nixcfg/homeManagerModules/services/swayidle/default.nix
Aly Raffauf 3663469066
sway,hyprland: convert startup apps to systemd (#73)
* home: switch hyprland and sway to new swayidle systemd service

* home: add swayosd service

* home: move swayidle and swayosd to services

* home/services: add swayidle and swayosd services

* hyprland,sway: don't start swayosd

* user playerctld as systemd service

* home: run gammastep as service for redShift"

* cleanup

* home: set swayosd and swayidle as wanted by hyprland and sway

* nix fmt

* home/services/swayidle: fixed resume command

* home/swayidle: fix command syntax

* home: better systemd defaults for swayidle and swayosd

* home: convert mako to systemd service

* home: make wayland-ipewire-idle-inhibit a systemd service

* home/waybar: use as systemd service

* home: move waybar to services

* home/desktop: convert randomWallpaper to systemd service

* migrate home options
2024-08-02 17:58:08 -04:00

74 lines
2 KiB
Nix

{
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.services.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";
resumeCommand = "${lib.getExe pkgs.brightnessctl} -r";
}
{
timeout = 600;
command = "${pkgs.swaylock}/bin/swaylock";
}
]
++ lib.optional cfg.desktop.autoSuspend {
timeout = 600;
command = "${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";
resumeCommand = "${hyprctl} dispatch dpms on";
}
++ lib.optional (!cfg.desktop.autoSuspend && cfg.desktop.sway.enable)
{
timeout = 630;
command = "${swaymsg} \"output * dpms off\"";
resumeCommand = "${swaymsg} \"output * dpms on\"";
};
};
systemd.user.services.swayidle = {
Install.WantedBy = lib.mkForce ["hyprland-session.target" "sway-session.target"];
Service = {
Restart = lib.mkForce "on-failure";
RestartSec = 5;
};
};
};
}