You are not logged in.
One of the statusbar examples on the dwm page has the following formula for calculating battery capacity:
DWM_BATTERY=$(( `cat /sys/class/power_supply/BAT0/energy_now` * 100 / `cat /sys/class/power_supply/BAT0/energy_full` ));
I noticed on my system this can be replaced with:
DWM_BATTERY=$( cat /sys/class/power_supply/BAT1/capacity )
Aside from the fact that my battery is named BAT1 instead of BAT0, can laptop users generally count on this file being present? If so then the example can be simplified.
Last edited by Ocypheum (2015-11-07 22:36:10)
Offline
Not necessarily. The example could certainly be made more efficient, but different models of laptop tend to report different information.
In any event, example in the wiki should just be considered examples, not canonical references: people are expected to adapt them to their own situations, not just copy and paste.
Offline
Just out of curiosity I checked if I have that capacity_level file because I have some battery related scripts and wanted to see if there is something useful in there.
$ cat /sys/class/power_supply/BAT0/capacity_level
Normal
Well...nice to know. I guess when the battery is low of charge it reports 'Low' instead.
So yeah, these information and their structure is machine dependent and there is no one script fits it all.
I put at button on it. Yes. I wish to press it, but I'm not sure what will happen if I do. (Gune | Titan A.E.)
Offline
Well...nice to know. I guess when the battery is low of charge it reports 'Low' instead.
Oops, that's because I said the wrong file. Check out /sys/class/power_supply/BAT0/capacity instead.
Anyways, point taken
(I also fixed my original post.)
Last edited by Ocypheum (2015-11-07 22:35:59)
Offline