summary refs log tree commit diff
path: root/home
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2021-02-09 21:56:30 -0500
committerJune McEnroe <june@causal.agency>2021-02-09 22:02:38 -0500
commit6e29174b0948e497d0cc58e7da9ce8ed4f11c0db (patch)
tree6a6af06ab38f0d76aeec75e823cb6b41114a7e70 /home
parentInstall sct (diff)
downloadsrc-6e29174b0948e497d0cc58e7da9ce8ed4f11c0db.tar.gz
src-6e29174b0948e497d0cc58e7da9ce8ed4f11c0db.zip
Show battery level while charging, time while discharging
Also fix initial sleep calculation when seconds has a leading zero,
and limit the length of time left for when it initially says
"unknown".
Diffstat (limited to 'home')
-rwxr-xr-xhome/.local/bin/clock9
1 files changed, 7 insertions, 2 deletions
diff --git a/home/.local/bin/clock b/home/.local/bin/clock
index 8f30ea8e..704b4040 100755
--- a/home/.local/bin/clock
+++ b/home/.local/bin/clock
@@ -2,9 +2,14 @@
 set -eu
 
 tput civis
-sleep=$(( 60 - $(date +'%S') ))
+sleep=$(( 60 - $(date +'%S' | sed 's/^0//') ))
 while :; do
-	printf '%3sm %s' "$(apm -m)" "$(date +'%a %H:%M')"
+	if [ $(apm -a) -eq 1 ]; then
+		printf '%3s%%' "$(apm -l)"
+	else
+		printf '%3.3sm' "$(apm -m)"
+	fi
+	printf ' %s\r' "$(date +'%a %H:%M')"
 	sleep $sleep
 	sleep=60
 done