Score:0

Accessing DISPLAY environment variable in systemd service file

al flag

I have a systemd service in user session. When the user logs in, this DISPLAY is set (by the Xserver) and I want to access the DISPLAY environment in the service file.

This is my service unit.

[Service]
ExecStart=/home/vipul.gupta/MyWorkspace/GTKdir/GTKTest
Environment=?
Type=simple

I want to provide this Environment value. I know that I can hardcode this value as Environment=Display=:10.0

,but I want the service unit to access the DISPLAY variable set for that user session.

Note: DISPLAY is not accessible by the systemd as it is not available in the output of the command : systemctl --user show-environment. Hence the question.

user535733 avatar
cn flag
This looks like a design problem. There are several approaches. The simplest is to use Startup Applications instead of a user service. Another approach is to use two applications in a client-server relationship communicating via Dbus.
Vipul Gupta avatar
al flag
Is there a reason why systemd is not accessing the DISPLAY. Is it something that I might have missed that is causing the systemd to not access the DISPLAY?
user535733 avatar
cn flag
Unable to reproduce the issue: On my Ubuntu Desktop 23.04 test system (stock install), systemd **does** see the DISPLAY environment variable, and happily outputs it using `systemctl --user show-environment | grep DISPLAY`
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.