Low-batt notification for Puppy? (Solved)

Using applications, configuring, problems
Message
Author
User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

Re: Xbatalarm combined with powerapplet_tray

#21 Post by MochiMoppel »

gjuhasz wrote:For those cannot get powerapplet_tray working, I referenced it in xbatalarm.
Among other changes, I applied new icons and forced the right one to appear in the tray
What exactly is the difference between the original powerapplet_tray and the one you packed into the pet?

The original icons were quite ugly, but your binary appears to contain no icons at all. After starting the binary it runs in the tray, but the spot remains blank. I see that the accompanying script xbatalarm links to the binary and that they work together, but if I understand the script correctly it kills and restarts the binary every 30sec. which I find a bit rough. I would prefer to use a nicer looking, stand-alone powerapplet_tray. Are you planning to add icons?

User avatar
corvus
Posts: 153
Joined: Fri 12 Jun 2015, 18:00
Location: In the peninsula shaped like a boot.

#22 Post by corvus »

Evening, all.
And thank you for your interest to my request.
I thought of something simple like:
SUSP_MARK=$(echo "$LAST_F_CHRG * $SUSP_PERC / 100" | bc) # with $SUSP_PERC entry in xbatalarm.conf

if (( $(bc <<< "$REAL_CHRG < $SUSP_MARK") )); then
acpitool -s &
fi
to be included somewhere in xbatalarm and its entry to xbatalarm.conf
thanks again. :)

corvus
[b]We are waves of the same sea, leaves of the same tree, flowers of the same garden.[/b]

User avatar
gjuhasz
Posts: 422
Joined: Mon 29 Sep 2008, 14:28

Re: Xbatalarm combined with powerapplet_tray

#23 Post by gjuhasz »

MochiMoppel wrote:What exactly is the difference between the original powerapplet_tray and the one you packed into the pet?
...
After starting the binary it runs in the tray, but the spot remains blank
Oops... I found an earlier, buggy version at the link I advertised. :oops: The correct version is uploaded as http://www.smokey01.com/gjuhasz/packages/xbat.pet
Now, the battery status is visualized by the tray icon and the warning message pops up repeatedly when 10% or less capacity remained.
After installed, you can activate it either by clicking on the xbatalarm menu item or by restarting X. Next time it will auto-start.
Sorry for the inconvenience.
The original icons were quite ugly, but your binary appears to contain no icons at all. ... Are you planning to add icons?
The redesigned icons are in /usr/share/pixmaps/puppy folder.
I see that the accompanying script xbatalarm links to the binary and that they work together, but if I understand the script correctly it kills and restarts the binary every 30sec. which I find a bit rough. I would prefer to use a nicer looking, stand-alone powerapplet_tray.
You are right. But it is intentional. I recognized that the binary powerapplet_tray fails to point dynamically to the right icon (so it is unable to mirror the actual battery status) but did not modify it. Instead, I only regularly provide the binary with the right picture behind the fixed blank.svg filename :shock:
Just one note: I only check the status instead of restarting the binary in every 30 sec... restarting happens only if a new picture shall be displayed. :wink:

Have fun!

Regards,

gjuhasz
Attachments
Newicons.jpg
(19.85 KiB) Downloaded 407 times

User avatar
gjuhasz
Posts: 422
Joined: Mon 29 Sep 2008, 14:28

Re: xbat and acpitool

#24 Post by gjuhasz »

gjuhasz wrote:Please give me some time to check with a 64-bit puplet (possibly slacko64).
Well,

the powerapplet_tray binary fails to work in Slacko 64 either, but performs it differently. :wink:

I plan to fix it as soon as I have time. However, for enthusiasts who want to see a dynamically changing powerapplet_tray icon in Slacko64, here is the list of steps (after installed my xbat.pet which works fine for 32-bit puplets such as Tahr 6.0.5):
  • 1. Remove /usr/bin/powerapplet_tray installed with my my xbat.pet and restore the original one from /initrd/pup_ro2/usr/bin
    2. Move my new icons from /usr/share/pixmaps/puppy to /usr/share/powerapplet
    3. Temporarily, change the theme in Slacko64 to any other one
    4. Restart X
    5. Set up the previous theme
