Forum › Forums › Official Releases › antiX-21/22 “Grup Yorum” › Laptop Battery Status
- This topic has 13 replies, 6 voices, and was last updated Aug 22-4:57 pm by 3guesses.
-
AuthorPosts
-
August 13, 2022 at 12:22 pm #87161Member
3guesses
Hi,
I currently use antiX on my laptop, so the status of the battery is quite important. I have enabled the battery status in conky, but I have a couple of questions:
– is is possible for conky to display a different coloured bar depending on whether or not the battery is charging / discharging, and if it is below a specific level (eg. 20%)?
– is it possible to put some sort of battery / power icon in the system bar which I can hover over with the mouse pointer to get a tool-tip showing the battery status?
Thanks for any help!
3g
August 13, 2022 at 1:52 pm #87165Member
punranger
::Can’t answer for Conky, but in the default ROX-IceWM config, there’s a battery status bar next to the system tray. (Click for full size.)
- This reply was modified 8 months, 3 weeks ago by punranger.
Attachments:
antiX linux: The best way to revive an old computer - https://www.youtube.com/watch?v=JCTaUAP6sSg
August 13, 2022 at 1:57 pm #87169Anonymous
::– for conky
Yes, that is feasible (whether today, however, I do not know)
I assume you mean something like this:

