Skip to content

Add graphical session support#204

Merged
mtwebster merged 1 commit into
linuxmint:masterfrom
leigh123linux:graphical-session
Jun 1, 2026
Merged

Add graphical session support#204
mtwebster merged 1 commit into
linuxmint:masterfrom
leigh123linux:graphical-session

Conversation

@leigh123linux
Copy link
Copy Markdown
Member

@leigh123linux leigh123linux commented May 27, 2026

session: Add graphical-session.target support

Activate the cross-desktop graphical-session.target and
graphical-session-pre.target when the Cinnamon session starts, so
that systemd-managed services which declare WantedBy= or PartOf=
against those targets are started and stopped in sync with the
session.

graphical-session.target and graphical-session-pre.target have
RefuseManualStart=yes so they cannot be started directly.  Instead
a new cinnamon-session.target is introduced which declares
Wants=graphical-session.target and Wants=graphical-session-pre.target;
systemd then pulls the cross-desktop targets up as dependencies when
cinnamon-session.target is started.

PropagatesStopTo= on cinnamon-session.target ensures that stopping it
on logout propagates to graphical-session.target and
graphical-session-pre.target, which in turn stops any PartOf= services.

The stop is issued at the beginning of CSM_MANAGER_PHASE_END_SESSION,
immediately after the end-session dialog closes, so that systemd-managed
services begin shutting down in parallel with the XSMP end-session
sequence rather than waiting until after it.

Two new helpers are added to csm-util.c:

  csm_util_start_systemd_unit(unit, mode, error)
  csm_util_stop_systemd_unit(unit, mode, error)

Both use g_autoptr and synchronous D-Bus calls via the session bus.

Systemd integration is controlled by a new 'systemd' feature option
(default: auto) and is skipped entirely when libsystemd is not present.

@Fantu
Copy link
Copy Markdown
Contributor

Fantu commented May 27, 2026

Thanks, integrating and manage the cinnamon session from systemd I think will be a good improvement, like other DEs already done.
From a quick look, however, I don't quite understand how it handles any failures, and regarding systemd-oomd (which is the default in Fedora) but I haven't retested yet to see if the problems I saw on Debian at the beginning are still there, is it already set up to have a lower probability of being killed without specific parameters?
And regarding the reboot that was added in Cinnamon in case of excessive RAM consumption, doesn't require modifications for this?

@leigh123linux
Copy link
Copy Markdown
Member Author

I don't quite understand how it handles any failures, and regarding systemd-oomd (which is the default in Fedora) but I haven't retested yet to see if the problems I saw on Debian at the beginning are still there, is it already set up to have a lower probability of being killed without specific parameters?

I haven't tested if it handles failures gracefully , there isn't much to fail.

And regarding the reboot that was added in Cinnamon in case of excessive RAM consumption, doesn't require modifications for this?

Does that restart cinnamon-session-binary?

@Fantu
Copy link
Copy Markdown
Contributor

Fantu commented May 27, 2026

Cinnamon have internal launcher, cinnamon-killer-daemon and probably also other part without a systemd service, these not affect the session part as "another level"?
anyway I suppose that moving also these to systemd service can be better? or I'm wrong?

looking for example gnome-shell have systemd services, for example this: https://salsa.debian.org/gnome-team/gnome-shell/-/blob/debian/latest/data/org.gnome.Shell@.service.in?ref_type=heads
and probably will be an improvement do also in cinnamon, about oom killer there is OOMScoreAdjust=-1000 in gnome shell service, so will be better also for that case
I'm not sure how to reboot in case of excessive memory leaks, memorymax if I'm not wrong kill and wayland session seems can't be restarted, I don't know how is managed

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds integration with the systemd user manager so Cinnamon's session lifecycle drives cinnamon-session.target (which pulls in graphical-session.target / graphical-session-pre.target). New csm-util helpers export the user environment to org.freedesktop.systemd1.Manager, start the target when the session enters the running phase, and stop it on exit. A user unit file and the necessary Meson plumbing are installed alongside.

Changes:

  • New csm-util helpers to export environment and start/stop systemd user units, with a small denylist for session-specific variables.
  • Wire cinnamon-session.target into session startup (main.c, csm-manager.c running phase) and shutdown (csm-manager.c exit phase).
  • Install data/systemd/user/cinnamon-session.target via a new Meson subdir, with systemduserunitdir resolved from libsystemd's pkg-config.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
meson.build Defines systemduserunitdir from libsystemd pkg-config with a prefix-based fallback.
data/meson.build Adds subdir('systemd/user') to include the new unit install.
data/systemd/user/meson.build Installs cinnamon-session.target into the user unit dir.
data/systemd/user/cinnamon-session.target New target with Wants/After/PropagatesStopTo on graphical-session{,-pre}.target.
cinnamon-session/csm-util.h Declares new export/start/stop helpers.
cinnamon-session/csm-util.c Implements env export to systemd SetEnvironment and StartUnit/StopUnit wrappers; adds session-var denylist.
cinnamon-session/main.c Calls the new env export and starts cinnamon-session.target at startup.
cinnamon-session/csm-manager.c Starts the target on entering RUNNING and stops it in do_phase_exit.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cinnamon-session/csm-util.c Outdated
Comment thread cinnamon-session/csm-util.c Outdated
Comment thread cinnamon-session/csm-manager.c Outdated
Comment thread meson.build Outdated
@Fantu
Copy link
Copy Markdown
Contributor

