systemd: add service file to start Plasma

Used in postmarketOS but probably also useful for others, this service
file can be used to start Plasma Mobile using systemd
This commit is contained in:
Bart Ribbers 2024-08-18 12:55:29 +02:00
parent 358b8f24cb
commit 381bfc3e02
3 changed files with 70 additions and 0 deletions

View file

@ -18,6 +18,8 @@ set(KDE_COMPILERSETTINGS_LEVEL "5.82")
set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON) 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) find_package(ECM ${KF6_MIN_VERSION} REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) 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) kde_configure_git_pre_commit_hook(CHECKS CLANG_FORMAT)
ki18n_install(po) ki18n_install(po)
if (INSTALL_SYSTEMD_SERVICE)
install(FILES
${CMAKE_CURRENT_SOURCE_DIR}/plasma-mobile.service
DESTINATION ${KDE_INSTALL_SYSTEMDUNITDIR}
)
endif()

59
plasma-mobile.service Normal file
View file

@ -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

View file

@ -0,0 +1,2 @@
Copyright None
SPDX-License-Identifier: CC0-1.0