-
-
Notifications
You must be signed in to change notification settings - Fork 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
systemd: add targets #8339
Closed
systemd: add targets #8339
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
17ed05f
systemd: add session targets
fufexan 4a67739
systemd/meson.build: install targets
fufexan 2557b9c
CMake: install systemd targets
fufexan 2c63c1e
systemd: don't prepend PREFIX
fufexan d78bc75
systemd/hyprland-session: add OnFailure and OnSuccess commands
fufexan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -222,8 +222,8 @@ if(NO_SYSTEMD) | |
else() | ||
message(STATUS "SYSTEMD support is requested (NO_SYSTEMD not defined)...") | ||
add_compile_definitions(USES_SYSTEMD) | ||
configure_file(systemd/hyprland-session.service.in | ||
systemd/hyprland-session.service @ONLY) | ||
configure_file(${CMAKE_SOURCE_DIR}/systemd/hyprland-session.service.in | ||
${CMAKE_BINARY_DIR}/systemd/hyprland-session.service @ONLY) | ||
|
||
# session file -systemd | ||
install(FILES ${CMAKE_SOURCE_DIR}/systemd/hyprland-systemd.desktop | ||
|
@@ -232,6 +232,14 @@ else() | |
# install systemd service | ||
install(FILES ${CMAKE_BINARY_DIR}/systemd/hyprland-session.service | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/systemd/user) | ||
|
||
# install systemd targets | ||
install(FILES ${CMAKE_SOURCE_DIR}/systemd/hyprland-session.target | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/systemd/user) | ||
install(FILES ${CMAKE_SOURCE_DIR}/systemd/[email protected] | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/systemd/user) | ||
install(FILES ${CMAKE_SOURCE_DIR}/systemd/hyprland-session-pre.target | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/systemd/user) | ||
endif() | ||
|
||
set(CPACK_PROJECT_NAME ${PROJECT_NAME}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[Unit] | ||
Description=Tasks to be run before Hyprland Session starts | ||
DefaultDependencies=no | ||
RefuseManualStart=yes | ||
RefuseManualStop=yes | ||
|
||
Requires=graphical-session-pre.target | ||
After=graphical-session-pre.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,21 @@ | ||
[Unit] | ||
Description=Hyprland - Tiling compositor with the looks | ||
Documentation=man:Hyprland(1) | ||
BindsTo=graphical-session.target | ||
Before=graphical-session.target | ||
|
||
BindsTo=hyprland-session.target | ||
Before=hyprland-session.target | ||
|
||
Wants=xdg-desktop-autostart.target | ||
Wants=graphical-session-pre.target | ||
After=graphical-session-pre.target | ||
|
||
Wants=hyprland-session-pre.target | ||
After=hyprland-session-pre.target | ||
|
||
[Service] | ||
Type=notify | ||
ExecStart=@PREFIX@/@BINDIR@/Hyprland | ||
ExecStop=@PREFIX@/@BINDIR@/hyprctl dispatch exit | ||
ExecStart=@BINDIR@/Hyprland | ||
ExecStop=@BINDIR@/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 | ||
Comment on lines
+18
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
These go into the |
||
Restart=on-failure | ||
Slice=session.slice |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[Unit] | ||
Description=Hyprland Session | ||
DefaultDependencies=no | ||
RefuseManualStart=yes | ||
RefuseManualStop=yes | ||
|
||
BindsTo=graphical-session.target | ||
Before=graphical-session.target | ||
After=hyprland-session-pre.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[Unit] | ||
Description=Hyprland Session (session: %i) | ||
DefaultDependencies=no | ||
# Start happens explicitly | ||
RefuseManualStart=no | ||
|
||
Conflicts=shutdown.target | ||
PartOf=graphical-session.target | ||
|
||
# As this is the main entry point, pull in the other toplevel hyprland-session targets | ||
[email protected] | ||
[email protected] | ||
|
||
Requires=hyprland-session.target | ||
After=hyprland-session.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,33 @@ | ||
install_data( | ||
'hyprland-systemd.desktop', | ||
install_dir: join_paths(get_option('datadir'), 'wayland-sessions'), | ||
install_tag: 'runtime', | ||
) | ||
user_unit_dir = systemd.get_variable(pkgconfig: 'systemduserunitdir', | ||
pkgconfig_define: ['prefix', get_option('prefix')]) | ||
|
||
install_data( | ||
'hyprland-systemd.desktop', | ||
install_dir: join_paths(get_option('datadir'), 'wayland-sessions'), | ||
install_tag: 'runtime', | ||
) | ||
install_data( | ||
'hyprland-session.target', | ||
install_dir: user_unit_dir, | ||
install_tag: 'runtime', | ||
) | ||
install_data( | ||
'[email protected]', | ||
install_dir: user_unit_dir, | ||
install_tag: 'runtime', | ||
) | ||
install_data( | ||
'hyprland-session-pre.target', | ||
install_dir: user_unit_dir, | ||
install_tag: 'runtime', | ||
) | ||
|
||
conf_data = configuration_data() | ||
conf_data.set('PREFIX', get_option('prefix')) | ||
conf_data.set('BINDIR', get_option('bindir')) | ||
user_unit_dir = systemd.get_variable(pkgconfig: 'systemduserunitdir', | ||
pkgconfig_define: ['prefix', get_option('prefix')]) | ||
|
||
configure_file( | ||
configuration: conf_data, | ||
input: 'hyprland-session.service.in', | ||
output: '@BASENAME@', | ||
install_dir: user_unit_dir ) | ||
install_dir: user_unit_dir | ||
) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 breaks using the current flake:
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're scrapping the idea anyway.
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.
Hm, that's odd, bindir is set in the mesonFlags:
--bindir=/nix/store/81g3gcxh6ca0gk46r6p7zqna2fb3svd7-hyprland-0.44.0+date=2024-11-03_dirty/bin
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.
Yes, after I built the package I got this
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.
Very odd indeed. I was overriding the nixpkgs input, let me change that and see if we get the same eval:
It's different to your store path. Have you pushed all changes?
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 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 servicesAfter
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.
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.
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/
?!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.
@Vladimir-csp is it feasible to also create a
{name}-session.target
that would be bound towayland-session@{name}.target
?@Atemu would this address your concern?
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, 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.
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.
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