-
-
Notifications
You must be signed in to change notification settings - Fork 15.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nixos/hypridle: only run the service on Hyprland #355416
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is a good way to check for Hyprland's existence.
Take the scenario where a user logs into Hyprland, closes it, and then logs into another compositor/DE/WM. The directory will still exist until the next boot (or whenever it is removed), and hypridle will start every time, even on sessions where it may be unwanted.
Well, this kind of safeguards it instead of just letting it start once Another approach would be checking for a variable, like systemd.user.services.hypridle.unitConfig.ConditionEnvironment = "XDG_SESSION_DESKTOP=Hyprland"; |
CC @Vladimir-csp for inputs, if they have a better idea :D |
My idea is to reuse |
Not familiar with the implementation. AFAIK you need a desktop file for XDG autostart? |
Originally posted by @Vladimir-csp in 0021223 I suppose so, but why Hyprland does not set the variable by default (as in force it)? @fufexan |
The 2nd option in this comment has the code for XDG autostart condition #347651 (comment). |
Pointing |
Option 1 is not feasible without UWSM, we want to have it working without relying on UWSM if possible. A question also arises if Hypridle even works on other compositors. Option 2 is good, but I suppose this will also work when UWSM is not enabled? (Does Hyprland implement XDG-activation-condition by itself?) |
It might be feasible with other implementations that provide a compositor-specific units. What I'm saying is, there would be no conflict if
It should work with any implementation that invokes systemd's |
I'd lean towards the WantedBy solution then. But that just that alone won't solve our issue. If we have two This will just bring us back to where we started. |
But which unit binds to |
|
If using UWSM is the only recommended solution for systemd support in Hyprland by upstream, we can remove I think we should start by adding a withUWSM option in Hyprland module, to make it easier for users and enable it by default later. I'll open a PR soon. |
This needs uwsm enabled. You can do so by setting `programs.hyprland.withUWSM = true`
0021223
to
a58ba43
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should provide some information about setting systemd.user.services.hypridle.wantedBy
to other values to allow using hypridle with other compositors.
I'd prefer this over duplicating the wantedBy
option.
Also, the target will be different when using UWSM. In my case it is |
Sure, but atleast one wantedBy here is needed, else NixOS module system won't recognise the service AFAIK. |
Is that supposed to work like that? I am using the standard configuration of Hyprland with UWSM. |
Ok, this might be GDM at play here. I'm using greetd's initial_session (autologin) with @Vladimir-csp could this be implemented? Or should I modify my call? |
I mean... isn't that double wrapping with uwsm? hyprland-uwsm.desktop should wrap Hyprland with uwsm already. GDM can execute the hyprland-uwsm.desktop directly, not sure about Greetd. |
Unit specifier comes from whatever was given to |
perhaps, in case of Hyprland or Sway, autodetection could be done and the service will always be: |
Hardcoding that would be ugly. Treating the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not work. At the minimum, you need what I worked out here:
# Service should be only be started on Hyprland | ||
# this target is started by UWSM | ||
wantedBy = [ "[email protected]" ]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will only start the service. It will not wait for to have started and never stop it either.
systemd.user.services.hypridle = { | ||
# Service should be only be started on Hyprland | ||
# this target is started by UWSM | ||
wantedBy = [ "[email protected]" ]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wantedBy = [ "[email protected]" ]; | |
wantedBy = [ "[email protected]" ]; | |
# order start after compositor (and WAYLAND_DISPLAY) is available | |
# order stop before compositor | |
after = [ "[email protected]" ]; | |
# squeeze before graphical session.target | |
before = [ "graphical-session.target" ]; | |
# stop with the session | |
partOf = [ "graphical-session.target" ]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two targets do not exist on NixOS. We've explicitly limited this module to only work with the programs.hyprland.withUWSM
option which only creates the [email protected]
. (I'd prefer a stronger API than the Hyprland package's binary name here but that's something our uwsm module would need to offer.)
We also want to order hypridle before
the wayland session so that it's only considered up when hypridle has actually started. (Wants=
does not imply any order.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
edited
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my config I made it before
and partOf
[email protected]
because I think of hypridle as belonging to the "Hyprland session" rather than the graphical-session directly. This would also be okay IMV.
I do find it a bit weird to depend on the session target rather than the wm service though as that's our actual dependency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Units of service and target are bound, so there is no difference for dependencies. Targets are more frequently used as dependencies.
$ grep -r ^WantedBy= /lib/systemd/system | grep -cF .target
124
$ grep -r ^WantedBy= /lib/systemd/system | grep -cF .service
90
$ grep -r ^WantedBy= /lib/systemd/user | grep -cF .target
24
$ grep -r ^WantedBy= /lib/systemd/user | grep -cF .service
17
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I don't follow. Could you reword?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[email protected]
is bound to [email protected]
, so they are interchangeable as dependencies (but can differ when ordering).
Targets are more frequently used for dependencies than services.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Depending on graphical-session.target
, is fine in my opinion.
When a WM managed by UWSM is terminated, graphical-session also stops. So I understand the partOf bit.
What I don't understand is why are we supposed to start it "before" graphical-session
? Starting it after isn't correct?
I'd prefer a stronger API than the Hyprland package's binary name here
Agreed.
EDIT: I did read the above discussion about before
, but still confused
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I don't understand is why are we supposed to start it "before"
graphical-session
? Starting it after isn't correct?
Because we only want the session to be considered up and running once hypridle is up and running.
For this service to work properly on Hyprland, you | ||
need to have `programs.hyprland.withUWSM` enabled. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should assert that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, because @fufexan wants it to be compatible with other compositors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As it stands right now, it cannot be compatible with other compositors because it depends on the hyprland-uwsm-specific units.
If you wanted to use it with another compositor, you should bring your own hypridle unit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could be compatible if you just add more targets in WantedBy
and After
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or simply add systemd.user.services.swayidle.wantedBy = ["your-compositors-session.target"];
. This should be an admonition in the enable option's description.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could turn the targets that hypridle is wantedBy
and before
into an option. withUWSM
would set it to the UWSM-generated session unit. We could then simply assert that this option's value isn't an empty list.
@fufexan just so we are on the clear here, at the moment, is hypridle supported on WMs like sway, wayfire, mir? |
I don't want it in Plasma. Wait for NixOS/nixpkgs#355416
Since #355959 have been merged we can finally get this going.
This PR makes the service only start with "[email protected]". This needs a UWSM configured setup.
Finally closes #347651
Things done