mirror of
https://git.adityakumar.xyz/dwmbar.git
synced 2024-11-21 18:12:53 +00:00
Added battery module
This commit is contained in:
parent
a87e9dff44
commit
e856077705
2 changed files with 37 additions and 0 deletions
35
modules/battery
Executable file
35
modules/battery
Executable file
|
@ -0,0 +1,35 @@
|
|||
#!/bin/bash
|
||||
|
||||
get_battery()
|
||||
{
|
||||
if [ -d /sys/class/power_supply/BAT? ]; then
|
||||
ac_adapter=$(cat /sys/class/power_supply/BAT?/status)
|
||||
if [ "$ac_adapter" == "Charging" ]; then
|
||||
echo ""
|
||||
fi
|
||||
|
||||
# Will show all batteries with approximate icon for remaining power.
|
||||
for x in /sys/class/power_supply/BAT?/capacity;
|
||||
do
|
||||
case "$(cat $x)" in
|
||||
100) echo "" ;;
|
||||
9[0-9]) echo " $(cat $x)%" ;;
|
||||
8[0-9]|7[0-9]) echo " $(cat $x)%" ;;
|
||||
6[0-9]|5[0-9]) echo " $(cat $x)%" ;;
|
||||
4[0-9]|3[0-9]) echo " $(cat $x)%" ;;
|
||||
2[0-9]|1[0-9]) if [ "$ac_adapter" == "Charging" ]; then
|
||||
echo " $(cat $x)%"
|
||||
else
|
||||
echo " $(cat $x)%"
|
||||
fi ;;
|
||||
[0-9]) if [ "$ac_adapter" == "Charging" ]; then
|
||||
echo " $(cat $x)%"
|
||||
else
|
||||
echo " $(cat $x)%"
|
||||
fi ;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
get_battery
|
|
@ -17,3 +17,5 @@ get_bluetooth()
|
|||
#echo ""
|
||||
fi
|
||||
}
|
||||
|
||||
get_bluetooth
|
||||
|
|
Loading…
Reference in a new issue