56 lines
1.7 KiB
Nix
56 lines
1.7 KiB
Nix
{
|
|
config,
|
|
pkgs,
|
|
username,
|
|
project,
|
|
...
|
|
}: {
|
|
#To show logs of services run:
|
|
#journalctl --user-unit={service-name} --user
|
|
systemd.user.services.niri-waybar = {
|
|
description = "Waybar status bar for Niri";
|
|
|
|
# "wantedBy" replaces the [Install] section
|
|
wantedBy = ["graphical-session.target"];
|
|
|
|
# "partOf" and "after" replace the [Unit] section dependencies
|
|
partOf = ["graphical-session.target"];
|
|
after = ["graphical-session.target"];
|
|
|
|
# [Unit] configuration goes here
|
|
unitConfig = {
|
|
# This checks the environment variable to ensure we are in Niri
|
|
ConditionEnvironment = "XDG_CURRENT_DESKTOP=niri";
|
|
};
|
|
|
|
# [Service] configuration goes here
|
|
serviceConfig = {
|
|
ExecStart = "${pkgs.waybar}/bin/waybar";
|
|
Restart = "on-failure";
|
|
RestartSec = "1s";
|
|
};
|
|
};
|
|
|
|
# 2. 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";
|
|
};
|
|
};
|
|
}
|