File 0010-Add-a-systemd-user-unit-file.patch of Package kdrive

From 021c23e2b5c351f08750e8700fdc13023008ac98 Mon Sep 17 00:00:00 2001
From: Christophe Marin <christophe@krop.fr>
Date: Tue, 27 May 2025 13:52:02 +0200
Subject: [PATCH 10/10] Add a systemd user unit file

Pass -DINSTALL_SYSTEMD_USER_UNIT=ON at build time, then
`systemctl --user enable infomaniak-kdrive.service` after install to enable
the service.
---
 CMakeLists.txt               | 10 ++++++++++
 infomaniak-kdrive.service.in | 15 +++++++++++++++
 2 files changed, 25 insertions(+)
 create mode 100644 infomaniak-kdrive.service.in

diff --git a/CMakeLists.txt b/CMakeLists.txt
index b48babb..a38c269 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -165,6 +165,16 @@ option(BUILD_GUI "BUILD_GUI" ON)
 # build the tests
 option(BUILD_UNIT_TESTS "BUILD_UNIT_TESTS" OFF)
 
+if(UNIX AND BUILD_GUI)
+    option(INSTALL_SYSTEMD_USER_UNIT "Install systemd user unit file" OFF)
+endif()
+
+if(INSTALL_SYSTEMD_USER_UNIT)
+    set(SYSTEMD_USER_UNIT_DIR "lib/systemd/user")
+    configure_file(${CMAKE_CURRENT_SOURCE_DIR}/infomaniak-kdrive.service.in ${CMAKE_CURRENT_BINARY_DIR}/infomaniak-kdrive.service @ONLY)
+    install(FILES ${CMAKE_CURRENT_BINARY_DIR}/infomaniak-kdrive.service DESTINATION ${SYSTEMD_USER_UNIT_DIR})
+endif()
+
 if(APPLE)
     # build uninstaller
     option(BUILD_UNINSTALLER "BUILD_UNINSTALLER" ON)
diff --git a/infomaniak-kdrive.service.in b/infomaniak-kdrive.service.in
new file mode 100644
index 0000000..6bbedf5
--- /dev/null
+++ b/infomaniak-kdrive.service.in
@@ -0,0 +1,15 @@
+# SPDX-License-Identifier: MIT
+# SPDX-FileCopyrightText: 2025 Christophe Marin <christophe@krop.fr>
+
+[Unit]
+Description=kDrive file synchronisation utility
+
+[Service]
+Type=simple
+ExecStart=@CMAKE_INSTALL_FULL_BINDIR@/kDrive
+TimeoutSec=10sec
+Type=simple
+Restart=on-failure
+
+[Install]
+WantedBy=graphical-session.target
-- 
2.50.0

openSUSE Build Service is sponsored by