Home > OS >  Start fullscreen firefox from linux service
Start fullscreen firefox from linux service

Time:11-20

I would like to start a fullscreen firefox instance at boot. I created two services:

Service starting firefox:

[Unit]
Description=Service running firefox
After=network.target

[Service]
Type=simple
User=me
Environment="DISPLAY=:0"
ExecStart=/usr/bin/firefox --new-window /usr/local/src/index.html
Restart=on-failure
RestartSec=1
TimeoutSec=60
RuntimeMaxSec=infinity

[Install]
WantedBy=multi-user.target

Then I have a service sending the F11 command to enable fullscreen. (I didn't manage to make everything from a single service)

[Unit]
Description=Service for firefox fullscreen
After=network.target start_firefox
BindsTo=start_firefox

[Service]
Type=simple
User=me
Environment="DISPLAY=:0"
ExecStart=/usr/bin/xdotool search --sync --onlyvisible --class "Firefox" windowactivate key F11
Restart=on-failure
RestartSec=1
TimeoutSec=60
RuntimeMaxSec=infinity

[Install]
WantedBy=multi-user.target

However, it doesn't work. The logs I get from the second service are:

systemd[1]: Started Service for firefox fullscreen
xdotool[6268]: Error: Can't open display: (null)
xdotool[6268]: Failed creating new xdo instance
systemd[1]: firefox_fullscreen.service: Main process exited, code=exited, status=1/FAILURE
systemd[1]: firefox_fullscreen.service: Failed with result 'exit-code'.
systemd[1]: firefox_fullscreen.service: Service hold-off time over, scheduling restart.
systemd[1]: firefox_fullscreen.service: Scheduled restart job, restart counter is at 4.
systemd[1]: Stopped Service for firefox fullscreen

What am I doing wrong?

I'm trying to run this through ssh on a board using ubuntu and connected to a screen.

CodePudding user response:

Just use "firefox --kiosk" and it starts in full screen by itself

  • Related