add suspend-and-hibernate and hybrid sleep optios

This commit is contained in:
Alpha 2024-07-18 15:50:00 +05:30
parent 7c6953721b
commit 79f9f9aa59
No known key found for this signature in database
GPG Key ID: E61724645DD4AC78

View File

@ -14,14 +14,17 @@ dir="$HOME/.config/rofi/powermenu/type-1"
theme='style-1' theme='style-1'
# CMDs # CMDs
uptime="`uptime -p | sed -e 's/up //g'`" uptime="$(uptime -p | sed -e 's/up //g')"
host=`hostname` host=$(hostname)
# Options # Options
shutdown=' Shutdown' shutdown=' Shutdown'
reboot=' Reboot' reboot=' Reboot'
lock=' Lock' lock=' Lock'
suspend=' Suspend' suspend=' Suspend'
hibernate='󰒲 Hibernate'
hybrid='󰜎 Hybrid Sleep'
susbernate=' Suspend then Hibernate'
logout=' Logout' logout=' Logout'
yes=' Yes' yes=' Yes'
no=' No' no=' No'
@ -54,7 +57,7 @@ confirm_exit() {
# Pass variables to rofi dmenu # Pass variables to rofi dmenu
run_rofi() { run_rofi() {
echo -e "$lock\n$suspend\n$logout\n$reboot\n$shutdown" | rofi_cmd echo -e "$lock\n$suspend\n$hibernate\n$reboot\n$shutdown\n$hybrid\n$susbernate\n$logout" | rofi_cmd
} }
# Execute Command # Execute Command
@ -69,7 +72,13 @@ run_cmd() {
mpc -q pause mpc -q pause
amixer set Master mute amixer set Master mute
systemctl suspend systemctl suspend
elif [[ $1 == '--logout' ]]; then elif [[ $1 == '--hibernate' ]]; then
systemctl hibernate
elif [[ $1 == '--hybrid' ]]; then
systemctl hybrid-sleep
elif [[ $1 == '--susbernate' ]]; then
systemctl suspend-then-hibernate
elif [[ $1 == '--logout ' ]]; then
if [[ "$DESKTOP_SESSION" == 'openbox' ]]; then if [[ "$DESKTOP_SESSION" == 'openbox' ]]; then
openbox --exit openbox --exit
elif [[ "$DESKTOP_SESSION" == 'bspwm' ]]; then elif [[ "$DESKTOP_SESSION" == 'bspwm' ]]; then
@ -90,13 +99,13 @@ run_cmd() {
# Actions # Actions
chosen="$(run_rofi)" chosen="$(run_rofi)"
case ${chosen} in case ${chosen} in
$shutdown) $shutdown)
run_cmd --shutdown run_cmd --shutdown
;; ;;
$reboot) $reboot)
run_cmd --reboot run_cmd --reboot
;; ;;
$lock) $lock)
if [[ -x '/usr/bin/betterlockscreen' ]]; then if [[ -x '/usr/bin/betterlockscreen' ]]; then
betterlockscreen -l betterlockscreen -l
elif [[ -x '/usr/bin/i3lock' ]]; then elif [[ -x '/usr/bin/i3lock' ]]; then
@ -105,10 +114,19 @@ case ${chosen} in
hyprlock hyprlock
fi fi
;; ;;
$suspend) $suspend)
run_cmd --suspend run_cmd --suspend
;; ;;
$logout) $hibernate)
run_cmd --hibernate
;;
$hybrid)
run_cmd --hybrid
;;
$susbernate)
run_cmd --susbernate
;;
$logout)
run_cmd --logout run_cmd --logout
;; ;;
esac esac