From c451f3cdd9baf645b56aa05a33d4a56570343c14 Mon Sep 17 00:00:00 2001 From: TolaMironcenko Date: Tue, 5 Nov 2024 18:55:02 +0700 Subject: [PATCH] updated batperc and added fontcharlist --- bin/batperc | 8 ++++---- bin/fontcharlist | 28 ++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 bin/fontcharlist diff --git a/bin/batperc b/bin/batperc index d1aa0b7..9403205 100755 --- a/bin/batperc +++ b/bin/batperc @@ -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" diff --git a/bin/fontcharlist b/bin/fontcharlist new file mode 100644 index 0000000..008303d --- /dev/null +++ b/bin/fontcharlist @@ -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"'}' \ No newline at end of file