moonarch/defaults/bin/moonarch-cpugov
nevaforget 5d2ce00455 Initial commit: Moonarch reproduzierbares Arch-Linux-Setup
Niri-basierter Wayland-Desktop mit greetd/regreet, Catppuccin Mocha
Theming, Rofi-Menus, Waybar und vollstaendiger Post-Install-Automatisierung.

Archinstall-Config klont das Repo automatisch via custom-commands,
danach genuegt ein einzelner Befehl fuer die komplette Einrichtung.
2026-03-23 17:42:26 +01:00

73 lines
1.6 KiB
Bash
Executable File

#!/usr/bin/env bash
# ABOUTME: Rofi-based 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 | rofi -dmenu -p "?=>"
print_menu | sort | rofi -theme /etc/xdg/rofi/cpugov/rofi-cpugov.rasi -show "CPU Modes" -dmenu -mesg "󰓅 CPU Modes" -i -p "rofi-bangs: "
}
# Run it
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}
then
exit
fi
# check if choice exists
if test ${COMMANDS[$choice]+isset}
then
# Execute the choice
${COMMANDS[$choice]}
dunstify --replace 553 -i "/usr/share/icons/zafiro-dark/devices/48/cpu.svg" "CPU Mode" "Set to $choice ${LABELS[$choice]}"
else
echo "Unknown command: ${choice}" | rofi -dmenu -p "error"
fi