Score:0

How to run Firefox from systemd service?

au flag

Can’t figure out how to fix /system.slice/unsplashpi.service is not a snap cgroup error.

$ cat /etc/systemd/system/unsplashpi.service
[Unit]
Description=unsplashpi
After=multi-user.target

[Service]
Type=forking
ExecStart=/home/ubuntu/run.sh
User=ubuntu
WorkingDirectory=/home/ubuntu

[Install]
WantedBy=multi-user.target
EOF
$ cat /home/ubuntu/run.sh
#! /bin/bash

startx /home/ubuntu/unsplashpi.sh &> /home/ubuntu/startx.log &
$ cat /home/ubuntu/unsplashpi.sh
#! /bin/bash

DISPLAY=:0 firefox --kiosk --private-window --width 1080 --height 1920 "https://askubuntu.com" &

while :
do
  sleep 60
done
$ cat /home/ubuntu/startx.log
…
/system.slice/unsplashpi.service is not a snap cgroup
sunknudsen avatar
au flag
Running `sudo loginctl enable-linger ubuntu` solves issue but not sure it’s an elegant solution.
user535733 avatar
cn flag
Are you open to using the `~/.config/autostart` directory instead of a systemd service?
Raffa avatar
jp flag
Just wondering, why take the long route so the service runs under a normal user at the end? ... Won't a [user service](https://askubuntu.com/a/1475900) be a better fit for this task? ... Also It's not quiet obvious to me why `linger` would be needed in that situation, please see what's going on under the hood in a user login session regarding cgroups/scopes ...etc. https://askubuntu.com/a/1471031 which is rather too technical but might help.
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.