#!/bin/bash notify-send --hint int:transient:1 -t 500 "powerprofilesctl" "Please, wait..." CURRENT=$(powerprofilesctl get) if [[ $? -ne 0 ]]; then notify-send --hint int:transient:1 -t 1800 "powerprofilesctl" "Error: could not retrieve status" exit 1 fi case "$CURRENT" in "power-saver") powerprofilesctl set balanced ;; "balanced") powerprofilesctl set performance ;; "performance") powerprofilesctl set power-saver ;; *) echo "Error: '$CURRENT' is not a valid power mode" exit 1 ;; esac if [[ $? -ne 0 ]]; then notify-send --hint int:transient:1 -t 800 "powerprofilesctl" "Error: failed to set power mode" exit 1 else notify-send --hint int:transient:1 -t 800 "powerprofilesctl" "Successfully changed to $(powerprofilesctl get)" fi exit 0