100 lines
2.6 KiB
Bash
Executable File
100 lines
2.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
## Author : Aditya Shakya
|
|
## Mail : adi1090x@gmail.com
|
|
## Github : @adi1090x
|
|
## Twitter : @adi1090x
|
|
|
|
style="$($HOME/.config/rofi/applets/menu/style.sh)"
|
|
|
|
dir="$HOME/.config/rofi/applets/menu/configs/$style"
|
|
rofi_command="rofi -theme $dir/powermenu.rasi"
|
|
|
|
uptime=$(uptime -p | sed -e 's/up //g')
|
|
# cpu=$(sh ~/.config/rofi/bin/usedcpu)
|
|
# memory=$(sh ~/.config/rofi/bin/usedram)
|
|
|
|
# Options
|
|
lock=""
|
|
shutdown=""
|
|
reboot=""
|
|
suspend=""
|
|
logout=""
|
|
windows="者"
|
|
|
|
# Confirmation
|
|
confirm_exit() {
|
|
rofi -dmenu\
|
|
-i\
|
|
-no-fixed-num-lines\
|
|
-p "Are You Sure? : "\
|
|
-theme $HOME/.config/rofi/applets/styles/confirm.rasi
|
|
}
|
|
|
|
# Message
|
|
msg() {
|
|
rofi -theme "$HOME/.config/rofi/applets/styles/message.rasi" -e "Available Options - yes / y / no / n"
|
|
}
|
|
|
|
# Variable passed to rofi
|
|
# options="$logout\n$suspend\n$lock\n$shutdown\n$reboot\n$windows"
|
|
# options="$logout\n$suspend\n$shutdown\n$reboot"
|
|
options="$logout\n$reboot\n$suspend\n$shutdown"
|
|
|
|
# chosen="$(echo -e "$options" | $rofi_command -p "祥 $uptime | $cpu | $memory " -dmenu -selected-row 2)"
|
|
chosen="$(echo -e "$options" | $rofi_command -p "祥 $uptime " -dmenu -selected-row 2)"
|
|
case $chosen in
|
|
$shutdown)
|
|
# ans=$(confirm_exit &)
|
|
# if [[ $ans == "yes" || $ans == "YES" || $ans == "y" || $ans == "Y" ]]; then
|
|
loginctl poweroff
|
|
# elif [[ $ans == "no" || $ans == "NO" || $ans == "n" || $ans == "N" ]]; then
|
|
# exit 0
|
|
# else
|
|
# msg
|
|
# fi
|
|
;;
|
|
$reboot)
|
|
# ans=$(confirm_exit &)
|
|
# if [[ $ans == "yes" || $ans == "YES" || $ans == "y" || $ans == "Y" ]]; then
|
|
loginctl reboot
|
|
# elif [[ $ans == "no" || $ans == "NO" || $ans == "n" || $ans == "N" ]]; then
|
|
# exit 0
|
|
# else
|
|
# msg
|
|
# fi
|
|
;;
|
|
$lock)
|
|
# if [[ -f /usr/bin/i3lock ]]; then
|
|
# i3lock
|
|
# elif [[ -f /usr/bin/betterlockscreen ]]; then
|
|
# betterlockscreen -l
|
|
# fi
|
|
;;
|
|
$suspend)
|
|
# ans=$(confirm_exit &)
|
|
# if [[ $ans == "yes" || $ans == "YES" || $ans == "y" || $ans == "Y" ]]; then
|
|
# mpc -q pause
|
|
# amixer set Master mute
|
|
loginctl hybrid-sleep
|
|
# elif [[ $ans == "no" || $ans == "NO" || $ans == "n" || $ans == "N" ]]; then
|
|
# exit 0
|
|
# else
|
|
# msg
|
|
# fi
|
|
;;
|
|
$logout)
|
|
# ans=$(confirm_exit &)
|
|
# if [[ $ans == "yes" || $ans == "YES" || $ans == "y" || $ans == "Y" ]]; then
|
|
# i3-msg exit
|
|
# elif [[ $ans == "no" || $ans == "NO" || $ans == "n" || $ans == "N" ]]; then
|
|
# exit 0
|
|
# else
|
|
# msg
|
|
# fi
|
|
;;
|
|
# $windows)
|
|
# # alacritty -e "/home/tobias/.scripts/windows"
|
|
# ;;
|
|
esac
|