aboutsummaryrefslogtreecommitdiffstats
path: root/dwm-statusbar
diff options
context:
space:
mode:
Diffstat (limited to 'dwm-statusbar')
-rwxr-xr-xdwm-statusbar44
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