nix machine / user configurations
1{ pkgs, ... }: 2{ 3 services.swayidle = 4 let 5 # Lock command 6 lock = "${pkgs.swaylock}/bin/swaylock --daemonize"; 7 display = status: "swaymsg 'output * power ${status}'"; 8 in 9 { 10 enable = true; 11 timeouts = [ 12 { 13 timeout = 60; 14 command = display "off"; 15 resumeCommand = display "on"; 16 } 17 { 18 timeout = 60 * 5; 19 command = lock; 20 } 21 { 22 timeout = 60 * 10; 23 command = "${pkgs.systemd}/bin/systemctl suspend"; 24 } 25 ]; 26 events = [ 27 { 28 event = "before-sleep"; 29 command = (display "off") + "; " + lock; 30 } 31 { 32 event = "after-resume"; 33 command = display "on"; 34 } 35 { 36 event = "lock"; 37 command = (display "off") + "; " + lock; 38 } 39 { 40 event = "unlock"; 41 command = display "on"; 42 } 43 ]; 44 }; 45}