:)

Have fun!

Regards,

gjuhasz

sfs
Posts: 49
Joined: Sat 02 Nov 2013, 04:49
Location: Russia
Contact:

Re: xbat and acpitool

#25 Post by sfs »

[url=https://sourceforge.net/projects/puppyrusa/]PuppyRus-Arch[/url]

User avatar
gjuhasz
Posts: 422
Joined: Mon 29 Sep 2008, 14:28

Re: xbat and acpitool

#26 Post by gjuhasz »

corvus wrote:I have a request it's possible to modify xbat so as to suspend the laptop with acpitool's -s option when it reaches to a particular discharge percentage and to include this option in the xbatalarm-config?
Please find my first attempt to suspend the machine at http://smokey01.com/gjuhasz/packages/xbat-s.pet

Please notice that this is for test purposes that suspends the machine just a couple of minutes after the low-batt warning.

Please take a look at Lines 15-16 in /usr/bin/xbatalarm script:

Code: Select all

ALRM_MARK=$(echo "$LAST_F_CHRG * $ALRM_PERC  / 100" | bc)
SUSP_MARK=$(echo "$LAST_F_CHRG * $ALRM_PERC  / 101" | bc)
The production version will allow more gap between the first alarm and the hibernation:

Code: Select all

ALRM_MARK=$(echo "$LAST_F_CHRG * $ALRM_PERC  / 100" | bc)
SUSP_MARK=$(echo "$LAST_F_CHRG * $ALRM_PERC  / 150" | bc)
Proposed test case:
  • 1. Install xbat-s.pet. Ensure that the charger is disconnected and no USB sticks remain mounted.
    2. In a terminal, issue acpi to see the actual battery percentage.
    3. From the System menu, run xbatalarm-config and set the actual acpi battery percentage :!: as alarm level.
    4. Check the alerts displayed (in each 30 seconds about low batt level)
    5. Wait some minutes until the hibernation alert arrives. The machine is hibernated in 10 seconds, the (machine-specific) LED slowly blinks.
    6. Connect the charger.
    7. To wake up the machine, shortly press the power button (in most cases, this contains the slowly blinking LED). The machine should wake up then show the previously seen graphical content of X in a few seconds.
Known issues that lead to inaccessible/crashed items in X after wake up:
  • 1. If you do not connect the charger while the machine is hibernated, it will be hibernated again, just after you wake the machine up.
    2. If hibernation happens during high CPU/memory usage, the machine may not wake up (needs to be rebooted by long pressing the power button).
    3. If there is a write process to the pendrive, data can be lost or even its filesystem can be damaged.
I would appreciate to receive any feedback.
Also, I am interested in your opinion about the best hibernation risk policy. That is, forcing some pre-emptive commands that admit some smaller issues to avoid the bigger problems. For example, force unmount of all devices, exit running programs, exit to prompt (closing X), etc., may cause loss of the latest session's data but prevents data loss in the "innocent" filesystem(s).

Thanks in advance

Have fun!

Regards,

gjuhasz

User avatar
corvus
Posts: 153
Joined: Fri 12 Jun 2015, 18:00
Location: In the peninsula shaped like a boot.

#27 Post by corvus »

Hi gjuhasz, I tested xbat-s, now the powerapplet icons are displayed correctly. I followed your instructions step by step, with my frugal installation booted via USB pendrive, but when xbat has tried to suspend the system it has restarted X.
After several tests I realized that your acpitool binary has a wrong ELFCLASS (it's not 64 bit) so I replaced it with the right one, downloaded from PPM, and it worked. :D
I need more time to test it better. I thank you for the time and effort in improving this tool. :)

Regards,

corvus
[b]We are waves of the same sea, leaves of the same tree, flowers of the same garden.[/b]

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

Re: Xbatalarm combined with powerapplet_tray

#28 Post by MochiMoppel »

gjuhasz wrote:Just one note: I only check the status instead of restarting the binary in every 30 sec... restarting happens only if a new picture shall be displayed. :wink:
I'm afraid not :wink:
This happens every 30sec when AC is plugged in and battery is fully charged (code line 41), i.e. even during a time when no new icon needs to be displayed:.

Code: Select all

cp /usr/share/pixmaps/puppy/charged.svg /usr/share/pixmaps/puppy/blank.svg
sync
killall -9 powerapplet_tray; sync ;powerapplet_tray &
That's a lot of copying and killing and resurrenction. :lol:

User avatar
gjuhasz
Posts: 422
Joined: Mon 29 Sep 2008, 14:28

Re: Xbatalarm combined with powerapplet_tray

#29 Post by gjuhasz »

MochiMoppel wrote:That's a lot of copying and killing and resurrenction. :lol:
Fixed. Dear MochiMoppel, thanks for the notification.

I uploaded three xbat flavors to http://www.smokey01.com/gjuhasz/packages
  • 1. xbat.pet - 32-bit tray binary included
    2. xbat-p.pet - for Puli users. No tray binary (thus hopefully compatible with 64-bit Slacko, too)
    3. xbat-s.pet - my 2nd attempt to correctly suspend the machine. Same as xbat-p above, with additional suspend feature.
    No tray binary either. Works without acpitool on the laptops I have access to.
    Known issue: If a USB stick remained plugged in (even if unmounted), some laptops rise from sleep after 2-3 seconds.

Dear corvus - could you please check the new xbat-s? Here, with reference to my above post, I apply a realistic preset

Code: Select all

SUSP_MARK=$(echo "$LAST_F_CHRG * $ALRM_PERC  / 150" | bc)
  • where it is better to temporarily change the value from 150 to 101 for testing purposes. Also, in the updated /usr/bin/suspend script, I commented out the acpitool call in favor of the simpler method in the next line - you can switch back if necessary.
    I understand that adding a $SUSP_PERC entry to xbatalarm.conf is more elegant but some additional hint or constraint
    (e.g., 5 < $SUSP_PERC < $ALRM_PERC ) shall be applied in this case to help novice users.
Have fun!

Regards,

gjuhasz

User avatar
corvus
Posts: 153
Joined: Fri 12 Jun 2015, 18:00
Location: In the peninsula shaped like a boot.

#30 Post by corvus »

Hi gjuhasz, I did several tests with xbat-s.pet, works fine but on one occasion at wake up the system crashed with the following error:
puppypc1672 login: [drm: gen8_irq_handler [i915]] * ERROR * the master control interrupt lied (SDE)
and I made a forced restart to fix the system. :?

Code: Select all

SUSP_MARK=$(echo "$LAST_F_CHRG * $ALRM_PERC  / 150" | bc)
With the above settings and default xbatalarm-config my system went into suspension around the 5%.
The new string, for suspension, did not affect the overall functions I still enjoyed the choice of using acpitool.
Great work, thanks. :) :)

