From f3f7d3629a632682b1b3acf800f0b5fb10cd48f4 Mon Sep 17 00:00:00 2001 From: izmyname <135810812+izmyname@users.noreply.github.com> Date: Sun, 27 Oct 2024 00:49:00 +0500 Subject: [PATCH] Build with hyprland-session.service (#8251) Co-authored-by: Mihai Fufezan --- CMakeLists.txt | 10 ++++++++++ meson.build | 3 +++ .../hyprland-session.service.in | 6 +++--- {example => systemd}/hyprland-systemd.desktop | 0 systemd/meson.build | 15 +++++++++++++++ 5 files changed, 31 insertions(+), 3 deletions(-) rename example/hyprland-session.service => systemd/hyprland-session.service.in (61%) rename {example => systemd}/hyprland-systemd.desktop (100%) create mode 100644 systemd/meson.build diff --git a/CMakeLists.txt b/CMakeLists.txt index df919d76..ec8c331e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,9 @@ include(GNUInstallDirs) set(HYPRLAND_VERSION ${VER}) set(PREFIX ${CMAKE_INSTALL_PREFIX}) set(INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR}) +set(BINDIR ${CMAKE_INSTALL_BINDIR}) configure_file(hyprland.pc.in hyprland.pc @ONLY) +configure_file(systemd/hyprland-session.service.in systemd/hyprland-session.service @ONLY) set(CMAKE_MESSAGE_LOG_LEVEL "STATUS") @@ -357,6 +359,11 @@ install( install(FILES ${CMAKE_SOURCE_DIR}/example/hyprland.desktop DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/wayland-sessions) + +# session file -systemd +install(FILES ${CMAKE_SOURCE_DIR}/systemd/hyprland-systemd.desktop + DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/wayland-sessions) + # allow Hyprland to find assets add_compile_definitions(DATAROOTDIR="${CMAKE_INSTALL_FULL_DATAROOTDIR}") @@ -397,3 +404,6 @@ install( DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hyprland FILES_MATCHING PATTERN "*.h*") + +#install systemd service +install(FILES ${CMAKE_BINARY_DIR}/systemd/hyprland-session.service DESTINATION ${CMAKE_INSTALL_LIBDIR}/systemd/user) diff --git a/meson.build b/meson.build index 33e8fdbe..d0ba9a5c 100644 --- a/meson.build +++ b/meson.build @@ -80,6 +80,8 @@ if get_option('tracy_enable') and get_option('buildtype') != 'debugoptimized' warning('Profiling builds should set -- buildtype = debugoptimized') endif + + subdir('protocols') subdir('src') subdir('hyprctl') @@ -87,6 +89,7 @@ subdir('hyprpm/src') subdir('assets') subdir('example') subdir('docs') +subdir('systemd') # Generate hyprland.pc pkg_install_dir = join_paths(get_option('datadir'), 'pkgconfig') diff --git a/example/hyprland-session.service b/systemd/hyprland-session.service.in similarity index 61% rename from example/hyprland-session.service rename to systemd/hyprland-session.service.in index 3089a961..dafdc141 100644 --- a/example/hyprland-session.service +++ b/systemd/hyprland-session.service.in @@ -9,8 +9,8 @@ After=graphical-session-pre.target [Service] Type=notify -ExecStart=/usr/bin/Hyprland -ExecStop=/usr/bin/hyprctl dispatch exit -ExecStopPost=/usr/bin/systemctl --user unset-environment DISPLAY WAYLAND_DISPLAY HYPRLAND_INSTANCE_SIGNATURE XDG_CURRENT_DESKTOP +ExecStart=@PREFIX@/@BINDIR@/Hyprland +ExecStop=@PREFIX@/@BINDIR@/hyprctl dispatch exit +ExecStopPost=systemctl --user unset-environment DISPLAY WAYLAND_DISPLAY HYPRLAND_INSTANCE_SIGNATURE XDG_CURRENT_DESKTOP Restart=on-failure Slice=session.slice diff --git a/example/hyprland-systemd.desktop b/systemd/hyprland-systemd.desktop similarity index 100% rename from example/hyprland-systemd.desktop rename to systemd/hyprland-systemd.desktop diff --git a/systemd/meson.build b/systemd/meson.build new file mode 100644 index 00000000..497e64f4 --- /dev/null +++ b/systemd/meson.build @@ -0,0 +1,15 @@ +install_data( + 'hyprland-systemd.desktop', + install_dir: join_paths(get_option('datadir'), 'wayland-sessions'), + install_tag: 'runtime', +) + +conf_data = configuration_data() +conf_data.set('PREFIX', get_option('prefix')) +conf_data.set('BINDIR', get_option('bindir')) + +configure_file( + configuration: conf_data, + input: 'hyprland-session.service.in', + output: '@BASENAME@', + install_dir: join_paths(get_option('libdir'), 'systemd/user') )