updated batperc and added fontcharlist

This commit is contained in:
wt
2024-11-05 18:55:02 +07:00
parent d4234ebf6a
commit c451f3cdd9
2 changed files with 32 additions and 4 deletions
+4 -4
View File
@@ -14,8 +14,8 @@ case "$1" in
exit 1;
fi
for i in $batteries; do
batfull=$(cat /sys/class/power_supply/$i/energy_full)
batnow=$(cat /sys/class/power_supply/$i/energy_now)
batfull=$(cat /sys/class/power_supply/$i/charge_full)
batnow=$(cat /sys/class/power_supply/$i/charge_now)
batperc=$((($batnow/($batfull/100))))
if [[ "$batperc" -le "20" ]]; then
@@ -37,8 +37,8 @@ case "$1" in
exit 1;
fi
for i in $batteries; do
batfull=$(cat /sys/class/power_supply/$i/energy_full)
batnow=$(cat /sys/class/power_supply/$i/energy_now)
batfull=$(cat /sys/class/power_supply/$i/charge_full)
batnow=$(cat /sys/class/power_supply/$i/charge_now)
batperc=$((($batnow/($batfull/100))))
printf "$batperc \n"
+28
View File
@@ -0,0 +1,28 @@
#!/bin/bash -
Usage() { echo "$0 FontFile"; exit 1; }
SayError() { local error=$1; shift; echo "$0: $@"; exit "$error"; }
[ "$#" -ne 1 ] && Usage
width=70
fontfile="$1"
[ -f "$fontfile" ] || SayError 4 'File not found'
list=$(fc-query --format='%{charset}\n' "$fontfile")
for range in $list
do IFS=- read start end <<<"$range"
if [ "$end" ]
then
start=$((16#$start))
end=$((16#$end))
for((i=start;i<=end;i++)); do
printf -v char '\\U%x' "$i"
printf '%b' "$char"
done
else
printf '%b' "\\U$start"
fi
done | grep -oP '.{'"$width"'}'