{ config, inputs, pkgs, username, project, ... }: { #To show logs of services run: #journalctl --user-unit={service-name} --user # The Niri Session Cleanup Service # This service starts when the graphical session starts, and when it stops, # it forcibly stops the graphical-session.target to ensure a clean state for the next login. systemd.user.services.niri-session-manager = { description = "Niri Session Management"; wantedBy = ["graphical-session.target"]; partOf = ["graphical-session.target"]; # Only run this cleanup logic for Niri unitConfig.ConditionEnvironment = "XDG_CURRENT_DESKTOP=niri"; serviceConfig = { Type = "simple"; # A dummy command that stays alive. 'sleep infinity' is low resource. ExecStart = "${pkgs.coreutils}/bin/sleep infinity"; # IMPORTANT: When this service stops (which happens when niri kills its children), # it brings down the whole target. ExecStopPost = "${pkgs.systemd}/bin/systemctl --user stop graphical-session.target"; }; }; }