fix: clean up cpugov scripts and waybar polling

Replace infinite loop with single execution (waybar handles polling
via interval), fix unquoted variables, simplify jq invocation.
This commit is contained in:
nevaforget 2026-03-28 14:31:00 +01:00
parent f5d94e8bc0
commit ef78e32394
3 changed files with 37 additions and 46 deletions

View File

@ -49,19 +49,17 @@ value="$(start)"
# Split input.
# grab upto first space.
choice=${value%%\ *}
# graph remainder, minus space.
input=${value:$((${#choice}+1))}
##
# Cancelled? bail out
##
if test -z ${choice}
if test -z "${choice}"
then
exit
fi
# check if choice exists
if test ${COMMANDS[$choice]+isset}
if test "${COMMANDS[$choice]+isset}"
then
# Execute the choice
${COMMANDS[$choice]}

View File

@ -2,47 +2,40 @@
# ABOUTME: Waybar-Modul das den CPU-Governor als JSON ausgibt.
# ABOUTME: Wird von der Waybar custom/cpugov Config referenziert.
while :
do
CPU_GOV=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)
CPU_GOV=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)
case $CPU_GOV in
performance)
CPU_GOV_SHORT=󰓅
;;
balanced)
CPU_GOV_SHORT=󰾅
;;
powersave)
CPU_GOV_SHORT=󰌪
;;
userspace)
CPU_GOV_SHORT=uspace
;;
ondemand)
CPU_GOV_SHORT=ondmnd
;;
conservative)
CPU_GOV_SHORT=cons
;;
schedutil)
CPU_GOV_SHORT=sutil
;;
*)
CPU_GOV_SHORT="?"
;;
esac
case $CPU_GOV in
performance)
CPU_GOV_SHORT=󰓅
;;
balanced)
CPU_GOV_SHORT=󰾅
;;
powersave)
CPU_GOV_SHORT=󰌪
;;
userspace)
CPU_GOV_SHORT=uspace
;;
ondemand)
CPU_GOV_SHORT=ondmnd
;;
conservative)
CPU_GOV_SHORT=cons
;;
schedutil)
CPU_GOV_SHORT=sutil
;;
*)
CPU_GOV_SHORT="?"
;;
esac
CPU_GOV_FULL="${CPU_GOV^}"
CPU_GOV_FULL="${CPU_GOV^}"
s="text|alt|tooltip|class
$CPU_GOV_SHORT|$CPU_GOV_FULL|CPU Mode: $CPU_GOV_FULL|cpugov"
jq --unbuffered --compact-output -Rn '
( input | split("|") ) as $keys |
( inputs | split("|") ) as $vals |
[[$keys, $vals] | transpose[] | {key:.[0],value:.[1]}] | from_entries
' <<<"$s"
sleep 5
done
jq --compact-output -n \
--arg text "$CPU_GOV_SHORT" \
--arg alt "$CPU_GOV_FULL" \
--arg tooltip "CPU Mode: $CPU_GOV_FULL" \
--arg class "cpugov" \
'{text: $text, alt: $alt, tooltip: $tooltip, class: $class}'

View File

@ -321,7 +321,7 @@
"custom/cpugov": {
"exec": "moonarch-waybar-cpugov",
"return-type": "json",
"restart-interval": 10,
"interval": 5,
"on-click": "moonarch-cpugov"
},
"custom/gpu-usage": {