Make bat red if it's low
Jes Olson j3s@c3f.net
Mon, 13 Jun 2022 23:01:40 -0500
1 files changed,
10 insertions(+),
1 deletions(-)
jump to
M
bin/nostromo/statusbar
→
bin/nostromo/statusbar
@@ -1,10 +1,19 @@
#!/bin/sh +get_bat() { + bat="$(cat /sys/class/power_supply/BAT1/capacity)" + if [ "$bat" -lt 10 ]; then + printf '\033[1m\033[31m%s%%\033[0m' "$bat" + else + printf '%s%%' "$bat" + fi +} + while true do time=$(date +"%A %Y-%m-%d %I:%M %p") time="$time $(date -u +"(%H:%M UTC)")" - bat="$(cat /sys/class/power_supply/BAT1/capacity)%" + bat="$(get_bat)" wifi="$(nmcli -t dev show wlp170s0 | grep GENERAL.CONNECTION | cut -d ':' -f 2)" printf "wifi: %s | bat: %s | %s\n" "$wifi" "$bat" "$time" sleep 10