diff --git a/defaults/bin/moonarch-cpugov b/defaults/bin/moonarch-cpugov index b805584..7d6c702 100755 --- a/defaults/bin/moonarch-cpugov +++ b/defaults/bin/moonarch-cpugov @@ -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]} diff --git a/defaults/bin/moonarch-waybar-cpugov b/defaults/bin/moonarch-waybar-cpugov index 1b04adf..8903c20 100755 --- a/defaults/bin/moonarch-waybar-cpugov +++ b/defaults/bin/moonarch-waybar-cpugov @@ -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}' diff --git a/defaults/xdg/waybar/config b/defaults/xdg/waybar/config index 2137f97..c2c947b 100644 --- a/defaults/xdg/waybar/config +++ b/defaults/xdg/waybar/config @@ -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": {