Skip to content

Instantly share code, notes, and snippets.

@ziirish ziirish/
Last active Oct 11, 2018

What would you like to do?
Firefox on Xbian

Firefox on Xbian

These scripts allow you to launch Firefox on XBian.


When you are in Kodi and you want to switch to Firefox, you just have to quit (no shutdown, just quit). Firefox will then start automatically. Now when you want to get back to Kodi, just quit Firefox and Kodi will start back automatically.

How it works?

The script will run in the background and check for the kodi.bin process.

  1. If the kodi.bin process does not exist, it will start Firefox with a minimal X environment
  2. When you close Firefox, it will start Kodi back
  3. Back to 1.


As root, install git, clone this gist, and run the script:

apt install git
git clone firefox_on_debian
cd firefox_on_debian
chmod +x
# rc.local seems to be launched twice, to avoid race condition, we use this little
# tweak with a random sleep and a lockfile
if [ "$DEBUG" == 0 ]
sleep 30
sleep $(($RANDOM%10))
test -e $LOCK && exit 0
touch $LOCK
log() {
if [ "$DEBUG" == "1" ]; then
echo $@
enable_nodm() {
sed -r "s/^NODM_ENABLED=.*$/NODM_ENABLED=true/" /etc/default/nodm
disable_nodm() {
sed -r "s/^NODM_ENABLED=.*$/NODM_ENABLED=false/" /etc/default/nodm
# make sure nodm is not started (because firefox consumes a lot of resources)
/etc/init.d/nodm stop &>/dev/null || true
test -e $LOCKFILE && rm $LOCKFILE
test -e $STOPFILE && rm $STOPFILE
log "Starting service..."
while true
# we do something only when kodi is stopped
pgrep kodi.bin &>/dev/null || {
log "Kodi stopped"
# if we just exited firefox, a $STOPFILE will be created
# we can then stop nodm an restart kodi
test -e $STOPFILE && {
log "Restarting Kodi"
/etc/init.d/nodm stop
pid=$(cat $STOPFILE)
ps $pid &>/dev/null && kill $pid
sleep 2
stop -q xbmc
start -q xbmc
} || {
# kodi is stopped and there is no $STOPFILE so it means we can
# start firefox, unless it is already started
test -e $LOCKFILE || {
log "Starting Firefox"
/etc/init.d/nodm restart
sleep 5
rm $LOCK
apt install matchbox-window-manager xinit xserver-xorg-input-all firefox-esr nodm git
if [ ! -e "" ]
git clone$GISTID.git firefox_on_debian
cd firefox_on_debian
cp /home/xbian/.xsession
cp nodm.default /etc/default/nodm
cp /opt/firefox_launcher
chown xbian: /home/xbian/.xsession
chmod +x /home/xbian/.xsession
chmod +x /opt/firefox_launcher
grep -vE "^/opt/firefox_launcher" /etc/rc.local || sed -ri 's,exit 0,/opt/firefox_launcher \&\n\n&,' /etc/rc.local
# nodm configuration
# Set NODM_ENABLED to something different than 'false' to enable nodm
# User to autologin for
# First vt to try when looking for free VTs
# X session
# Options for nodm itself
# Options for the X server.
# Format: [/usr/bin/<Xserver>] [:<disp>] <Xserver-options>
# The Xserver executable and the display name can be omitted, but should
# be placed in front, if nodm's defaults shall be overridden.
NODM_X_OPTIONS='-nolisten tcp'
# If an X session will run for less than this time in seconds, nodm will wait an
# increasing bit of time before restarting the session.
# Timeout (in seconds) to wait for X to be ready to accept connections. If X is
# not ready before this timeout, it is killed and restarted.
test -e $STOPFILE && rm $STOPFILE || true
#Turn off Power saver and Screen Blanking
xset s off -dpms
#Execute window manager for full screen
matchbox-window-manager -use_titlebar no &
#Execute Browser with options
kill %1
sleep 60 &
echo $pid >$STOPFILE
wait $pid

This comment has been minimized.

Copy link

macaju commented Dec 2, 2017

I'd like to try your solution but first, could you tell me, if you use them, of course, if amazon video and netflix works with this trick and firefox esr version?

Regarding the version it should*:

xbian@xbian:~$ sudo apt show firefox-esr
Package: firefox-esr
Version: 52.4.0esr-1~deb9u1



This comment has been minimized.

Copy link
Owner Author

ziirish commented Dec 6, 2017


You can actually run whatever browser you like. I personally run firefox, but I successfully tried chromium as well.
I did not try amazon video nor netflix since I don't have access to these platforms, but I know youtube is almost unusable so I suppose you may expect the same unusability.


This comment has been minimized.

Copy link

mcgunn84 commented Jan 14, 2018

it will not work, it tried more times on xbian but exit is always to shell. what i make wrong?
thx mcgunn


This comment has been minimized.

Copy link

nicojx commented Aug 26, 2018

Can't get it to work either. Exiting Kodi leads to a shell login. When I try to run matchbox-window-manager manually, it complains that no display is found (also in the Xorg log file). Any ideas?


This comment has been minimized.

Copy link

MyMarvel commented Oct 11, 2018

exit from kodi; enter 'xbian' and 'raspberry' as root login/pass; see a blue screen with list of settings; click 'esc' on your keyboard. You'll see the command line on the bottom of the screen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.