diff options
author | Eduardo Pedroni <e.pedroni91@gmail.com> | 2015-11-01 17:15:45 +0100 |
---|---|---|
committer | Eduardo Pedroni <e.pedroni91@gmail.com> | 2015-11-01 17:15:45 +0100 |
commit | 439d828830dcd912b723be3026fa188a7e313286 (patch) | |
tree | 6b73445d0aa560b7a2e1327daec740bc0e0cfced | |
parent | 3e376d1937fca8c9ad50c1917e763c347cc85f02 (diff) |
Added battery code to dwm-statusbar
-rwxr-xr-x | dwm-statusbar | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/dwm-statusbar b/dwm-statusbar index 42353c9..44e2555 100755 --- a/dwm-statusbar +++ b/dwm-statusbar @@ -61,6 +61,50 @@ print_volume() { echo -ne "${icon_colour}${icon}${vol_colour}${volume}%" } +# This will probably need tweaking +print_battery() { + # charging E20D, empty E20E, full E20F, 2/3 E210, 1/3 E211 + # 1 or 0 + ac_status=$(cat /sys/class/power_supply/AC/online) + + if [ $ac_status -eq 1 ]; then + icon_colour=$colour_neutral + if [ -d "/sys/class/power_supply/BAT0" ]; then + icon="\uE20D" + bat_colour=$colour_normal + bat_capacity="$(cat /sys/class/power_supply/BAT0/capacity)%" + else + icon="\uE257" + fi + else + bat_capacity=$(cat /sys/class/power_supply/BAT0/capacity) + if [ $bat_capacity -lt 10 ]; then + bat_colour=$colour_critical + icon_colour=$colour_critical + icon="\uE20E" + elif [ $bat_capacity -lt 25 ]; then + bat_colour=$colour_warning + icon_colour=$colour_warning + icon="\uE211" + elif [ $bat_capacity -lt 50 ]; then + bat_colour=$colour_normal + icon_colour=$colour_neutral + icon="\uE1FB" + elif [ $bat_capacity -lt 75 ]; then + bat_colour=$colour_normal + icon_colour=$colour_neutral + icon="\uE210" + else + bat_colour=$colour_normal + icon_colour=$colour_neutral + icon="\uE20F" + fi + bat_capacity="${bat_capacity}%" + fi + + echo -ne "${icon_colour}${icon}${bat_colour}${bat_capacity}" +} + # This should work out of the box print_root_free() { # floppy E0C3 |