summaryrefslogtreecommitdiff
path: root/home/wayland/modules/sway/swayidle.nix
blob: 1aa16c5789eabe3af09476f1a309b71d6d40b75c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
{ config, lib, pkgs, ... }: let
  swaylock = lib.getExe config.programs.swaylock.package;
  brightnessctl = lib.getExe pkgs.brightnessctl;
  swaymsg = "${pkgs.sway}/bin/swaymsg";
in {
  services.swayidle = {
    enable = true;
    systemdTarget = "sway-session.target";

    timeouts = [
      {
	timeout = 250;
	command =
	  "${brightnessctl} --save; "
	  + "${brightnessctl} set 10%-";
	resumeCommand = "${brightnessctl} --restore";
      }

      {
	timeout = 300;
	command = swaylock;
      }

      {
	timeout = 600;
	command =
	  "${swaymsg} --type command 'output * dpms off'; "
	  + "${brightnessctl} -c leds -d platform::kbd_backlight --save; "
	  + "${brightnessctl} -c leds -d platform::kbd_backlight set 0";
	resumeCommand =
	  "${brightnessctl} -c leds -d platform::kbd_backlight --restore; "
	  + "${swaymsg} --type command 'output * dpms on'";
      }
    ];
  };
}