Skip to content

Commit

Permalink
Update Gala Systemd services
Browse files Browse the repository at this point in the history
Sync with what is currently done in GNOME Shell
  • Loading branch information
tintou committed Jun 13, 2023
1 parent 5c170b2 commit 54b17ce
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 8 deletions.
6 changes: 3 additions & 3 deletions data/gala-x11.target → data/gala.target
@@ -1,10 +1,10 @@
[Unit]
Description=Gala on X11
Description=Gala
DefaultDependencies=no

Requisite=gnome-session-initialized.target
PartOf=gnome-session-initialized.target
Before=gnome-session-initialized.target

Requires=gala-x11.service
After=gala-x11.service
Wants=io.elementary.gala@wayland.service
Wants=io.elementary.gala@x11.service
36 changes: 36 additions & 0 deletions data/gala@wayland.service.in
@@ -0,0 +1,36 @@
[Unit]
Description=Gala on Wayland
# On wayland, force a session shutdown
OnFailure=gnome-session-shutdown.target
OnFailureJobMode=replace-irreversibly
CollectMode=inactive-or-failed
RefuseManualStart=on
RefuseManualStop=on

After=gnome-session-manager.target

Requisite=gnome-session-initialized.target
PartOf=gnome-session-initialized.target
Before=gnome-session-initialized.target

#NOTE: ConditionEnvironment works with systemd >= 246
ConditionEnvironment=XDG_SESSION_TYPE=%I

[Service]
Slice=session.slice
Type=notify
ExecStart=@bindir@/gala
# Exit code 1 means we are probably *not* dealing with an extension failure
SuccessExitStatus=1

# unset some environment variables that were set by the compositor and won't work now that the compositor is gone
ExecStopPost=-/bin/sh -c 'test "$SERVICE_RESULT" != "exec-condition" && systemctl --user unset-environment GNOME_SETUP_DISPLAY WAYLAND_DISPLAY DISPLAY XAUTHORITY'

# On wayland we cannot restart
Restart=no
# Kill any stubborn child processes after this long
TimeoutStopSec=5

# Lower down Gala's OOM score to avoid being killed by OOM-killer too early
OOMScoreAdjust=-1000

18 changes: 16 additions & 2 deletions data/gala-x11.service.in → data/gala@x11.service.in
@@ -1,6 +1,6 @@
[Unit]
Description=Gala on X11
# On X11, try to show the fail whale screen
# On X11, try to show the GNOME Session Failed screen
OnFailure=gnome-session-failed.target
OnFailureJobMode=replace
CollectMode=inactive-or-failed
Expand All @@ -13,16 +13,30 @@ Requisite=gnome-session-initialized.target
PartOf=gnome-session-initialized.target
Before=gnome-session-initialized.target

#NOTE: ConditionEnvironment works with systemd >= 246
ConditionEnvironment=XDG_SESSION_TYPE=%I

# Limit startup frequency more than the default
StartLimitIntervalSec=15s
StartLimitBurst=3

[Service]
Slice=session.slice
Type=notify
ExecStart=@bindir@/gala
# Exit code 1 means we are probably *not* dealing with an extension failure
SuccessExitStatus=1

# On X11 we do not need to unset any variables

# On X11 we want to restart on-success (Alt+F2 + r) and on-failure.
Restart=always
# Do not wait before restarting
# Do not wait before restarting the shell
RestartSec=0ms
# Kill any stubborn child processes after this long
TimeoutStopSec=5

# Lower down gnome-shell's OOM score to avoid being killed by OOM-killer too early
OOMScoreAdjust=-1000


15 changes: 12 additions & 3 deletions data/meson.build
Expand Up @@ -50,15 +50,24 @@ if get_option('systemd')
unit_conf.set('bindir', bindir)

configure_file(
input: 'gala-x11.service.in',
output: 'gala-x11.service',
input: 'gala@x11.service.in',
output: 'io.elementary.gala@x11.service',
install: true,
install_dir: systemd_userunitdir,
configuration: unit_conf
)

configure_file(
input: 'gala@wayland.service.in',
output: 'io.elementary.gala@wayland.service',
install: true,
install_dir: systemd_userunitdir,
configuration: unit_conf
)

install_data(
'gala-x11.target',
'gala.target',
rename: 'io.elementary.gala.target',
install_dir: systemd_userunitdir
)
endif

0 comments on commit 54b17ce

Please sign in to comment.