Skip to content
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

systemd: add targets #8339

Closed
wants to merge 5 commits into from
Closed

systemd: add targets #8339

wants to merge 5 commits into from

Conversation

fufexan
Copy link
Member

@fufexan fufexan commented Nov 3, 2024

Describe your PR, what does it fix/add?

Adds more systemd targets.

Attempts to address NixOS/nixpkgs#347651.

Is there anything you want to mention? (unchecked code, possible bugs, found problems, breaking compatibility, etc.)

Untested. I don't know whether everything is hooked up as it should be.
We should probably implement a watchdog process like gnome-session-monitor.

Is it ready for merging, or does it need work?

Needs reviews and testing.

@izmyname @solopasha @ anyone else

@izmyname
Copy link
Contributor

izmyname commented Nov 3, 2024

We should probably implement a watchdog process like gnome-session-monitor.

Anything that brings up Hyprland session on par to GNOME, KDE and other DE's will be a good addition.

@izmyname
Copy link
Contributor

izmyname commented Nov 3, 2024

Also, might be related #8311

@izmyname
Copy link
Contributor

izmyname commented Nov 3, 2024

cmake --install ./build
-- Install configuration: "Release"
-- Installing: /usr/local/share/wayland-sessions/hyprland-systemd.desktop
-- Installing: /usr/local/lib/systemd/user/hyprland-session.service
CMake Error at build/cmake_install.cmake:59 (file):
  file INSTALL cannot find
  "/home/arch-mage/test/Hyprland/build/systemd/hyprland-session.target": No
  such file or directory.

UPD: Okay, I wasn't able to install targets with both CMake and meson. There's just hyprland-session.service.

@fufexan
Copy link
Member Author

fufexan commented Nov 3, 2024

Can you check the build directory?

@izmyname
Copy link
Contributor

izmyname commented Nov 3, 2024

There is only hyprland-session.service under Hyprland/build/systemd if that's what you mean

@izmyname
Copy link
Contributor

izmyname commented Nov 3, 2024

Hmm. Session file is installed from CMAKE_SOURCE_DIR, but target files are installed from CMAKE_BINARY_DIR. Maybe this is the problem? I'll replace CMAKE_BINARY with CMAKE_SOURCE and try again

@fufexan
Copy link
Member Author

fufexan commented Nov 3, 2024

Sure, that could work. Cmake needs reworking anyway.

@izmyname
Copy link
Contributor

izmyname commented Nov 3, 2024

Okay, nothing really changed for me, so far.

The one problem I think I should mention - after exiting the compositor (hyprctl dispatch exit), and re-entering the session - there's a chance other user services won't start, namely - hyprpaper, hypridle, portal-hyprland., hyprpolkitagent. This isn't really a regression, because it happens with just hyprland-session.service in the main branch, but anyway.

To reproduce - exit Hyprland session and re-enter again, several times, with and without binding graphical session to user login (i.e regardless of whether exiting the session should log a user out).

UPD: Despite being 'broken', systemctl reports that the services are active and running. Also, when this happens - xcursor is broken, as well - it fallbacks to default adwaita 32

UPD 2: My guess is where watchdog process comes in. It should stop all services, that depend on the graphical session, before the session, itself, exited, so the services could be restarted upon re-entering the graphical session. And, if xcursor is being managed by something like dconf service, it explains why it breaks, too.

@izmyname
Copy link
Contributor

izmyname commented Nov 3, 2024

Also, for some reason - meson doesn't autodetect systemd

@fufexan
Copy link
Member Author

fufexan commented Nov 3, 2024

I think we don't even need a watchdog. We can use systemd's OnFailure to stop everything that depends on graphical-session.target.

@fufexan
Copy link
Member Author

fufexan commented Nov 3, 2024

Meson should detect systemd as long as the option is enabled. It should probably be manually enabled.

@izmyname
Copy link
Contributor

izmyname commented Nov 3, 2024

The problem is that units don't fail. They are just absent upon restart the session, but systemd reports they are active

@fufexan
Copy link
Member Author

fufexan commented Nov 3, 2024

Then OnFailure and OnSuccess should have the same thing bound to them. So that units get stopped regardless of exit code.

@fufexan
Copy link
Member Author

fufexan commented Nov 3, 2024

So currently it's like this, from my understanding

hyprland-session.service -> bound to hyprland-session.target -> bound to graphical-session.target

