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:
parent
f5d94e8bc0
commit
ef78e32394
@ -49,19 +49,17 @@ value="$(start)"
|
|||||||
# Split input.
|
# Split input.
|
||||||
# grab upto first space.
|
# grab upto first space.
|
||||||
choice=${value%%\ *}
|
choice=${value%%\ *}
|
||||||
# graph remainder, minus space.
|
|
||||||
input=${value:$((${#choice}+1))}
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# Cancelled? bail out
|
# Cancelled? bail out
|
||||||
##
|
##
|
||||||
if test -z ${choice}
|
if test -z "${choice}"
|
||||||
then
|
then
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# check if choice exists
|
# check if choice exists
|
||||||
if test ${COMMANDS[$choice]+isset}
|
if test "${COMMANDS[$choice]+isset}"
|
||||||
then
|
then
|
||||||
# Execute the choice
|
# Execute the choice
|
||||||
${COMMANDS[$choice]}
|
${COMMANDS[$choice]}
|
||||||
|
|||||||
@ -2,47 +2,40 @@
|
|||||||
# ABOUTME: Waybar-Modul das den CPU-Governor als JSON ausgibt.
|
# ABOUTME: Waybar-Modul das den CPU-Governor als JSON ausgibt.
|
||||||
# ABOUTME: Wird von der Waybar custom/cpugov Config referenziert.
|
# ABOUTME: Wird von der Waybar custom/cpugov Config referenziert.
|
||||||
|
|
||||||
while :
|
CPU_GOV=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)
|
||||||
do
|
|
||||||
CPU_GOV=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)
|
|
||||||
|
|
||||||
case $CPU_GOV in
|
case $CPU_GOV in
|
||||||
performance)
|
performance)
|
||||||
CPU_GOV_SHORT=
|
CPU_GOV_SHORT=
|
||||||
;;
|
;;
|
||||||
balanced)
|
balanced)
|
||||||
CPU_GOV_SHORT=
|
CPU_GOV_SHORT=
|
||||||
;;
|
;;
|
||||||
powersave)
|
powersave)
|
||||||
CPU_GOV_SHORT=
|
CPU_GOV_SHORT=
|
||||||
;;
|
;;
|
||||||
userspace)
|
userspace)
|
||||||
CPU_GOV_SHORT=uspace
|
CPU_GOV_SHORT=uspace
|
||||||
;;
|
;;
|
||||||
ondemand)
|
ondemand)
|
||||||
CPU_GOV_SHORT=ondmnd
|
CPU_GOV_SHORT=ondmnd
|
||||||
;;
|
;;
|
||||||
conservative)
|
conservative)
|
||||||
CPU_GOV_SHORT=cons
|
CPU_GOV_SHORT=cons
|
||||||
;;
|
;;
|
||||||
schedutil)
|
schedutil)
|
||||||
CPU_GOV_SHORT=sutil
|
CPU_GOV_SHORT=sutil
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
CPU_GOV_SHORT="?"
|
CPU_GOV_SHORT="?"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
CPU_GOV_FULL="${CPU_GOV^}"
|
CPU_GOV_FULL="${CPU_GOV^}"
|
||||||
|
|
||||||
s="text|alt|tooltip|class
|
jq --compact-output -n \
|
||||||
$CPU_GOV_SHORT|$CPU_GOV_FULL|CPU Mode: $CPU_GOV_FULL|cpugov"
|
--arg text "$CPU_GOV_SHORT" \
|
||||||
|
--arg alt "$CPU_GOV_FULL" \
|
||||||
jq --unbuffered --compact-output -Rn '
|
--arg tooltip "CPU Mode: $CPU_GOV_FULL" \
|
||||||
( input | split("|") ) as $keys |
|
--arg class "cpugov" \
|
||||||
( inputs | split("|") ) as $vals |
|
'{text: $text, alt: $alt, tooltip: $tooltip, class: $class}'
|
||||||
[[$keys, $vals] | transpose[] | {key:.[0],value:.[1]}] | from_entries
|
|
||||||
' <<<"$s"
|
|
||||||
|
|
||||||
sleep 5
|
|
||||||
done
|
|
||||||
|
|||||||
@ -321,7 +321,7 @@
|
|||||||
"custom/cpugov": {
|
"custom/cpugov": {
|
||||||
"exec": "moonarch-waybar-cpugov",
|
"exec": "moonarch-waybar-cpugov",
|
||||||
"return-type": "json",
|
"return-type": "json",
|
||||||
"restart-interval": 10,
|
"interval": 5,
|
||||||
"on-click": "moonarch-cpugov"
|
"on-click": "moonarch-cpugov"
|
||||||
},
|
},
|
||||||
"custom/gpu-usage": {
|
"custom/gpu-usage": {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user