diff options
author | June McEnroe <june@causal.agency> | 2021-02-09 21:56:30 -0500 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2021-02-09 22:02:38 -0500 |
commit | 4db0a0fba5df91c82dc48881a6c82d0d2585040a (patch) | |
tree | 9b23420b8d74e841d1d0d34f9e89f8cf8a6522a4 /home | |
parent | Install sct (diff) | |
download | src-4db0a0fba5df91c82dc48881a6c82d0d2585040a.tar.gz src-4db0a0fba5df91c82dc48881a6c82d0d2585040a.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-x | home/.local/bin/clock | 9 |
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 |