home · contact · privacy
Fix script. master
authorChristian Heller <c.heller@plomlompom.de>
Wed, 12 Mar 2025 06:48:50 +0000 (07:48 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Wed, 12 Mar 2025 06:48:50 +0000 (07:48 +0100)
testing/home/t490s/.nonpath_bins/status.sh

index 180aa395bccc7ad9c2456049f4844c5a142f255b..dcc30f10509dd28ecdcf27003622ebbb84eccd19 100755 (executable)
@@ -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