That was many years ago. The one needs the kernel module ‘smapi’ and works only with ThinkPads.
The relevant lines were:${color}CycleCount: ${execi 60 cat /sys/devices/platform/smapi/BAT0/cycle_count} ${color}Capacity: ${execi 60 cat /sys/devices/platform/smapi/BAT0/design_capacity}${alignr}${color red}${execi 60 cat /sys/devices/platform/smapi/BAT0/remaining_capacity} mWh ${color}BAT0-temp: ${execi 60 cat /sys/devices/platform/smapi/BAT0/temperature} °C/1000 ${color}FAN: ${ibm_fan} rpm ${color}CPU: ${acpitemp}C° ${color}Battery: ${alignr}${if_match ${battery_percent BAT0} >= 100}${color white}${battery_bar 10,60 BAT0}${else}${if_match ${battery_percent BAT0} < 99}${color green}${battery_bar 10,60 BAT0}${else}${if_match ${battery_percent BAT0} < 55}${color yellow}${battery_bar 10,60 BAT0}${else}${if_match ${battery_percent BAT0} <= 32}${color red}${battery_bar 10,60 BAT0}${endif}${endif}${endif}${endif} ${voffset -22}${alignr 12}${font :size=7}${color black}${battery_percent BAT0}%${font}The other lines:
${voffset 0}${offset 775}${color2} Power ${offset 775}$color0 Battery: ${alignr 15}${if_match ${battery_percent BAT0} >= 99}${color white}${battery_bar 15,130 BAT0}${else}${if_match ${battery_percent BAT0} < 99}${color green}${battery_bar 15,130 BAT0}${else}${if_match ${battery_percent BAT0} < 50}${color yellow}${battery_bar 15,130 BAT0}${else}${if_match ${battery_percent BAT0} <= 30}${color red}${battery_bar 15,130 BAT0}${endif}${endif}${endif}${endif} ${voffset -22}${alignr 47}${font :size=7}${color black}${battery_percent BAT0}%${font} #$acpiacadapter ${battery_percent BAT0}% ${offset 775}$color0 #$battery $battery_timeI don’t know if this still works today, so, trial and error.
August 13, 2022 at 4:40 pm #87178ModeratorBobC
::Maybe one of these would help
https://www.antixforum.com/forums/topic/conky-mods/page/3/#post-22392
https://www.antixforum.com/forums/topic/what-battery-monitor-do-you-recommend-2/#post-13766
PS: just thinking aloud on the logic,
If AC power on
.. Show battery percent,
.. if 100 percent
…. show est time battery will hold
.. else
…. show time till full charge
else
.. show est time battery will hold
.. if battery percent >= 66 (or some value)
…. show percent bar in yellow
.. elseif battery percent >= 40 (or some value)
…. show percent bar in orange
.. elseif
…. show percent bar in redI haven’t been running any kind of battery monitor on my main laptop. It’s now getting old and I’ve run out of battery on average once a month as a result of not noticing it was running low, and crashing as a result. The usually the screen has an application window covering the conky. I should get a visible/audible alarm working again. Machines that crash tend to develop other issues.
- This reply was modified 8 months, 3 weeks ago by BobC.
- This reply was modified 8 months, 3 weeks ago by BobC.
- This reply was modified 8 months, 3 weeks ago by BobC.
August 14, 2022 at 4:00 pm #87232Member
iznit
::whether or not the battery is charging / discharging
Accurately gauging this might be elusive. Easy to detect whether connected to A/C….. but what utility can track if the battery is healthy and accepting [[[gaining]]] a charge at the expected rate? For each laptop+battery SKU combination, the specified [[[healthy, normal]]] charging rate likely differs. Charging rate probably varies with battery temperature also…..
August 20, 2022 at 12:15 pm #87485Member3guesses
::Can’t answer for Conky, but in the default ROX-IceWM config, there’s a battery status bar next to the system tray. (Click for full size.)
Thanks, yes, a partial solution seems to be to uncomment (ie remove the leading #) the line #TaskBarShowAPMAuto=1 # 0/1 in ~/.icewm/preferences – that puts a little bar icon in the system tray which seems to be yellow when the battery is discharging and green when charging, while hovering over it shows the battery status (% charged, and charging / discharging).
There’s also TaskBarShowAPMTime and TaskBarShowAPMGraph, but I haven’t experimented with them yet!
August 20, 2022 at 12:15 pm #87487Member3guesses
::– for conky
Yes, that is feasible (whether today, however, I do not know)
I assume you mean something like this:

That was many years ago. The one needs the kernel module ‘smapi’ and works only with ThinkPads.
The relevant lines were:${color}CycleCount: ${execi 60 cat /sys/devices/platform/smapi/BAT0/cycle_count} ${color}Capacity: ${execi 60 cat /sys/devices/platform/smapi/BAT0/design_capacity}${alignr}${color red}${execi 60 cat /sys/devices/platform/smapi/BAT0/remaining_capacity} mWh ${color}BAT0-temp: ${execi 60 cat /sys/devices/platform/smapi/BAT0/temperature} °C/1000 ${color}FAN: ${ibm_fan} rpm ${color}CPU: ${acpitemp}C° ${color}Battery: ${alignr}${if_match ${battery_percent BAT0} >= 100}${color white}${battery_bar 10,60 BAT0}${else}${if_match ${battery_percent BAT0} < 99}${color green}${battery_bar 10,60 BAT0}${else}${if_match ${battery_percent BAT0} < 55}${color yellow}${battery_bar 10,60 BAT0}${else}${if_match ${battery_percent BAT0} <= 32}${color red}${battery_bar 10,60 BAT0}${endif}${endif}${endif}${endif} ${voffset -22}${alignr 12}${font :size=7}${color black}${battery_percent BAT0}%${font}The other lines:
${voffset 0}${offset 775}${color2} Power ${offset 775}$color0 Battery: ${alignr 15}${if_match ${battery_percent BAT0} >= 99}${color white}${battery_bar 15,130 BAT0}${else}${if_match ${battery_percent BAT0} < 99}${color green}${battery_bar 15,130 BAT0}${else}${if_match ${battery_percent BAT0} < 50}${color yellow}${battery_bar 15,130 BAT0}${else}${if_match ${battery_percent BAT0} <= 30}${color red}${battery_bar 15,130 BAT0}${endif}${endif}${endif}${endif} ${voffset -22}${alignr 47}${font :size=7}${color black}${battery_percent BAT0}%${font} #$acpiacadapter ${battery_percent BAT0}% ${offset 775}$color0 #$battery $battery_timeI don’t know if this still works today, so, trial and error.
Thanks very much. I shall investigate in due course!
August 20, 2022 at 12:17 pm #87488Member3guesses
::whether or not the battery is charging / discharging
Accurately gauging this might be elusive. Easy to detect whether connected to A/C….. but what utility can track if the battery is healthy and accepting [[[gaining]]] a charge at the expected rate? For each laptop+battery SKU combination, the specified [[[healthy, normal]]] charging rate likely differs. Charging rate probably varies with battery temperature also…..
Yes – whether the laptop is A/C-connected is really all I’m after (ie the battery is not discharging), nothing more complex than that 😎
August 20, 2022 at 1:26 pm #87493ModeratorBobC
::What version of antiX are you running and with which desktop?
As noted by punranger, the default rox-icewm desktop should show the battery monitor. If you are connected it to power will be green, else yellow or black when discharging, by default.
The hover feature should also work.
August 21, 2022 at 7:53 am #87529Member
iznit
::Not a exact solution to the OP’s goal but I found this, it shows example output of “upower” command https://askubuntu.com/questions/69556/how-do-i-check-the-batterys-status-via-the-terminal
If your battery is indeed recognized as “battery_BAT0”, adding this snipplet into your conky config would give more info than just the battery “status”…..
${execi 30 upower -i /org/freedesktop/UPower/devices/battery_BAT0| grep -E "state"} ${execi 30 upower -i /org/freedesktop/UPower/devices/battery_BAT0| grep -E "to\ full"} ${execi 30 upower -i /org/freedesktop/UPower/devices/battery_BAT0| grep -E "percentage"}should produce 3 lines like these within the displayed conky output
state: charging time to full: 57.3 minutes percentage: 42.5469%unknown to me: Does the upower output change, if the system locale is something other than *english?
The above really needs some “checking”. Like, makes no sense to display “time to full” when the current state is not “charging”.
August 21, 2022 at 2:40 pm #87532Moderator
christophe
::Do you think xbattbar would be what you’re looking for?
After installation, add
xbattbar -t 4 -p 1 -I gray -i black -O purple -o red -c right &
to your startup file.
(Click the images below to see it better.)
First image shows battery dischaging – red bar on right.
Second image shows battery charging – blue bar on right.
Obviously you can designate where the bar is displayed, top/left/bottom/right.- This reply was modified 8 months, 2 weeks ago by christophe.
confirmed antiX frugaler, since 2019
August 21, 2022 at 5:21 pm #87548Anonymous
::@iznit,
unfortunately my battery is broken. Your (conky)code works only in english.
@christophe,
thanks for xbattbar. I did not know that yet. I made the bar a bit wider because otherwise my eyes don’t see it.
BTW, your images stay small after clicking. I can not see it.

xbattbar -t 8 -p 1 -I gray -i black -O purple -o red -c left &August 22, 2022 at 12:33 am #87565Moderator
christophe
::Bigger pix, for anyone else whose eyes are worse than mine 😉
(Note: clicking on them will show the red/blue bar on the upper right of the screen better, against the grey background.)- This reply was modified 8 months, 2 weeks ago by christophe.
confirmed antiX frugaler, since 2019
August 22, 2022 at 4:57 pm #87589Member3guesses
::Thank you all for the very helpful replies. I shall investigate them all when I get a chance!
-
AuthorPosts
- You must be logged in to reply to this topic.




