From 4bd8222dc3fced02b853acf3bff5090997b03214 Mon Sep 17 00:00:00 2001 From: ElnuDev Date: Sat, 23 Sep 2023 14:34:10 -0700 Subject: [PATCH] i3: Add lock options to power.sh --- modules/i3/power.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/i3/power.sh b/modules/i3/power.sh index 0e1990d..a8d5a30 100755 --- a/modules/i3/power.sh +++ b/modules/i3/power.sh @@ -1,14 +1,16 @@ POWER_OFF=" Power Off" REBOOT=" Reboot" SUSPEND=" Suspend" +LOCK=" Lock" LOG_OUT="󰗽 Log out" -chosen=`printf "%s\n%s\n%s\n%s" "$POWER_OFF" "$REBOOT" "$SUSPEND" "$LOG_OUT" | rofi -dmenu -i -p ""` +chosen=`printf "%s\n%s\n%s\n%s\n%s" "$POWER_OFF" "$REBOOT" "$SUSPEND" "$LOCK" "$LOG_OUT" | rofi -dmenu -i -p ""` case "$chosen" in $POWER_OFF) action="power off" ;; $REBOOT) action="reboot" ;; $SUSPEND) action="suspend" ;; + $LOCK) action="lock" ;; $LOG_OUT) action="log out" ;; *) exit 1 ;; esac @@ -20,7 +22,7 @@ if [[ $sure != $confirm ]]; then exit 1 fi -if [[ $chosen != $SUSPEND ]]; then +if [[ $chosen != $SUSPEND ]] && [[ $chosen != $LOCK ]]; then # based on https://github.com/ardadem/graceful-shutdown TIMEOUT=10 @@ -61,7 +63,8 @@ fi case "$chosen" in $POWER_OFF) poweroff ;; $REBOOT) reboot ;; - $SUSPEND) systemctl suspend ;; + $SUSPEND) dm-tool switch-to-greeter && systemctl suspend ;; + $LOCK) dm-tool lock ;; $LOG_OUT) i3-msg exit ;; *) exit 1 ;; esac