#!/bin/sh

mode=$(echo -e "\n400\n2000\n󰾅\n700\n3000\n󰈸\n1000\n4200" | rofi \
    -modes drun,run,calc \
    -dmenu -p "Power menu" \
    -theme "$HOME/.config/rofi/styles/style-powermodemenu.rasi" \
    -markup-rows \
    -drun-use-desktop-cache \
)

cpupowerset="sudo cpupower frequency-set --max"
powerprofileset="powerprofilesctl set"

case "$mode" in
    "")
        $powerprofileset power-saver
        ;;
    "󰾅")
        $powerprofileset balanced
        ;;
    "󰈸")
        $powerprofileset performance
        ;;
    "400")
        $cpupowerset "400MHz"
        ;;
    "700")
        $cpupowerset "700MHz"
        ;;
    "1000")
        $cpupowerset "1000MHz"
        ;;
    "2000")
        $cpupowerset "2000MHz"
        ;;
    "3000")
        $cpupowerset "3000MHz"
        ;;
    "4200")
        $cpupowerset "4200MHz"
        ;;
    *)
        exit 0
        ;;
esac
