Commit fa40bf29 authored by Guido Gunther's avatar Guido Gunther
Browse files

Merge branch 'systemd' into 'master'

Add systemd user units

See merge request Librem5/phosh!824
parents 707e4298 b2629f41
......@@ -10,6 +10,9 @@ vgdump
/subprojects/libhandy
.vscode/
*.gcov
debian/phosh.service
debian/sm.puri.Phosh.service
debian/sm.puri.Phosh.target
debian/files
debian/*.substvars
debian/*debhelper*
......
gsd_required_components = [
'org.gnome.SettingsDaemon.A11ySettings',
'org.gnome.SettingsDaemon.Color',
'org.gnome.SettingsDaemon.Datetime',
'org.gnome.SettingsDaemon.Housekeeping',
'org.gnome.SettingsDaemon.Keyboard',
'org.gnome.SettingsDaemon.MediaKeys',
'org.gnome.SettingsDaemon.Power',
'org.gnome.SettingsDaemon.PrintNotifications',
'org.gnome.SettingsDaemon.Rfkill',
'org.gnome.SettingsDaemon.ScreensaverProxy',
'org.gnome.SettingsDaemon.Sharing',
'org.gnome.SettingsDaemon.Smartcard',
'org.gnome.SettingsDaemon.Sound',
'org.gnome.SettingsDaemon.UsbProtection',
'org.gnome.SettingsDaemon.Wacom',
'org.gnome.SettingsDaemon.XSettings',
]
desktop_required_components = gsd_required_components + [
'sm.puri.Phosh',
'sm.puri.OSK0',
]
desktopconf = configuration_data()
desktopconf.set('bindir', bindir)
desktopconf.set('libexecdir', libexecdir)
desktopconf.set('required_components', ';'.join(desktop_required_components) + ';')
if get_option('systemd')
desktopconf.set('hidden_under_systemd', 'X-GNOME-HiddenUnderSystemd=true')
endif
desktop_files = [
'sm.puri.Phosh.desktop',
......@@ -47,6 +75,14 @@ runconf.set('libexecdir', libexecdir)
runconf.set('pkgdatadir', pkgdatadir)
runconf.set('version', meson.project_version())
runconf.set('wlrootsdir', join_paths(libexecdir, 'wlroots'))
runconf.set('compositor', get_option('compositor'))
if get_option('systemd')
runconf.set('session_manager', '--systemd')
else
runconf.set('session_manager', '--builtin')
endif
configure_file(
input: 'phosh.in',
output: 'phosh',
......@@ -97,6 +133,8 @@ install_data(
install_dir: schemasdir
)
subdir('systemd')
install_data('phoc.ini', install_dir : pkgdatadir)
install_data('wayland-sessions/phosh.desktop',
install_dir : 'share/wayland-sessions')
......
#!/bin/sh
COMPOSITOR="/usr/bin/phoc"
COMPOSITOR="@compositor@"
PHOC_INI="@pkgdatadir@/phoc.ini"
gnome_session_args()
{
ARGS="--disable-acceleration-check --session=phosh"
# Use builtin session handling until we can rely
# on a newer gnome-session everywhere
if gnome-session --help | grep -qs -e--builtin; then
ARGS="--builtin ${ARGS}"
fi
echo "${ARGS}"
}
GNOME_SESSION=${GNOME_SESSION:-gnome-session}
help()
{
......@@ -60,4 +48,4 @@ fi
# variables from /etc/profile.d (XDG_*)
[ -n "$WLR_BACKENDS" ] || WLR_BACKENDS=drm,libinput
export WLR_BACKENDS
exec "${COMPOSITOR}" -C "${PHOC_INI}" -E "bash -lc 'gnome-session $(gnome_session_args)'"
exec "${COMPOSITOR}" -C "${PHOC_INI}" -E "bash -lc '${GNOME_SESSION} --disable-acceleration-check --session=phosh @session_manager@'"
[GNOME Session]
# Translators: this is the session name, no need to translate it
Name=Phosh
RequiredComponents=sm.puri.Phosh;org.gnome.SettingsDaemon.A11ySettings;org.gnome.SettingsDaemon.Color;org.gnome.SettingsDaemon.Datetime;org.gnome.SettingsDaemon.Housekeeping;org.gnome.SettingsDaemon.Keyboard;org.gnome.SettingsDaemon.Power;org.gnome.SettingsDaemon.PrintNotifications;org.gnome.SettingsDaemon.Rfkill;org.gnome.SettingsDaemon.ScreensaverProxy;org.gnome.SettingsDaemon.Sharing;org.gnome.SettingsDaemon.Smartcard;org.gnome.SettingsDaemon.Sound;sm.puri.OSK0;
RequiredComponents=@required_components@
......@@ -10,3 +10,4 @@ X-GNOME-Autostart-Phase=DisplayServer
X-GNOME-Provides=panel;windowmanager;
X-GNOME-Autostart-Notify=true
X-GNOME-AutoRestart=true
@hidden_under_systemd@
if get_option('systemd')
gsd_wants = ''
foreach component : gsd_required_components
gsd_wants += 'Wants=' + component + '.target\n'
endforeach
session_dropins = [
'gnome-session@phosh.target.d',
]
sessionconf = configuration_data()
sessionconf.set('gsd_wants', gsd_wants)
foreach session_dropin : session_dropins
configure_file(
input: 'phosh.session.conf.in',
output: 'session.conf',
install_dir: join_paths(systemduserdir, session_dropin),
configuration: sessionconf,
install: true
)
endforeach
serviceconf = configuration_data()
serviceconf.set('libexecdir', libexecdir)
configure_file(
input: 'sm.puri.Phosh.service.in',
output: 'sm.puri.Phosh.service',
install_dir: systemduserdir,
configuration: serviceconf,
install: true
)
install_data('sm.puri.Phosh.target', install_dir: systemduserdir)
endif
[Unit]
@gsd_wants@
Requires=sm.puri.Phosh.target
# This is a systemd user unit intended to be started with gnome-session.
[Unit]
Description=Phosh, a shell for mobile phones
Documentation=https://source.puri.sm/Librem5/phosh
After=gnome-session-manager.target
Requisite=gnome-session-initialized.target
PartOf=gnome-session-initialized.target
Before=gnome-session-initialized.target
StartLimitIntervalSec=15s
StartLimitBurst=3
OnFailure=gnome-session-shutdown.target
OnFailureJobMode=replace-irreversibly
CollectMode=inactive-or-failed
RefuseManualStart=on
RefuseManualStop=on
[Service]
ExecStart=@libexecdir@/phosh
Restart=on-failure
RestartSec=0ms
Slice=session.slice
[Unit]
Description=Phosh
DefaultDependencies=no
Requisite=gnome-session-initialized.target
PartOf=gnome-session-initialized.target
Before=gnome-session-initialized.target
Requires=sm.puri.Phosh.service
After=sm.puri.Phosh.service
debian/phosh.service
debian/sm.puri.Phosh.service
debian/sm.puri.Phosh.target
usr/bin/phosh
usr/lib/systemd/user/
usr/libexec/phosh
usr/share/locale
usr/share/wayland-sessions/phosh.desktop
......
......@@ -2,7 +2,7 @@
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
CONFIGURE_OPTS=-Dphoc_tests=disabled
CONFIGURE_OPTS=-Dphoc_tests=disabled -Dsystemd=true
ifeq ($(filter nodoc,$(DEB_BUILD_PROFILES)),)
CONFIGURE_OPTS+=-Dgtk_doc=true
......@@ -24,7 +24,8 @@ ifeq ($(filter nodoc,$(DEB_BUILD_PROFILES)),)
endif
override_dh_installsystemd:
rm -f debian/phosh.service ; cp data/phosh.service debian/phosh.service
rm -f debian/phosh.service
cp data/phosh.service debian/phosh.service
dh_installsystemd --no-start --no-enable --no-restart-on-upgrade --no-restart-after-upgrade
override_dh_auto_test:
......
......@@ -15,6 +15,8 @@ desktopdir = join_paths(datadir, 'applications')
sessiondir = join_paths(datadir, 'gnome-session')
pkgdatadir = join_paths(datadir, meson.project_name())
pkglibdir = join_paths(libdir, meson.project_name())
systemddir = join_paths(prefix, 'lib/systemd')
systemduserdir = join_paths(systemddir, 'user')
config_h = configuration_data()
config_h.set_quoted('GETTEXT_PACKAGE', 'phosh')
......@@ -162,6 +164,8 @@ summary = [
'',
' Tests: @0@'.format(get_option('tests')),
' Phoc Tests: @0@'.format(run_phoc_tests),
' Compositor: @0@'.format(get_option('compositor')),
' Systemd: @0@'.format(get_option('systemd')),
'Documentation: @0@'.format(get_option('gtk_doc')),
'-----------',
]
......
......@@ -9,3 +9,11 @@ option('phoc_tests',
option('gtk_doc',
type: 'boolean', value: false,
description: 'Whether to generate the API reference for Handy')
option('systemd',
type: 'boolean', value: false,
description: 'Whether to generate systemd user units')
option('compositor',
type: 'string', value: '/usr/bin/phoc',
description: 'Path to the Phoc compositor for use in the launcher script')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment