#!/bin/bash CONFIG_DIR="$HOME/.config/hypr/hyprland/configs" CURRENT_CONFIG_FILE="$HOME/.config/hypr/hyprland/active.conf" # List of available configs in order to cycle through CONFIGS=("powersave" "balanced" "performance") # Read current config or set default if [[ -f "$CURRENT_CONFIG_FILE" ]]; then CURRENT_CONFIG=$(grep -oP '^#\s*\K\w+' "$CURRENT_CONFIG_FILE" | head -n1) else CURRENT_CONFIG="${CONFIGS[0]}" fi # Find current config index INDEX=0 for i in "${!CONFIGS[@]}"; do if [[ "${CONFIGS[$i]}" = "$CURRENT_CONFIG" ]]; then INDEX=$i break fi done # Calculate next config index (with wrap-around) NEXT_INDEX=$(( (INDEX + 1) % ${#CONFIGS[@]} )) NEXT_CONFIG="${CONFIGS[$NEXT_INDEX]}" # Update current config file printf "# ${NEXT_CONFIG}\n" > "$CURRENT_CONFIG_FILE" printf "# AUTO-GENERATED FILE\n" >> "$CURRENT_CONFIG_FILE" cat "${CONFIG_DIR}/${NEXT_CONFIG}.conf" >> "$CURRENT_CONFIG_FILE" if [[ "$NEXT_CONFIG" == "powersave" ]]; then sudo auto-cpufreq --force powersave elif [[ "$NEXT_CONFIG" == "performance" ]]; then sudo auto-cpufreq --force performance elif [[ "$NEXT_CONFIG" == "balanced" ]]; then sudo auto-cpufreq --force reset else notify-send -u critical "Unknown config: $NEXT_CONFIG" fi # Reload Hyprland hyprctl reload # Notification notify-send -t 3000 "Hyprland Config" "Switched to ${NEXT_CONFIG} config"