I would like to launch a GUI app (Firefox, for example) every time my Linux OS boots in my Chromebook. The Linux OS boots whenever the first Linux app is launched. I've tried a number of techniques, but can't make any of them work.
1. .desktop in ~/.config/autostart
or in /etc/xdg/autostart
This fails to launch Firefox on boot even though the firefox.desktop file itself launches Firefox with no problem. Would I need permissions set in some special way, or something else, for this to work right?
2. Launch it via .bashrc
This launches Firefox when the terminal is launched, not necessarily when Crostini boots. If I boot Crostini by opening a different Linux app than the terminal (like Chromium for example), then .bashrc
doesn't get called.
3. Launch it via /etc/profile.d
Same problem as .bashrc
. It only launches Firefox when the terminal starts up, not when Crostini boots per-se.
4. systemd unit file launching a bash script that launches Firefox
This (so far) fails to launch Firefox on startup even though it can launch Firefox with no problem when I run the service manually. Here is the code for my service file, which is placed in /etc/systemd/system/
with chmod 640
perms:
[Unit]
Description=Firefox launcher
[Service]
Type=forking
Environment="Displat=:0"
Environment="XAUTHORITY=~/.Xauthority"
ExecStart=/mypath/fflauncher.sh
[Install]
WantedBy=graphical.target
And here is the code for fflauncher.sh
, which has chmod +x
perms:
#!/bin/bash
COUNTER=0
while [ 1 ]
do
if [ -S /tmp/.X11-unix/X0 ]
then
xhost local:
firefox &
exit 0
fi
((++COUNTER))
if [ $COUNTER -gt 20 ]
then
exit 1
fi
sleep 0.5
done
Nevertheless, Firefox does not launch on startup. But interestingly, the bash script itself is actually called on startup using this method. The Firefox app just doesn't run.
Does anyone have any suggestions for how I can get this to work?