diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b11bdc3..3f7e1583 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,8 @@ set(KDE_COMPILERSETTINGS_LEVEL "5.82") set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) +option(INSTALL_SYSTEMD_SERVICE "Install a systemd service file to start the session" OFF) + find_package(ECM ${KF6_MIN_VERSION} REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) @@ -137,3 +139,10 @@ kde_clang_format(${ALL_CLANG_FORMAT_SOURCE_FILES}) kde_configure_git_pre_commit_hook(CHECKS CLANG_FORMAT) ki18n_install(po) + +if (INSTALL_SYSTEMD_SERVICE) + install(FILES + ${CMAKE_CURRENT_SOURCE_DIR}/plasma-mobile.service + DESTINATION ${KDE_INSTALL_SYSTEMDUNITDIR} + ) +endif() diff --git a/plasma-mobile.service b/plasma-mobile.service new file mode 100644 index 00000000..51944625 --- /dev/null +++ b/plasma-mobile.service @@ -0,0 +1,59 @@ +[Unit] +Description=Open-source user interface for phones, based on Plasma technologies +Documentation=https://invent.kde.org/plasma-mobile + +# replaces the getty +Conflicts=getty@tty7.service +After=getty@tty7.service + +# Needs all the dependencies of the services it's replacing +# (currently getty@tty1.service): +After=rc-local.service plymouth-quit-wait.service systemd-user-sessions.service + +OnFailure=getty@tty7.service + +# D-Bus is necessary for contacting logind. Logind is required. +Wants=dbus.socket +After=dbus.socket + +# This scope is created by pam_systemd when logging in as the user. +# This directive is a workaround to a systemd bug, where the setup of the +# user session by PAM has some race condition, possibly leading to a failure. +After=session-c1.scope + +# Since we are part of the graphical session, make sure we are started before +# it is complete. +Before=graphical.target + +# Prevent starting on systems without virtual consoles +ConditionPathExists=/dev/tty0 + +[Service] +Environment=LANG=C.UTF-8 +Environment=XDG_SEAT=seat0 +Environment=XDG_VTNR=tty7 +ExecStart=/usr/bin/startplasmamobile +TimeoutStartSec=30 +User=1000 +PAMName=login +WorkingDirectory=~ +Restart=always +RestartSec=5s + +# A virtual terminal is needed. +TTYPath=/dev/tty7 +TTYReset=yes +TTYVHangup=yes +TTYVTDisallocate=yes + +# Fail to start if not controlling the tty. +StandardInput=tty-fail +StandardOutput=journal +StandardError=journal + +# Log this user with utmp, letting it show up with commands 'w' and 'who'. +UtmpIdentifier=tty7 +UtmpMode=user + +[Install] +Alias=display-manager.service diff --git a/plasma-mobile.service.license b/plasma-mobile.service.license new file mode 100644 index 00000000..0128b00f --- /dev/null +++ b/plasma-mobile.service.license @@ -0,0 +1,2 @@ +Copyright None +SPDX-License-Identifier: CC0-1.0