mirror of
https://github.com/alyraffauf/nixcfg.git
synced 2024-11-23 09:23:55 -05:00
home/services: add swayidle and swayosd services
This commit is contained in:
parent
011565307f
commit
3bd64a7155
63
homeManagerModules/services/swayidle/default.nix
Normal file
63
homeManagerModules/services/swayidle/default.nix
Normal file
|
@ -0,0 +1,63 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
cfg = config.ar.home;
|
||||
hyprctl = lib.getExe' config.wayland.windowManager.hyprland.package "hyprctl";
|
||||
swaymsg = lib.getExe' config.wayland.windowManager.sway.package "swaymsg";
|
||||
|
||||
in {
|
||||
config = lib.mkIf cfg.apps.swayidle.enable {
|
||||
services.swayidle = {
|
||||
enable = true;
|
||||
|
||||
events = [
|
||||
{
|
||||
event = "before-sleep";
|
||||
command = "${lib.getExe pkgs.playerctl} pause";
|
||||
}
|
||||
{
|
||||
event = "before-sleep";
|
||||
command = "${pkgs.swaylock}/bin/swaylock";
|
||||
}
|
||||
{
|
||||
event = "lock";
|
||||
command = "${pkgs.swaylock}/bin/swaylock";
|
||||
}
|
||||
];
|
||||
|
||||
timeouts =
|
||||
[
|
||||
{
|
||||
timeout = 120;
|
||||
command = "${lib.getExe pkgs.brightnessctl} -s set 10' resume '${lib.getExe pkgs.brightnessctl} -r";
|
||||
}
|
||||
{
|
||||
timeout = 600;
|
||||
command = "${pkgs.swaylock}/bin/swaylock";
|
||||
}
|
||||
]
|
||||
++ lib.optional cfg.desktop.autoSuspend {
|
||||
timeout = 600;
|
||||
command = "sleep 2 && ${lib.getExe' pkgs.systemd "systemctl"} suspend'";
|
||||
}
|
||||
++ lib.optional (!cfg.desktop.autoSuspend)
|
||||
{
|
||||
timeout = 600;
|
||||
command = "${pkgs.swaylock}/bin/swaylock";
|
||||
}
|
||||
++ lib.optional (!cfg.desktop.autoSuspend && cfg.desktop.hyprland.enable)
|
||||
{
|
||||
timeout = 630;
|
||||
command = "${hyprctl} dispatch dpms off' resume '${hyprctl} dispatch dpms on'";
|
||||
}
|
||||
++ lib.optional (!cfg.desktop.autoSuspend && cfg.desktop.sway.enable)
|
||||
{
|
||||
timeout = 630;
|
||||
command = "${swaymsg} \"output * dpms off\"' resume '${swaymsg} \"output * dpms on\"";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
9
homeManagerModules/services/swayosd/default.nix
Normal file
9
homeManagerModules/services/swayosd/default.nix
Normal file
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: {
|
||||
config = lib.mkIf config.ar.home.apps.swayosd.enable {
|
||||
services.swayosd.enable = true;
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue