Score:0

GUI application fails to launch as a systemd service(daemon) in user mode

al flag

I have created a systemd service to run a Gui application in user mode.

This is my .service file located at ~/.config/systemd/user.

[Unit]
Description=daemon service in user session created for startup ways in linux

[Service]
WorkingDirectory=/home/vipul.gupta/MyWorkspace
ExecStart=/home/vipul.gupta/MyWorkspace/GTKSource
Type=simple

[Install]
WantedBy=graphical-session.target

The Gui window appear if I use, Environment=DISPLAY=:0 but I dont want to use it, as the service is running in user session, so it has access to display.

These are the logs:

Started daemon service in user session created for startup ways in linux
GTKTest[201583]: Unable to init server: Could not connect: Connection refused
GTKTest[201583]: cannot open display:
systemd[72001]: tallyuserdaemon.service: Main process exited, code=exited, status=1/FAILURE
systemd[72001]: tallyuserdaemon.service: Failed with result 'exit-code'.

I m not able to figure out the reason.

muru avatar
us flag
"as the service is running in user session, so it has access to display", access, yes, but how will it know where that display is? You could also have multiple X or Wayland sessions going on too. That's why you need to specify where. Put it in the environment, make it read it from a file, whatever.
Vipul Gupta avatar
al flag
@muru oh,ok. should I be able to run GUI application in the system session in the same way?
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.