Theoretically hyprland being closed/crashing should stop both targets. You're saying this does not happen. I will have to dig deeper.

@izmyname
Copy link
Contributor

izmyname commented Nov 3, 2024

If I understand this correctly, we could edit hypr* related units to have these conditions, but e.g. waybar.service has neither OnFailure nor OnSucces conditions. Something tells me, it has to be implemented the hard (GNOME/KDE) way.

I didn't mention waybar and mpd-notification services earlier, because I have Upholds overrides for them, because they fail to restart too, and now I understand, why.

@fufexan
Copy link
Member Author

fufexan commented Nov 3, 2024

It does not matter, systemd should just kill the processes regardless. At least that's what happens when I manually systemctl --user stop graphical-session.target.

@izmyname
Copy link
Contributor

izmyname commented Nov 3, 2024

CMake Error at build/cmake_install.cmake:55 (file):
  file INSTALL cannot find
  "/home/arch-mage/test/Hyprland/systemd/hyprland-session.service": No such
  file or directory.

The service, itself, there and in the build dir, as well

@fufexan
Copy link
Member Author

fufexan commented Nov 3, 2024

Ah yeah my bad.

@izmyname
Copy link
Contributor

izmyname commented Nov 3, 2024

ExecStart=/usr/bin/Hyprland
ExecStop=/usr/bin/hyprctl dispatch exit

Even, though Hyprland is installed in /usr/local, so the correct path should be /usr/local/bin

Also, it didn't work. The services aren't restarting upon exiting, then re-entering the session.

@izmyname
Copy link
Contributor

izmyname commented Nov 4, 2024

IMHO, might be a good idea to look, how GNOME and KDE do systemd stuff and adapt their practices to Hyprland. Correct session handling with systemd might as important stuff to implement, as were aquamarine and explicit sync, since both Arch Linux and NixOS - officially supported distros - use systemd.

UPD: meson build seems to be broken too, as it defaults to /bin instead of /usr/local/bin. I, honestly, have no clue why CMake changed BINDIR variable value.

@izmyname
Copy link
Contributor

izmyname commented Nov 4, 2024