corvus
[b]We are waves of the same sea, leaves of the same tree, flowers of the same garden.[/b]

muggins
Posts: 6724
Joined: Fri 20 Jan 2006, 10:44
Location: hobart

#31 Post by muggins »

I recently changed my pupversion & liked everything except the included powerapplet_tray, which didn'r seem to reflect my laptop's real battery state.

So i'm happy I came across sfs's link for cbatticon, which is easy to compile, accurately reflects battery state, and with which you can have a script in /root/Startup with something like:

Code: Select all

cbatticon -l 10 -r 5 -c wmpoweroff
where it will warn you when percentage gets to 10, then poweroff at 5%.
Last edited by muggins on Sat 10 Feb 2018, 21:35, edited 1 time in total.

User avatar
festus
Posts: 235
Joined: Wed 14 Jan 2015, 19:10

#32 Post by festus »

muggins wrote:I recently changed my pupversion & liked everything except the included powerapplet_tray, which didn'r seem to reflect my laptop's real battery state.

So i'm happy I came across sfs's link for cbatticon, which is easy to compile, accurately reflects battery state, and with which you can have a script in /root/Startup with something like:

Code: Select all

cbatticon -l 10 -r 5 -c wmrpoweroff
where it will warn you when percentage gets to 10, then poweroff at 5%.
Hello, muggins, I am interested in this battery app, but can not compile it, as I have always compiled sources starting with - "./configure --prefix=/usr"
and it did not work with this cbatticon source.