Fantu commented May 29, 2026

this need changes also to Debian packaging part, I not remember for sure if dh-sequence-systemd is not needed also in the old compat 11 but one thing needed for sure is the adding to .install, in d/rules have dh_missing --list-missing, so don't give error for files not installed and not included in d/not-installed.
Confirmed also by log of workflow test:
dh_missing --list-missing

dh_missing: warning: usr/lib/systemd/user/cinnamon-session.target exists in debian/tmp but is not installed to anywhere 
	The following debhelper tools have reported what they installed (with files per package)
	 * dh_install: cinnamon-session (9), cinnamon-session-common (7)
	 * dh_installdocs: cinnamon-session (0), cinnamon-session-common (0)
	 * dh_installman: cinnamon-session (0), cinnamon-session-common (0)
	If the missing files are installed by another tool, please file a bug against it.
	When filing the report, if the tool is not part of debhelper itself, please reference the
	"Logging helpers and dh_missing" section from the "PROGRAMMING" guide for debhelper (10.6.3+).
	  (in the debhelper package: /usr/share/doc/debhelper/PROGRAMMING.md.gz)
	Be sure to test with dpkg-buildpackage -A/-B as the results may vary when only a subset is built
	If the omission is intentional or no other helper can take care of this consider adding the
	paths to debian/not-installed.

after will be useful check the generated packages, that I now see were skipped. need to check the generated .postinst to know if are missed part that may require additional build-dep or add in d/rules.
A good thing would be improve the full debian packaging (in another PR) and migrate from old compat 11 that was also problematic in some cases, including with dh_installsystemd. I'll probably merge improvements done in Debian (about packaging).

@leigh123linux
Copy link
Copy Markdown
Member Author

this need changes also to Debian packaging part, I not remember for sure if dh-sequence-systemd is not needed also in the old compat 11 but one thing needed for sure is the adding to .install, in d/rules have dh_missing --list-missing, so don't give error for files not installed and not included in d/not-installed. Confirmed also by log of workflow test: dh_missing --list-missing

dh_missing: warning: usr/lib/systemd/user/cinnamon-session.target exists in debian/tmp but is not installed to anywhere 
	The following debhelper tools have reported what they installed (with files per package)
	 * dh_install: cinnamon-session (9), cinnamon-session-common (7)
	 * dh_installdocs: cinnamon-session (0), cinnamon-session-common (0)
	 * dh_installman: cinnamon-session (0), cinnamon-session-common (0)
	If the missing files are installed by another tool, please file a bug against it.
	When filing the report, if the tool is not part of debhelper itself, please reference the
	"Logging helpers and dh_missing" section from the "PROGRAMMING" guide for debhelper (10.6.3+).
	  (in the debhelper package: /usr/share/doc/debhelper/PROGRAMMING.md.gz)
	Be sure to test with dpkg-buildpackage -A/-B as the results may vary when only a subset is built
	If the omission is intentional or no other helper can take care of this consider adding the
	paths to debian/not-installed.

after will be useful check the generated packages, that I now see were skipped. need to check the generated .postinst to know if are missed part that may require additional build-dep or add in d/rules. A good thing would be improve the full debian packaging (in another PR) and migrate from old compat 11 that was also problematic in some cases, including with dh_installsystemd. I'll probably merge improvements done in Debian (about packaging).

Missing file added to ‎debian/cinnamon-session.install

@leigh123linux leigh123linux force-pushed the graphical-session branch 2 times, most recently from 1517a45 to 89d7d5c Compare May 29, 2026 22:11
@Fantu
Copy link
Copy Markdown
Contributor

Fantu commented May 29, 2026

you need to add systemd-dev (>= 253-2~) | systemd (<< 253-2~) in build-deps in d/control

@Cobinja
Copy link
Copy Markdown
Member

Cobinja commented May 30, 2026

Can confirm, this makes xdg-desktop-portal work here on Fedora 44.

@Fantu
Copy link
Copy Markdown
Contributor

Fantu commented May 30, 2026

@leigh123linux latest changes seem wrong; from a quick look systemduserunitdir variable is inside systemd.pc from systemd-dev (>= 253-2~) | systemd (<< 253-2~)

@leigh123linux leigh123linux force-pushed the graphical-session branch 3 times, most recently from 6d48017 to 80ce0b0 Compare May 31, 2026 00:04
@mtwebster mtwebster merged commit e01c8c3 into linuxmint:master Jun 1, 2026
3 checks passed
@Fantu
Copy link
Copy Markdown
Contributor

Fantu commented Jun 1, 2026

The issue reported seems still present, the take of the systemduserunitdir variable is wrong after https://github.com/linuxmint/cinnamon-session/compare/89d7d5c3cdd7685a3e0261136fa928f561bc28ba..6111a1738ea426ee0449254eb9fe36e0cfe83108
I don't know how many distro use path different from the default, probably nixos

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

5 participants