Another insight - I suggest replacing @bindir@ variable inside hyprland-session.service with just /bin, like it was done in hypridle.service due to similar reasons (see hyprwm/hypridle#47 ). This way, we can fix #8340 along the way.

@fufexan
Copy link
Member Author

fufexan commented Nov 4, 2024

#8340 will be fixed precisely by this PR, because I removed @Prefix@ and left only @bindir@. Also, hardcoding paths is never the solution. I should fix that in hypridle.

@Vladimir-csp
Copy link
Contributor

Be aware that some DMs might not support desktop entry Exec quoting properly: Vladimir-csp/uwsm#39. I do not know if any upstream bug reports were made about this.

@Vladimir-csp
Copy link
Contributor

Vladimir-csp commented Nov 7, 2024

Also, @Vladimir-csp instruction for making a desktop file for starting a compositor with DM is a bit unclear to me. Should it look like

Basically yes, but you left an extra quote there. Something like this, with bad-DM-proof comment. (oh, and the executable was also missing)

[Desktop Entry]
Name=Hyprland (uwsm-managed)
Comment=An intelligent dynamic tiling Wayland compositor
Exec=uwsm start -N Hyprland -D Hyprland -C An_intelligent_dynamic_tiling_Wayland_compositor -- Hyprland
DesktopNames=Hyprland
Type=Application

@izmyname
Copy link
Contributor

izmyname commented Nov 7, 2024

Be aware that some DMs might not support desktop entry Exec quoting properly: Vladimir-csp/uwsm#39. I do not know if any upstream bug reports were made about this.

Probably, it's possible to wrap exec string in a script and Exec=srcipt.sh

@fufexan
Copy link
Member Author

fufexan commented Nov 7, 2024

@Vladimir-csp then is the Nixpkgs module implementation wrong for adding a Comment field?
https://github.com/NixOS/nixpkgs/blob/4aa36568d413aca0ea84a1684d2d46f55dbabad7/nixos/modules/programs/wayland/uwsm.nix#L16-L20

@Vladimir-csp
Copy link
Contributor

Probably, it's possible to wrap exec string in a script and Exec=srcipt.sh

There will be problems if one launches such entry with uwsm, it won't recognize itself. :)

@izmyname
Copy link
Contributor

izmyname commented Nov 7, 2024

Probably, it's possible to wrap exec string in a script and Exec=srcipt.sh

There will be problems if one launches such entry with uwsm, it won't recognize itself. :)

Sacrificing dm-compatibility isn't the best thing, but since display managers aren't officially supported, as stated in Hyprland wiki - probably, not that critical.

Anyway, it's up to hyprwm team to decide. If the final decision is to use uwsm - I'll wait for systemd cleanup and then, will help to adjust the wiki.

@Vladimir-csp
Copy link
Contributor

Vladimir-csp commented Nov 7, 2024

then is the Nixpkgs module implementation wrong for adding a Comment field?

No, Comment field is perfectly valid. Or did you mean not adding -C argument? It is a matter of consistency/cosmetics. If entry is launched by a DM, uwsm does not have access to its contents, so it relies on cli arguments to fill in unit description. If entry is launched by uwsm, it recognizes itself in the Exec command line and takes into account both entry content and command line args.

More important choice is -S argument - whether to put compositor into app or session slice (users are expected to configure application launching as units via uwsm app helper).

@Vladimir-csp
Copy link
Contributor

#8339 (comment) this example (edited) is DM-proof and consistent (except underscores).

@izmyname
Copy link
Contributor

izmyname commented Nov 7, 2024

Sacrificing dm-compatibility isn't the best thing

Oh wait, you meant that this string, with underscores, actually bypasses DM limitations and allows using the entry with them.

An_intelligent_dynamic_tiling_Wayland_compositor

My bad

@Vladimir-csp
Copy link
Contributor

Vladimir-csp commented Nov 7, 2024

Yes. I guess DMs did not expect the Spanish Inquisitionneed to follow all the Spec

Report mentioned these:

I've tried greetd running cosmic-comp, cage'd ReGreet, SDDM, and GDM.

@izmyname
Copy link
Contributor

izmyname commented Nov 7, 2024

Good. In this case, we can just replace existing hyprland-systemd.desktop with hyprland-uwsm.desktop. Or, we can just replace the contents of hyprland-systemd.desktop, as it's already configured to be installed with systemd deps.

@izmyname
Copy link
Contributor

izmyname commented Nov 7, 2024

Some update about xpdh-service. Using loginctl terminate-user "" instead of hyprctl dispatch exit brings back both xdph and flatpak xcursor after restarting the session, as expected. I should mention it on wiki

@fufexan that's, probably, the reason why our own service didn't work as expected - we should've used a systemd command instead of hyprctl one.

@Vladimir-csp I think makes sense to add a warning to uwsm "how to stop" readme section to not use compositor-side exit commands and use systemctl, instead.

@fufexan
Copy link
Member Author

fufexan commented Nov 7, 2024

I've finally managed to start Hyprland using uwsm, but services are not started due to the absence of WAYLAND_DISPLAY.

journalctl -xe:

Nov 07 21:45:51 io systemd[221007]: Finished Environment preloader for Hyprland (UWSM), Hyprland managed by UWSM.
Nov 07 21:45:51 io systemd[221007]: Reached target Preparation for session of hyprland-uwsm.desktop Wayland compositor.
Nov 07 21:45:51 io systemd[221007]: Reached target Session services which should run early before the graphical session is brought up.
Nov 07 21:45:51 io systemd[221007]: Reached target Home Manager System Tray.
Nov 07 21:45:51 io systemd[221007]: Started Gammastep colour temperature adjuster.
Nov 07 21:45:51 io systemd[221007]: hypridle was skipped because of an unmet condition check (ConditionEnvironment=WAYLAND_DISPLAY).
uwsm_env-preloader output
Nov 07 21:45:51 io uwsm_env-preloader[292194]: Loading plugin "/run/current-system/sw/share/uwsm/plugins/hyprland.sh"
Nov 07 21:45:51 io uwsm_env-preloader[292194]: Applying quirks for "hyprland"
Nov 07 21:45:51 io uwsm_env-preloader[292194]: Marking variables for later cleanup from systemd user manager on stop:
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   DISPLAY
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   EDITOR
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   FLAKE
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   GTK_PATH
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   INFOPATH
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   LANG
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   LESSKEYIN_SYSTEM
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   LESSOPEN
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   LIBEXEC_PATH
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   NIXOS_OZONE_WL
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   NIXPKGS_CONFIG
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   NIX_PROFILES
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   NIX_USER_PROFILE_DIR
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   PAGER
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   PATH
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   QTWEBKIT_PLUGIN_PATH
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   SSH_ASKPASS
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   TERM
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   TERMINFO_DIRS
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   UWSM_FINALIZE_VARNAMES
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   UWSM_WAIT_VARNAMES
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   WAYLAND_DISPLAY
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   XCURSOR_PATH
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   XCURSOR_SIZE
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   XCURSOR_THEME
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   XDG_BACKEND
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   XDG_CONFIG_DIRS
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   XDG_CURRENT_DESKTOP
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   XDG_DATA_DIRS
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   XDG_MENU_PREFIX
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   XDG_SESSION_DESKTOP
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   XDG_SESSION_ID
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   XDG_SESSION_TYPE
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   XDG_VTNR
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   __ETC_PROFILE_DONE
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   __NIXOS_SET_ENVIRONMENT_DONE
Nov 07 21:45:51 io uwsm_env-preloader[292194]: Exporting variables to systemd user manager:
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   EDITOR
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   FLAKE
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   GTK_PATH (updating)
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   INFOPATH (updating)
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   LESSKEYIN_SYSTEM
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   LESSOPEN
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   LIBEXEC_PATH (updating)
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   NIXOS_OZONE_WL
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   NIXPKGS_CONFIG
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   NIX_PROFILES
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   NIX_USER_PROFILE_DIR
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   PAGER
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   PATH (updating)
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   QTWEBKIT_PLUGIN_PATH (updating)
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   SSH_ASKPASS
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   TERM
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   TERMINFO_DIRS (updating)
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   UWSM_FINALIZE_VARNAMES
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   UWSM_WAIT_VARNAMES
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   XCURSOR_PATH (updating)
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   XDG_BACKEND
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   XDG_CONFIG_DIRS (updating)
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   XDG_CURRENT_DESKTOP
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   XDG_DATA_DIRS (updating)
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   XDG_MENU_PREFIX
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   XDG_SESSION_DESKTOP
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   XDG_SESSION_ID
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   XDG_SESSION_TYPE
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   XDG_VTNR
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   __ETC_PROFILE_DONE
Nov 07 21:45:51 io uwsm_env-preloader[292194]:   __NIXOS_SET_ENVIRONMENT_DONE
Nov 07 21:45:51 io systemd[221007]: Finished Environment preloader for Hyprland (UWSM), Hyprland managed by UWSM.

Looks like WAYLAND_DISPLAY is not being exported.

@Vladimir-csp any idea if this is a misconfig on my end?

@Vladimir-csp
Copy link
Contributor

I've finally managed to start Hyprland using uwsm, but services are not started due to the absence of WAYLAND_DISPLAY.

Are those services ordered After=graphical-session.target? They should be.

WAYLAND_DISPLAY is exported by Hyprland, this triggers graphical-session.target to be reached. Preloader is part of graphical-session-pre.target.

@fufexan
Copy link
Member Author

fufexan commented Nov 7, 2024

Ah yeah, why didn't I check that first. They're After=graphical-session-pre.target and PartOf=graphical-session.target. Should I keep the latter or drop it?

@Vladimir-csp
Copy link
Contributor

Vladimir-csp commented Nov 7, 2024

(moved to hyprwm/hyprland-wiki#850 (comment))

@Vladimir-csp
Copy link
Contributor

Ah yeah, why didn't I check that first. They're After=graphical-session-pre.target and PartOf=graphical-session.target. Should I keep the latter or drop it?

Rule of thumb: if something needs WAYLAND_DISPLAY, it should have After=graphical-session.target

@fufexan
Copy link
Member Author

fufexan commented Nov 7, 2024

I found out that we've been doing hypr* services all wrong in Home Manager then. Almost all of them depend on graphical-session-pre. I will open PRs to fix those issues. Even the tray target we create wants it, which causes more problems down the line. There's also kdeconnect-indicator which does the same thing, probably an Xorg leftover.

Apps (also things that do not have a systemd unit, run continuously, and are not related to the compositor) need to be wrapped in units by executing them via uwsm app or uwsm-app or app2unit, or directly via systemd-run --user ....

I already do this in my configuration with a wrapper over systemd-run. I do like the approach of uwsm app, and it's definitely more complete than my crude implementation.

Comment on lines +15 to +16
ExecStart=@BINDIR@/Hyprland
ExecStop=@BINDIR@/hyprctl dispatch exit
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks using the current flake:

...
[Service]
Type=notify
ExecStart=bin/Hyprland
ExecStop=bin/hyprctl dispatch exit
ExecStopPost=systemctl --user unset-environment DISPLAY WAYLAND_DISPLAY HYPRLAND_INSTANCE_SIGNATURE XDG_CURRENT_DESKTOP
OnFailure=systemctl --user unset-environment DISPLAY WAYLAND_DISPLAY HYPRLAND_INSTANCE_SIGNATURE XDG_CURRENT_DESKTOP
OnSuccess=systemctl --user unset-environment DISPLAY WAYLAND_DISPLAY HYPRLAND_INSTANCE_SIGNATURE XDG_CURRENT_DESKTOP
...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're scrapping the idea anyway.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, that's odd, bindir is set in the mesonFlags: --bindir=/nix/store/81g3gcxh6ca0gk46r6p7zqna2fb3svd7-hyprland-0.44.0+date=2024-11-03_dirty/bin

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, after I built the package I got this

[Service]
Type=notify
ExecStart=/nix/store/hsx2dwp9agi54dvkkp7rhr9wgvar6d4h-hyprland-0.44.0+date=2024-11-03_403cd66/bin/Hyprland
ExecStop=/nix/store/hsx2dwp9agi54dvkkp7rhr9wgvar6d4h-hyprland-0.44.0+date=2024-11-03_403cd66/bin/hyprctl dispatch exit
ExecStopPost=systemctl --user unset-environment DISPLAY WAYLAND_DISPLAY HYPRLAND_INSTANCE_SIGNATURE XDG_CURRENT_DESKTOP
Restart=on-failure
Slice=session.slice

Copy link

@Atemu Atemu Nov 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very odd indeed. I was overriding the nixpkgs input, let me change that and see if we get the same eval:

/nix/store/8gww5vdnbxgvd8ian4m7z8rhixb0vsy9-hyprland-0.44.0+date=2024-11-03_d78bc75.drv

/nix/store/p1fx35kj1nw5w6swlz9xwhkbmjbknn55-hyprland-0.44.0+date=2024-11-03_d78bc75

It's different to your store path. Have you pushed all changes?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciate wanting to use ready-made solutions but they need to actually solve the problem properly in order to be viable.

Unless I'm missing something, it is not possible in uwsm to create a service that is part of the greater hyprland session but starts after the compositor is up. You cannot make it wantedBy graphical-session because it'd then be wantedBy any graphical session, regardless of the compositor. If you made it After the compositor service other services After the compositor service or the graphical-session wouldn't wait on your service, so that wouldn't work either.
I'd have expected uwsm to create a target for us that'd allow for this use-case.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, it does create all sorts of targets. I didn't immediately find them because it appears to generate them dynamically rather than putting them into /etc/systemd/user/?!

Copy link
Member Author

@fufexan fufexan Nov 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Vladimir-csp is it feasible to also create a {name}-session.target that would be bound to wayland-session@{name}.target?

@Atemu would this address your concern?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, as I said, it already does this, I just didn't see it because the units files weren't where I expected them to be.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using [email protected] while target not yet existing is valid and works, but will result in a (harmless) warning from systemd.

Alternatively there is systemd-xdg-autostart-condition, see examples

Comment on lines +18 to +19
OnFailure=systemctl --user unset-environment DISPLAY WAYLAND_DISPLAY HYPRLAND_INSTANCE_SIGNATURE XDG_CURRENT_DESKTOP
OnSuccess=systemctl --user unset-environment DISPLAY WAYLAND_DISPLAY HYPRLAND_INSTANCE_SIGNATURE XDG_CURRENT_DESKTOP
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/etc/systemd/user/hyprland-session.service:18: Unknown key 'OnFailure' in section [Service], ignoring.
/etc/systemd/user/hyprland-session.service:19: Unknown key 'OnSuccess' in section [Service], ignoring.

These go into the [Unit] section.

@fufexan
Copy link
Member Author

fufexan commented Nov 8, 2024

I guess this can be closed in favor of #8376.

@fufexan fufexan closed this Nov 8, 2024
Atemu added a commit to Atemu/nixos-config that referenced this pull request Nov 10, 2024
This is much more robust than starting the session from the compositor config.

It will also become the upstream-sanctioned method to start a hyprland session
with proper systemd integration: hyprwm/Hyprland#8339
@vaxerski vaxerski deleted the systemd branch November 18, 2024 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants