summaryrefslogtreecommitdiff
path: root/local/bin/update-dwm-bar
blob: ac6858275827256ceeb1946da0995530fd2382e2 (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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash

DELAY=20
sep=$(echo -e '\u2502')

while true; do
	if hash upsc 2>/dev/null; then
		ups="UPS: $(upsc eaton5e@zoidberg battery.charge)% $sep "
	fi
	if [ -f ~/.cache/XAGNZD ]; then
		xa="$(cat ~/.cache/XAGNZD) $(cat ~/.cache/XAUNZD) $sep "
	fi
	if [ -d "/sys/class/power_supply/BAT0/" ]; then
		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 $sep "
	fi
	thermal_string="🌡"
	for zone in /sys/class/thermal/thermal_zone* ; do
		temp="$(cat $zone/temp)"
		thermal_string="$thermal_string $(($temp / 1000)),"
	done
	thermal_string="${thermal_string%,} °C"
	datetime_string=$(date "+%A $sep %d %h %Y $sep %_I:%M %p (UTC%:::z)")
	xsetroot -name "$xa$ups$thermal_string $sep $bat_string$datetime_string" || exit
	sleep "$DELAY"
done