From: Christian Heller Date: Wed, 12 Mar 2025 06:48:50 +0000 (+0100) Subject: Fix script. X-Git-Url: https://plomlompom.com/repos/%7B%7B%20web_path%20%7D%7D/decks/static/%7B%7Bprefix%7D%7D/ledger2?a=commitdiff_plain;h=a3cee8759041de26dffc798c846ba87567bcf84b;p=config Fix script. --- diff --git a/testing/home/t490s/.nonpath_bins/status.sh b/testing/home/t490s/.nonpath_bins/status.sh index 180aa39..dcc30f1 100755 --- a/testing/home/t490s/.nonpath_bins/status.sh +++ b/testing/home/t490s/.nonpath_bins/status.sh @@ -1,11 +1,13 @@ #!/bin/sh # see sway-bar(5) and swaybar-protocol(7) + +SYSCLASS_DIR=/sys/class + COL_WHITE=ffffff COL_RED=ff0000 COL_YELLOW=ffff00 COL_GREEN=00ff00 COL_GREY=aaaaaa -SYSCLASS_DIR=/sys/class print_bar_element() { if [ -z "$3" ]; then @@ -19,7 +21,7 @@ print_bar_element() { COLOR="$2" fi printf '{"full_text": "%s", ' "$1" - printf '"color": "%s", ', "${COLOR}" + printf '"color": "%s", ' "${COLOR}" printf '"separator_block_width": %d},\n' "${SEP_WIDTH}" } @@ -33,7 +35,7 @@ print_battery() { STATUS=$(cat "${BAT_DIR}/status") CHARGING=? if [ "${STATUS}" = "Not charging" ]; then - CHARGING=_ + CHARGING=- elif [ "${STATUS}" = "Charging" ]; then CHARGING=^ COLOR="${COL_GREEN}" @@ -55,10 +57,10 @@ print_battery() { print_temperature() { COLOR="${COL_WHITE}" TEMPERATURE=$(cat ${SYSCLASS_DIR}/thermal/thermal_zone0/temp) - TEMPERATURE_IN_C=$(calc "${TEMPERATURE} // 1000") - if [ $TEMPERATURE -gt 85 ]; then + TEMPERATURE_IN_C=$(printf "%d" $(calc "${TEMPERATURE} // 1000")) + if [ $TEMPERATURE_IN_C -gt 85 ]; then COLOR="${COL_RED}" - elif [ $TEMPERATURE -gt 65 ]; then + elif [ $TEMPERATURE_IN_C -gt 65 ]; then COLOR="${COL_YELLOW}" fi print_bar_element "${TEMPERATURE_IN_C}°C" "${COLOR}" @@ -79,5 +81,5 @@ while true; do print_temperature print_datetime printf '],' - sleep 0.5 + sleep 0.1 done