OPINIONATED OMARCHY
TROUBLESHOOTING CORPUS
790
RECORDS
790
AUDITED
0
UNCHECKED
2388
SOURCES
LIVE
apps-services medium common DISPUTE

Fix a systemd user unit that never starts in the Hyprland session

omarchyarchendeavouroscachyosmanjarohyprlandwaylandsystemdlaptopdesktop
CORRECTED An auditor found the fix wrong or incomplete and rewrote it.
AUDIT NOTE

The fix steps are almost all right and match the current Hyprland wiki (uwsm + libnewt, the uwsm check may-start bash_profile snippet, add-wants graphical-session.target for units with no [Install], the After/PartOf drop-in, systemctl --user revert hyprland-session.target, deleting leftover systemctl calls from hyprland.lua, and preferring enabled units over exec-once). But the central cause claim is stale: the wiki's Systemd startup page now states hyprland-session.target 'previously required manual setup, but is now integrated into Hyprland and handled automatically', and its note says setting HYPRLAND_NO_SD_TARGET 'will avoid this, but also prevent starting hyprland-session.target and graphical-session.target in the first place'. So a bare Hyprland launched from a TTY does reach graphical-session.target on 0.55/0.56, and 'never reaches' was true of the pre-integration era and now sends readers to fix the wrong thing. HYPRLAND_NO_SD_TARGET itself is a real variable, correctly named.

The cause above was not rewritten and may still contain the error described. The fix below is the corrected version.
RISK

A single user is not expected to have two compositors running at once: exiting one Hyprland instance stops graphical-session.target and takes down every session unit bound to it, including in the other session.

Symptom

systemctl --user enable foo.service reports success, but the service is never running: systemctl --user status foo.service says inactive (dead) after every login. systemctl --user status graphical-session.target may show inactive too. Enabling it with --now starts it once, and then it is gone again after a reboot.

Cause

Session-scoped user units are pulled in by graphical-session.target, a passive target that must be activated by something. Since Hyprland integrated systemd target handling, Hyprland itself starts hyprland-session.target and graphical-session.target, even when launched bare from a TTY, unless HYPRLAND_NO_SD_TARGET is set, which suppresses both. So an inactive target now points at that variable, at leftover manual target plumbing from older guides, or at a session started some other way, rather than at 'bare Hyprland cannot reach it'. The other two traps are unchanged and are the usual culprits: a unit with no [Install] section cannot be enabled into anything, and enable without --now only schedules it for the next login.

Fix

Check whether the target is actually reached:


systemctl --user status graphical-session.target
systemctl --user list-dependencies graphical-session.target

If it is inactive, the likely reasons on a current Hyprland are that the target start was suppressed or that leftover manual plumbing is interfering. Hyprland starts hyprland-session.target and graphical-session.target itself now:


systemctl --user show-environment | grep HYPRLAND_NO_SD_TARGET   # must be unset
systemctl --user revert hyprland-session.target                  # drop old manual target files

and delete any systemctl --user start hyprland-session.target / stop graphical-session.target calls from hyprland.lua. Launching through uwsm remains the most robust option and is what Omarchy does (Exec=uwsm start -g -1 -e -D Hyprland hyprland.desktop). From a TTY:


sudo pacman -S --needed uwsm libnewt

# ~/.bash_profile
if uwsm check may-start; then
    exec uwsm start hyprland.desktop
fi

With the target reachable, the unit-side fixes are as written: systemctl --user daemon-reload then enable --now, systemctl --user add-wants graphical-session.target foo.service when the unit has no [Install], and a drop-in via systemctl --user edit foo.service adding After=graphical-session.target / PartOf=graphical-session.target rather than editing the shipped file. Prefer systemctl --user enable hyprpaper.service over an exec_cmd("hyprpaper") line.

Verify

After a fresh login, systemctl --user status graphical-session.target is active, and systemctl --user status foo.service is active (running) without you touching it.

Sources

user-unit-never-starts-graphical-session