small pixel drawing of a pufferfish dotfiles

Make bat red if it's low
Jes Olson j3s@c3f.net
Mon, 13 Jun 2022 23:01:40 -0500
commit

a346b7f4010d95184bf78377df94516af84198f8

parent

7d457ec35c9ec159b73cbd8c9f25b93719f07cd1

1 files changed, 10 insertions(+), 1 deletions(-)

jump to
M bin/nostromo/statusbarbin/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