Score:0

GUI application fails to launch as a systemd service(daemon) in system session

al flag

I m trying to run a GUI application as a systemd service in system mode but it fails to launch with the error :

GTKTest[236921]: Unable to init server: Could not connect: Connection refused
unknown[236921]: cannot open display:

This is my .service file.

[Unit]
Description=daemon service in user session created for startup ways in linux
PartOf=graphical-session.target
After=graphical-session.target

[Service]
User=vipul.gupta
WorkingDirectory=/home/vipul.gupta/MyWorkspace/GTKdir
ExecStart=/home/vipul.gupta/MyWorkspace/GTKdir/GTKTest
Type=exec
Restart=no

[Install]
WantedBy=graphical-session.target

I m able to start the GUI application in user session but not in system session. Any help if it is even possible?

Score:1
cn flag

You are trying to fly an airplane before starting the engine.

Graphical applications require a display server.

But display servers since about 18.04 do not start at boot, and can no longer be started by root. The display server starts at login, owned by the non-root user. This was done to close a longstanding security issue when the display server ran as root.

Folks who want displays that start at boot as part of a device or server (like for signage controllers) should look into Ubuntu Frame, which is available as a snap.

Folks who want some kind of always-on window for a desktop should simply start the application at login (Startup Applications) instead of boot (systemd service).

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.