nix-configs/modules/desktop/swayidle.nix
2025-03-23 16:15:06 +01:00

48 lines
1.4 KiB
Nix

{
pkgs,
config,
lib,
...
}:
let
cfg = config.xyno.desktop.swayidle;
makoConf = pkgs.writeText "mako.conf" ''
font=Source Sans Pro Nerd Font 11
background-color=#1d2021ff
border-color=#3c3836FF
text-color=#ebdbb2ff
progress-color=over #928374FF
'';
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 = "--fade-in 2 --clock --timestr %T%z --datestr %F";
};
config = lib.mkIf cfg.enable {
environment.systemPackages = with cfg; [ package swaylockPackage ];
systemd.user.services.mako = {
unitConfig.PartOf = "graphical-session.target";
unitConfig.After = "graphical-session.target";
unitConfig.Requisite = "graphical-session.target";
serviceConfig.Restart = "on-failure";
wantedBy = [ cfg.wantedBy ];
script = "${cfg.package}/bin/mako -c ${makoConf}";
restartTrigers = makoConf;
};
};
}