summaryrefslogtreecommitdiff
path: root/dot-config/rofi/scripts/powermenu.sh
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2024-06-03 19:56:39 +0800
committerlittleblack111 <littleblack11111@gmail.com>2024-06-03 19:56:39 +0800
commitca968c4e5040f1ff4b5b5e12d9312360d807dcc1 (patch)
tree9900920e8f566794560c1519678e344351d2803b /dot-config/rofi/scripts/powermenu.sh
parent5f3deaff0bf006a1a353e57b82ad48c0e8f143bc (diff)
added submodules, change . -> dot (see man stow --dotfiles)
Diffstat (limited to 'dot-config/rofi/scripts/powermenu.sh')
-rwxr-xr-xdot-config/rofi/scripts/powermenu.sh98
1 files changed, 98 insertions, 0 deletions
diff --git a/dot-config/rofi/scripts/powermenu.sh b/dot-config/rofi/scripts/powermenu.sh
new file mode 100755
index 00000000..ac311732
--- /dev/null
+++ b/dot-config/rofi/scripts/powermenu.sh
@@ -0,0 +1,98 @@
+#!/usr/bin/env bash
+
+## Author : Aditya Shakya
+## Mail : adi1090x@gmail.com
+## Github : @adi1090x
+## Twitter : @adi1090x
+
+dir="$HOME/.config/rofi/styles"
+rofi_command="rofi -theme $dir/five.rasi"
+
+uptime=$(uptime -p | sed -e 's/up //g')
+
+# Options
+shutdown=""
+reboot=""
+lock=""
+suspend=""
+logout=""
+
+# Confirmation
+confirm_exit() {
+ rofi -dmenu\
+ -i\
+ -no-fixed-num-lines\
+ -p "Are You Sure? : "\
+ -theme $dir/confirm.rasi
+}
+
+# Message
+msg() {
+ rofi -theme "$dir/message.rasi" -e "Available Options - yes / y / no / n"
+}
+
+# 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=$(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
+ loginctl suspend
+ 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
+ if [[ "$DESKTOP_SESSION" == "/usr/share/xsessions/voidwm" ]]; then
+ pkill dwm
+ elif [[ "$DESKTOP_SESSION" == "bspwm" ]]; then
+ bspc quit
+ elif [[ "$DESKTOP_SESSION" == "/usr/share/xsessions/i3" ]]; then
+ i3-msg exit
+ elif [[ "$DESKTOP_SESSION" == "/usr/local/bin/dwm" ]]; then
+ pkill dwm
+ elif [[ "$DESKTOP_SESSION" == "awesome" ]]; then
+ pkill awesome
+ else
+ pkill Hyprland
+ fi
+ elif [[ $ans == "no" || $ans == "NO" || $ans == "n" || $ans == "N" ]]; then
+ exit 0
+ else
+ msg
+ fi
+ ;;
+esac