Replace infinite loop with single execution (waybar handles polling via interval), fix unquoted variables, simplify jq invocation.
42 lines
829 B
Bash
Executable File
42 lines
829 B
Bash
Executable File
#!/usr/bin/bash
|
|
# ABOUTME: Waybar-Modul das den CPU-Governor als JSON ausgibt.
|
|
# ABOUTME: Wird von der Waybar custom/cpugov Config referenziert.
|
|
|
|
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
|
|
|
|
CPU_GOV_FULL="${CPU_GOV^}"
|
|
|
|
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}'
|