dots/polybar/scripts/powermenu.sh
2022-04-19 10:34:46 +01:00

37 lines
708 B
Bash
Executable file

#!/usr/bin/env bash
## Author : Aditya Shakya
## Mail : adi1090x@gmail.com
## Github : @adi1090x
## Twitter : @adi1090x
uptime=$(uptime -p | sed -e 's/up //g')
rofi_command="rofi -theme ~/.config/rofi/power.rasi"
# Options
shutdown="Shutdown"
reboot="Restart"
suspend="Sleep"
settings="Settings"
# Variable passed to rofi
options="$reboot\n$shutdown\n$settings"
chosen="$(echo -e "$options" | $rofi_command -p "Uptime: $uptime" -dmenu -selected-row 0)"
case $chosen in
$shutdown)
systemctl poweroff
;;
$reboot)
systemctl reboot
;;
$suspend)
mpc -q pause
amixer set Master mute
systemctl suspend
;;
$settings)
gnome-control-center
;;
esac