feat: nb make swayidle to a toggle

This commit is contained in:
Dominik Polakovics Polakovics 2026-04-09 21:27:18 +02:00
parent 2d2b15d1bc
commit 431ab4e49c
2 changed files with 38 additions and 8 deletions

View file

@ -72,6 +72,40 @@ let
fi
'';
toggle-swayidle = pkgs.writeShellScriptBin "toggle-swayidle" ''
if pgrep -x swayidle >/dev/null; then
pkill -x swayidle
else
swayidle \
before-sleep 'loginctl lock-session $XDG_SESSION_ID' \
lock 'swaylock -c 252525 -s center -i ~/.wallpaper.png' \
timeout 120 'light -O && light -S 10' \
resume 'light -I' \
timeout 180 'swaylock -c 252525 -s center -i ~/.wallpaper.png' \
timeout 600 'systemctl suspend' &
disown
fi
'';
session-menu = pkgs.writeShellScriptBin "session-menu" ''
if pgrep -x swayidle >/dev/null; then
suspend_label="Auto Suspend Off"
else
suspend_label="Auto Suspend On"
fi
swaynag \
--background f1fa8c --border ffb86c --border-bottom-size 0 \
--button-background ffb86c --button-text 282a36 \
-t warning -f "pango:Hack 9" \
-m "Do you really want to exit?" \
-B " $suspend_label " "pkill swaynag; toggle-swayidle" \
-B " Exit " "swaymsg exit" \
-B " Lock " "pkill swaynag && swaylock -c 252525 -s center -i ~/.wallpaper.png" \
-B " Reboot " "pkill swaynag && reboot" \
-B " Shutdown " "pkill swaynag && shutdown -h now" \
-B " Suspend " "pkill swaynag && systemctl suspend"
'';
sway-conf = builtins.readFile ./sway.conf + ''
exec swaybg -m center -c 252525 -i ~/.wallpaper.png
@ -88,6 +122,8 @@ in {
wayland
wofi
battery-alert-swaynag
toggle-swayidle
session-menu
];
programs.sway = {