Would you, please, post your comp. recipe for this app.?

btw, I'm using xenial-7.5 & slacko-6999, if that matters any.

Thank you

bliss,
festus

muggins
Posts: 6724
Joined: Fri 20 Jan 2006, 10:44
Location: hobart

#33 Post by muggins »

Hello Festus,

I just ran the included makefile & it generated a 31k binary. You can than
just copy the binary to /usr/bin.

matchpoint
Posts: 168
Joined: Fri 26 Jan 2018, 20:54

#34 Post by matchpoint »

Hello festus, run the build like this: make WITH_GTK3=0

muggins
Posts: 6724
Joined: Fri 20 Jan 2006, 10:44
Location: hobart

#35 Post by muggins »

Thanks Matchpoint,

I forgot you can compile it for gtk3 or gtk2. I just changed line 7, of the makefile, to "WITH_GTK3 = 0".

muggins
Posts: 6724
Joined: Fri 20 Jan 2006, 10:44
Location: hobart

#36 Post by muggins »

OK,

here's a pet attached for anyone that wants to try it. I don't know that it will work in every pupversion, but it should in most.

Run

Code: Select all

cbatticon -h
to see usage options. Or open, in a text editor, the script /root/Startup/cbatt and modify it to suit your laptop/preferences. At the moment it has:

Code: Select all

#!/bin/sh

cbatticon -l 5 -r 3 -c wmreboot
So is set to reboot when battery level gets to 3%.
Attachments
CBattIcon-1.6.7.pet
(19.1 KiB) Downloaded 171 times

User avatar
festus
Posts: 235
Joined: Wed 14 Jan 2015, 19:10

#37 Post by festus »

Thanks for the help, muggins & matchpoint.

I should have realized running "make" would work since it already contained the Makefile.

I am testing it on slacko-6999(32 bit), using "WITH_GTK3 = 1", since I installed gtk3 in this pup.

@muggins
In your initial post about cbatticon, is thie command correct?:
cbatticon -l 10 -r 5 -c wmrpoweroff
the "wmrpoweroff" in particular?
Is the "r" supposed to be there?

Thanks again,
festus

User avatar
bigpup
Posts: 13886
Joined: Sun 11 Oct 2009, 18:15
Location: S.C. USA

#38 Post by bigpup »

I would call that a typo.
Puppy uses

Code: Select all

wmpoweroff
The things they do not tell you, are usually the clue to solving the problem.
When I was a kid I wanted to be older.... This is not what I expected :shock:
YaPI(any iso installer)

User avatar
festus
Posts: 235
Joined: Wed 14 Jan 2015, 19:10

#39 Post by festus »

bigpup wrote:I would call that a typo.
Puppy uses

Code: Select all

wmpoweroff
Thanks, bigpup, for the clarification.

I decided to use the gtk-2 vesion on all my pups, and tested it out on slacko-6999 by letting the battery run down past my critical setting of 5%, and it did indeed poweroff the laptop, as desired.

Thanks to all,
festus

muggins
Posts: 6724
Joined: Fri 20 Jan 2006, 10:44
Location: hobart

#40 Post by muggins »

Yes,

a typo as bigpup said. Corrected initial post. Thanks.

Post Reply