diff --git a/user/sway/swayidle.nix b/user/sway/swayidle.nix index 697a1cc..d21f40c 100644 --- a/user/sway/swayidle.nix +++ b/user/sway/swayidle.nix @@ -2,6 +2,8 @@ let inherit (pkgs.uservars) key accent font theme; inherit (theme) color; + + asScript = filename: text: toString (pkgs.writeShellScript filename text); in { services.swayidle = { @@ -12,10 +14,10 @@ in } { timeout = 1800; - command = '' - mpc status | grep "^[playing]" > /dev/null || ${pkgs.sway}/bin/swaymsg "output * dpms off" + command = asScript "swayidle-suspend-monitors" '' + ${pkgs.mpc_cli}/bin/mpc status | grep "^[playing]" > /dev/null || ${pkgs.sway}/bin/swaymsg "output * dpms off" ''; - resumeCommand = '' + resumeCommand = asScript "swayidle-wakeup-monitors" '' ${pkgs.sway}/bin/swaymsg "output * dpms on" ''; } @@ -27,7 +29,9 @@ in } { event = "after-resume"; - command = ''swaymsg "output * dpms on"''; + command = asScript "after-resume" '' + ${pkgs.sway}/bin/swaymsg "output * dpms on" + ''; } ]; };