Low-batt notification for Puppy? (Solved)

Using applications, configuring, problems
Message
Author
User avatar
gjuhasz
Posts: 422
Joined: Mon 29 Sep 2008, 14:28

Xbatalarm combined with powerapplet_tray

#13 Post by gjuhasz »

Hi,

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.
Changed the default alarm level to 10%.
Tested in Puli, probably works for other puppies, too.

As powerapplet_tray is a built-in feature in many puplets, I also created a bare xbat-p.pet, see http://murga-linux.com/puppy/viewtopic. ... &start=154

Have fun!

Regards,

gjuhasz

Edit: first upload of the attachment failed, uploaded again.
Edit2: after bugfix, uploaded again
Edit3 on 29 Jan: after bugfix and some uplift, uploaded again. Thanks for the feedbacks.
Attachments
xbat.pet
MD5sum: 754de17b66e4578b661a233ae1d9018c
(8.64 KiB) Downloaded 204 times
Last edited by gjuhasz on Sat 30 Jan 2016, 02:14, edited 7 times in total.

B.K. Johnson
Posts: 807
Joined: Mon 12 Oct 2009, 17:11

#14 Post by B.K. Johnson »

@rcrsn51
What's the link for batterup?
[color=blue]B.K. Johnson
tahrpup-6.0.5 PAE (upgraded from 6.0 =>6.0.2=>6.0.3=>6.0.5 via quickpet/PPM=Not installed); slacko-5.7 occasionally. Frugal install, pupsave file, multi OS flashdrive, FAT32 , SYSLINUX boot, CPU-Dual E2140, 4GB RAM[/color]

User avatar
Mike Walsh
Posts: 6351
Joined: Sat 28 Jun 2014, 12:42
Location: King's Lynn, UK.

#15 Post by Mike Walsh »

Hi, B.K.

As far as I recall, the 'link' for batterup is that you need to request it from rcrsn51. Bill does things this way with a lot of the .pets that he creates, because it usually means that folk who do request an item are more likely to be serious about testing it out, and reporting back with results!

Hope that helps. Just drop him a request by PM if you'd like to try it out. That's usually all it takes. Be patient; it may take him a little while to get back to you.


Mike. :wink:

B.K. Johnson
Posts: 807
Joined: Mon 12 Oct 2009, 17:11

#16 Post by B.K. Johnson »

Mike Walsh wrote:
...Bill does things this way with a lot of the .pets that he creates, because it usually means that folk who do request an item are more likely to be serious about testing it out, and reporting back with results!
It's not the puppy forum way. :? :roll:

With apologies to the iconic quote from W.P. Kinsella's Field of Dreams: "If you build it, he will come."
Bill, "If you build it, they will come." "If you expose it, they will hear of it[find it]; don't and it stays hidden." :)
Hope that helps. Just drop him a request by PM if you'd like to try it out. That's usually all it takes. Be patient; it may take him a little while to get back to you.
Sure clears the air. Thanks Mike. Had you not made reference to batterup, nobody would have heard of it. It seems you were invited via PM to try it. Perhaps protocol would dictate that your test reports should have also been made in private. Naughty Mike! :P (kidding of course) As my lappy isn't working at the moment, no PM to Bill. I would not want to upset him by taking too long to report results. I'll just make a note in my archives that batterup is available on request. :wink:
[color=blue]B.K. Johnson
tahrpup-6.0.5 PAE (upgraded from 6.0 =>6.0.2=>6.0.3=>6.0.5 via quickpet/PPM=Not installed); slacko-5.7 occasionally. Frugal install, pupsave file, multi OS flashdrive, FAT32 , SYSLINUX boot, CPU-Dual E2140, 4GB RAM[/color]

User avatar
Mike Walsh
Posts: 6351
Joined: Sat 28 Jun 2014, 12:42
Location: King's Lynn, UK.

#17 Post by Mike Walsh »

Hi again, BK.
B.K.Johnson wrote:It's not the puppy forum way. :? :roll:

With apologies to the iconic quote from W.P. Kinsella's Field of Dreams: "If you build it, he will come."
Bill, "If you build it, they will come." "If you expose it, they will hear of it[find it]; don't and it stays hidden." :)
Well, I wouldn't exactly say it's hidden.....after all, there is a thread about it in plain sight on the forum:-

http://www.murga-linux.com/puppy/viewtopic.php?t=91019

.....and it's in the 'Utilities' section, right where you'd expect to find it. He's not hiding the fact that it exists; just being selective about who gets to test it, that's all. Makes sense to pick folks who are more likely to report back, I would have thought. But that's just me.

Some people just have their eccentricities; that's the way Bill prefers to do it.....seems to work well enough. He has made a lot of very useful contributions to the Forums, there's no denying that. I, myself, am using at least 7 of his pets that I can think of off the top of my head; all small, but very useful 'utilities' of various sorts.....that have made Puppy even more usable, if that's possible..!


Mike. :wink:

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

xbat and acpitool

#18 Post by corvus »

G'day gjuhasz, I tried your xbat-p.pet on an ASUS X555L laptop with Xanad's T64_Light-k_4.1.3 EmSee_x86-64 an Italian version derived from 666philb's Tahrpup64, It works very well, great job, Bravo. :D
The only drawback is that the icon of powerapplet in the tray remains the default (same with xbat.pet).
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?

Regards. :)

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

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#19 Post by Karl Godt »

Here is a modified version that tries to care for battery and emit a xmessage GUI
of /sbin/pup_event_frontend_d .

It is still the old script style, not the current binary exe.

I attach it to give you an idea .
If you want to install it, you may get problems even if set executable .
You can test it by pup_event_frontend_d restart option .

In the editor search for lines containing "BAT_0_CURRENT" .

The idea occured to me to check for battery inside pup_event_frontend_d, since it also
checks for the POWERTIMEOUT variable set in /etc/eventmanager .
If pup_event_frontend_d checks for mousecounts, it could also check for battery status .
Attachments
pup_event_frontend_d.gz
heavily modified
(13.81 KiB) Downloaded 230 times
«Give me GUI or Death» -- I give you [[Xx]term[inal]] [[Cc]on[s][ole]] .
Macpup user since 2010 on full installations.
People who want problems with Puppy boot frugal :P

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

Re: xbat and acpitool

#20 Post by gjuhasz »

corvus wrote:The icon of powerapplet in the tray remains the default (same with xbat.pet). 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?
Dear corvus,

Hm... I created xbat.pet to force tray icon based visualization - but tested with 32-bit puplets only on Dell and HP laptops. The icon changes according to the (dis)charging level going thru all statuses (see icons at /usr/share/pixmaps/puppy).
Please give me some time to check with a 64-bit puplet (possibly slacko64). Also, I will play with acpitool -s option, first in 32-bit version.

Have fun!

Regards,

gjuhasz

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

Post Reply