conky/battery_estimate: render h/m indicators as superscript

This commit is contained in:
Colin 2023-12-28 01:53:43 +00:00
parent 1df99978bb
commit 104e76de47

View File

@ -1,3 +1,4 @@
#!/bin/sh
#!/usr/bin/env nix-shell
#!nix-shell -i bash
@ -14,6 +15,27 @@ usage() {
icon_bat_chg=("󰢟" "󱊤" "󱊥" "󰂅")
icon_bat_dis=("󰂎" "󱊡" "󱊢" "󱊣")
# render time like: 2ʰ08ᵐ
# unicode sub/super-scripts: <https://en.wikipedia.org/wiki/Unicode_subscripts_and_superscripts>
symbol_hr="ʰ"
symbol_min="ᵐ"
# render time like: 2ₕ08ₘ
# symbol_hr="ₕ"
# symbol_min="ₘ"
# render time like: 2h08m
# symbol_hr="h"
# symbol_min="m"
# render time like: 2:08
# symbol_hr=":"
# symbol_min=
# render time like: 2'08"
# symbol_hr="'"
# symbol_min='"'
log() {
if [ "$BATTERY_ESTIMATE_DEBUG" = "1" ]; then
printf "$@" >&2
@ -88,7 +110,7 @@ fmt_minutes() {
hr=$(($3 / 60))
hr_in_min=$(($hr * 60))
min=$(($3 - $hr_in_min))
printf "%s %dh%02dm" "$1" "$hr" "$min"
printf "%s %d%s%02d%s" "$1" "$hr" "$symbol_hr" "$min" "$symbol_min"
fi
}