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