56 lines
1.8 KiB
Nix
56 lines
1.8 KiB
Nix
{
|
|
pkgs,
|
|
config,
|
|
lib,
|
|
...
|
|
}:
|
|
let
|
|
cfg = config.xyno.desktop.swayidle;
|
|
in
|
|
{
|
|
options.xyno.desktop.swayidle.enable = lib.mkEnableOption "enable swayidle and swaylock and stuff";
|
|
options.xyno.desktop.swayidle.wantedBy = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = "niri.service";
|
|
};
|
|
options.xyno.desktop.swayidle.package = lib.mkOption {
|
|
type = lib.types.package;
|
|
default = pkgs.swayidle;
|
|
};
|
|
options.xyno.desktop.swayidle.swaylockPackage = lib.mkOption {
|
|
type = lib.types.package;
|
|
default = pkgs.swaylock-effects;
|
|
};
|
|
options.xyno.desktop.swayidle.swaylockArgs = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = "-f --daemonize -F --clock --timestr %T --datestr %F --indicator -i /home/${config.xyno.system.user.name}/Pictures/background.jpg";
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
environment.systemPackages = with cfg; [
|
|
package
|
|
swaylockPackage
|
|
(pkgs.writeShellApplication {
|
|
name = "lock";
|
|
runtimeInputs = [ cfg.swaylockPackage ];
|
|
text = ''
|
|
exec swaylock ${cfg.swaylockArgs}
|
|
'';
|
|
})
|
|
];
|
|
systemd.user.services.swayidle = {
|
|
unitConfig.PartOf = "graphical-session.target";
|
|
unitConfig.After = "graphical-session.target";
|
|
unitConfig.ConditionEnvironment = "WAYLAND_DISPLAY";
|
|
unitConfig.Requisite = "graphical-session.target";
|
|
serviceConfig.Restart = "always";
|
|
# environment.PATH = "${lib.makeBinPath [ pkgs.bash ]}";
|
|
wantedBy = [ cfg.wantedBy ];
|
|
script = ''
|
|
exec ${cfg.package}/bin/swayidle -w timeout 310 'niri msg action power-off-monitors' \
|
|
timeout 300 '${cfg.swaylockPackage}/bin/swaylock ${cfg.swaylockArgs}' \
|
|
before-sleep '${cfg.swaylockPackage}/bin/swaylock ${cfg.swaylockArgs}'
|
|
'';
|
|
};
|
|
};
|
|
}
|