#!/usr/bin/env bash
# 
# SCRIPT NAME:
# power
#
# AUTHOR:
# Severin Kaderli <severin@kaderli.dev>
#
# DESCRIPTION:
# Displays a power menu using rofi.
#
# USAGE:
# ./power

# The rofi prompt
PROMPT="Power Options"

# Actions for the menu
ACTIONS=(
    "1: Reboot"
    "2: Shutdown"
    "3: Suspend"
    "4: Lock Screen"
    "5: Performance Mode"
    "6: Powersave Mode"
)

SELECTION=$(printf '%s\n' "${ACTIONS[@]}" | rofi -dmenu -p "${PROMPT}" | cut -d ":" -f1)
case "${SELECTION}" in
    "1")
        systemctl reboot
        ;;
    "2")
        systemctl poweroff
        ;;
    "3")
        systemctl suspend
        ;;
    "4")
        screenlock
        ;;
    "5")
        gksu "cpupower frequency-set -g performance"
        ;;
    "6")
        gksu "cpupower frequency-set -g powersave"
esac
