[systemd-devel] Execute a script/program at the start of a graphical session

Gerion Entrup entrup at sra.uni-hannover.de
Thu May 12 11:31:41 UTC 2022


Hi,

in our work we have a setup where a PC is used by many different users
under a variety of desktop environments.
The PC has several monitors and we use a xrandr script to setup them
correctly (independent of the graphical session) as soon as an user
starts an arbitrary graphical session.

We recently switched from Ubuntu (LightDM) to Debian (GDM, both with
systemd). On Ubuntu, the login manager started a user target
"graphical-session.target" and we crafted a service that executes our
script and was "wanted" by this target.

On Debian, no such "graphical-session.target" exists, only a
"default.target". If we put our service as "wanted by" the
"default.target", it is not always executed when the graphical session
is up, so xrandr does not work and so on.

My question is: logind should know when an (arbitrary) graphical
session is up. Is there a possibility to trigger systemd to execute
some script under the current user when logind detects a new graphical
session? This way, it would not depend on the login manager and desktop
environment.

The broader question is: Is there a way to start a script at the
beginning of a graphical session (but after X or the Wayland compositor
have started) which is independent of the login manager or desktop
environment?

Best,
Gerion
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5502 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20220512/db950427/attachment.bin>


More information about the systemd-devel mailing list