moonarch/defaults/bin/moonarch-cpugov
nevaforget ac2b210a1f
All checks were successful
Update PKGBUILD version / update-pkgver (push) Successful in 3s
fix: audit remediation — security, quality and performance fixes
- CI Dockerfile: verify act_runner SHA256, restrict sudoers to safe
  pacman arguments (S-C1, S-C2)
- cliphist: split into cliphist-text + cliphist-image services with
  Type=simple for proper PID tracking and restart (Q-C3)
- batsaver-toggle: validate sysfs input as numeric, check state file
  write (Q-C2, S-W2)
- udev battery rule: add ACTION=="add" filter to avoid firing on
  every battery event (Q-W3)
- cpugov: replace eval with direct expansion, switch waybar module
  to signal-based updates, send SIGRTMIN+10 after toggle (Q-W1,
  S-W1, P-W4)
- Remove docker group auto-assignment from install scripts (S-I1)
2026-04-08 11:45:56 +02:00

72 lines
1.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# ABOUTME: Walker-dmenu CPU governor switcher using auto-cpufreq.
# ABOUTME: Allows switching between performance, powersave, and reset modes.
declare -A LABELS
declare -A COMMANDS
###
# List of defined 'bangs'
COMMANDS["󰓅"]="pkexec auto-cpufreq --force=performance"
LABELS["󰓅"]="Performance"
COMMANDS["󰌪"]='pkexec auto-cpufreq --force=powersave'
LABELS["󰌪"]="Powersave"
COMMANDS[""]='pkexec auto-cpufreq --force=reset'
LABELS[""]="Reset"
################################################################################
# do not edit below
################################################################################
##
# Generate menu
##
function print_menu()
{
for key in ${!LABELS[@]}
do
# echo "$key ${LABELS}"
echo "$key ${LABELS[$key]}"
# my top version just shows the first field in labels row, not two words side by side
done
}
##
# Show rofi.
##
function start()
{
print_menu | sort | walker -d -p "󰓅 CPU Mode"
}
# Run it
value="$(start)"
# Split input.
# grab upto first space.
choice=${value%%\ *}
##
# Cancelled? bail out
##
if test -z "${choice}"
then
exit
fi
# check if choice exists
if test "${COMMANDS[$choice]+isset}"
then
${COMMANDS[$choice]}
notify-send -h string:x-canonical-private-synchronous:cpugov -i cpu "CPU Mode" "Set to $choice ${LABELS[$choice]}"
# Signal Waybar to refresh the cpugov module (SIGRTMIN+10)
pkill -RTMIN+10 waybar
else
notify-send -u critical "CPU Governor" "Unknown command: ${choice}"
fi