Score:2

Launch Firefox as a system service on bootup

bg flag

System -> Ubuntu 22.04 LTS

Firefox -> Mozilla Firefox 110.0 (Not using snap firefox)

Use Case -> Launch firefox as a system service on system bootup.

Created a service as follows ->

[Unit]
Description=Firefox service as startup app
BindsTo=graphical.target
PartOf=graphical.target
After=graphical.target

[Service]
Type=simple
User=user1
Group=user1
Environment=DISPLAY=':0'
Environment=XAUTHORITY='/run/user/1000/gdm/Xauthority'
ExecStart=firefox

[Install]
WantedBy=multi-user.target

Verified that the env variable DISPLAY is :0 by default

In normal case, on manually starting the service the firefox is launched as service.

After bootup, the service fails with the following error "localhost.localdomain firefox[878]: Error: cannot open display: :0"

Any idea on how to resolve this ?

shaggy avatar
bg flag
Firefox is not started as root, It is part of a startup application, but even in that, the application fails as firefox is not able to get the display :0
shaggy avatar
bg flag
I want to start the service, after the user1 logs in.
Score:2
iq flag

This error come from the fact that the X server is not ready when the service want to start Firefox, you could add Firefox to startup applications, or if you want to stay systemd service solution you gonna need to add xorg.target and network.target, modify the file like this:

[Unit]
Description=Firefox service as startup app
BindsTo=graphical.target
PartOf=graphical.target
After=graphical.target x
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.