summaryrefslogtreecommitdiff
path: root/local/bin/update-dwm-bar
diff options
context:
space:
mode:
authorDavid Phillips <david@sighup.nz>2016-10-26 20:44:03 +1300
committerDavid Phillips <david@sighup.nz>2016-10-26 20:44:03 +1300
commit49b53c75b94aea509436536f94dc3e65354b9fcf (patch)
treeb4b9fa0153e79d67c4aef01ca346a4d7a7b334c7 /local/bin/update-dwm-bar
parent4b84b1c26b4b0ca4a6b2fad3e133e628b10f8f6c (diff)
downloaddotfiles-49b53c75b94aea509436536f94dc3e65354b9fcf.tar.xz
Add local/bin files
Diffstat (limited to 'local/bin/update-dwm-bar')
-rwxr-xr-xlocal/bin/update-dwm-bar27
1 files changed, 27 insertions, 0 deletions
diff --git a/local/bin/update-dwm-bar b/local/bin/update-dwm-bar
new file mode 100755
index 0000000..ff3a389
--- /dev/null
+++ b/local/bin/update-dwm-bar
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+DELAY=20
+sep=$(echo -e '\u2502')
+
+while true; do
+ bat="$(cat /sys/class/power_supply/BAT0/capacity)%"
+ case "$(cat /sys/class/power_supply/BAT0/status)" in
+ Full)
+ bat_icon='✓'
+ ;;
+ Charging)
+ bat_icon='▲'
+ ;;
+ Discharging)
+ bat_icon='▼'
+ ;;
+ *)
+ bat_icon="(?)"
+ ;;
+ esac
+ bat_string="$bat_icon $bat"
+ datetime_string=$(date "+%A $sep %d %h %Y $sep %_I:%M %p (UTC%:::z)")
+ xsetroot -name "$(uname -r) $sep $bat_string $sep $datetime_string" || exit
+ sleep "$DELAY"
+done
+