80 lines
2.3 KiB
Bash
Executable file
80 lines
2.3 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
## Author : Aditya Shakya (adi1090x)
|
|
## Mail : adi1090x@gmail.com
|
|
## Github : @adi1090x
|
|
## Reddit : @adi1090x
|
|
|
|
# Available Styles
|
|
# >> Styles Below Only Works With "rofi-git(AUR)", Current Version: 1.5.4-76-gca067234
|
|
# full full_circle full_rounded full_alt
|
|
# card card_circle column column_circle
|
|
# row row_alt row_circle
|
|
# single single_circle single_full single_full_circle single_rounded single_text
|
|
|
|
style="card_circle"
|
|
|
|
rofi_command="rofi -theme power/$style.rasi"
|
|
|
|
uptime=$(uptime -p | sed -e 's/up //g')
|
|
|
|
# Options
|
|
shutdown=""
|
|
reboot=""
|
|
lock=""
|
|
suspend=""
|
|
logout=""
|
|
dir="$HOME/.config/rofi/power"
|
|
|
|
# Variable passed to rofi
|
|
options="$shutdown\n$reboot\n$lock\n$suspend\n$logout"
|
|
|
|
chosen="$(echo -e "$options" | $rofi_command -p "Uptime: $uptime" -dmenu -selected-row 2)"
|
|
case $chosen in
|
|
$shutdown)
|
|
ans=$($dir/confirm.sh)
|
|
if [[ $ans == "yes" ]] || [[ $ans == "YES" ]] || [[ $ans == "y" ]]; then
|
|
systemctl poweroff
|
|
elif [[ $ans == "no" ]] || [[ $ans == "NO" ]] || [[ $ans == "n" ]]; then
|
|
exit
|
|
else
|
|
rofi -theme "$dir/message.rasi" -e "Available Options - yes / y / no / n"
|
|
fi
|
|
;;
|
|
$reboot)
|
|
ans=$($dir/confirm.sh)
|
|
if [[ $ans == "yes" ]] || [[ $ans == "YES" ]] || [[ $ans == "y" ]]; then
|
|
systemctl reboot
|
|
elif [[ $ans == "no" ]] || [[ $ans == "NO" ]] || [[ $ans == "n" ]]; then
|
|
exit
|
|
else
|
|
rofi -theme "$dir/message.rasi" -e "Available Options - yes / y / no / n"
|
|
fi
|
|
;;
|
|
$lock)
|
|
i3lock
|
|
;;
|
|
$suspend)
|
|
ans=$($dir/confirm.sh)
|
|
if [[ $ans == "yes" ]] || [[ $ans == "YES" ]] || [[ $ans == "y" ]]; then
|
|
mpc -q pause
|
|
amixer set Master mute
|
|
systemctl suspend
|
|
elif [[ $ans == "no" ]] || [[ $ans == "NO" ]] || [[ $ans == "n" ]]; then
|
|
exit
|
|
else
|
|
rofi -theme "$dir/message.rasi" -e "Available Options - yes / y / no / n"
|
|
fi
|
|
;;
|
|
$logout)
|
|
ans=$($dir/confirm.sh)
|
|
if [[ $ans == "yes" ]] || [[ $ans == "YES" ]] || [[ $ans == "y" ]]; then
|
|
openbox --exit
|
|
elif [[ $ans == "no" ]] || [[ $ans == "NO" ]] || [[ $ans == "n" ]]; then
|
|
exit
|
|
else
|
|
rofi -theme "$dir/message.rasi" -e "Available Options - yes / y / no / n"
|
|
fi
|
|
;;
|
|
esac
|