home/phone: enable swayidle

This commit is contained in:
chayleaf 2024-08-23 11:42:07 +07:00
parent cc4ae20674
commit 45191559c7
Signed by: chayleaf
GPG key ID: 78171AD46227E68E

View file

@ -52,9 +52,15 @@ dpms-on = pkgs.writeShellScript "sway-dpms-on" ''
lock-script = pkgs.writeShellScript "lock-start" '' lock-script = pkgs.writeShellScript "lock-start" ''
${swaylock-start} ${swaylock-start}
${lib.optionalString config.phone.enable ${lib.optionalString config.phone.enable
# suspend if nothing is playing # suspend if nothing is playing and no ssh sessions are active
'' ''
${pkgs.playerctl}/bin/playerctl -a status | ${pkgs.gnugrep}/bin/grep Playing >/dev/null || /run/current-system/sw/bin/systemctl suspend if ${pkgs.playerctl}/bin/playerctl -a status | ${pkgs.gnugrep}/bin/grep Playing >/dev/null; then
exit
fi
if ${pkgs.coreutils}/bin/who -u | ${pkgs.gnugrep}/bin/grep "pts.*(" >/dev/null; then
exit
fi
/run/current-system/sw/bin/systemctl suspend
''} ''}
''; '';
barConfig = { barConfig = {
@ -443,7 +449,7 @@ in
''; '';
}; };
services.swayidle = { services.swayidle = {
enable = config.wayland.windowManager.sway.enable && !config.phone.enable; enable = config.wayland.windowManager.sway.enable;
events = [ events = [
{ event = "before-sleep"; command = toString swaylock-start; } { event = "before-sleep"; command = toString swaylock-start; }
# after-resume, lock, unlock # after-resume, lock, unlock