summary refs log tree commit diff
path: root/home/.local/bin/clock
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/.local/bin/clock
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 '')
-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
013-05-22 12:53:06 +0200'>2013-05-22shared.c: use die_errno() where appropriateJohn Keeping 2013-05-22html.c: die when write failsJohn Keeping 2013-05-22ui-log: add <span/> around commit decorationsJohn Keeping 2013-05-22Makefile: fix parallel "make test"John Keeping 2013-05-18cache.c: fix cache_lsJohn Keeping 2013-05-13t0109: "function" is a bash-ismJohn Keeping 2013-05-13New mailing list.Jason A. Donenfeld 2013-04-30ui-snapshot: do not access $HOMEJason A. Donenfeld 2013-04-27t0001: validate Git -rcN version numbers correctlyJohn Keeping 2013-04-27git: update to 1.8.2.2John Keeping 2013-04-17scan-tree: fix regression in section-from-path=-1John Keeping 2013-04-15t0001: ignore ".dirty" suffix on Git versionJohn Keeping 2013-04-15tests: set TEST_OUTPUT_DIRECTORY to the CGit test directoryJohn Keeping 2013-04-15t0109: test more URLsJohn Keeping 2013-04-10cgitrc.5.txt: Specify when scan-path must be defined before.Jason A. Donenfeld 2013-04-10ui-snapshot.c: Prepend "V" when guessing ref namesLukas Fleischer 2013-04-10t0107: Skip ZIP tests if unzip(1) isn't availableLukas Fleischer 2013-04-10tests/: Do not use `sed -i`Lukas Fleischer 2013-04-10Add branch-sort and repo.branch-sort options.Jason A. Donenfeld 2013-04-10t0109: chain operations with &&John Keeping 2013-04-10cgit.c: Do not restore unset environment variablesLukas Fleischer 2013-04-09t0107: Use `tar -z` for gzip'ed archivesLukas Fleischer