summaryrefslogtreecommitdiff
path: root/local/bin/update-dwm-bar
blob: ff3a3891185b67de36a04c265a736832617f2e69 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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