Kodi Community Forum

Full Version: [RELEASE] Steam Launcher - Start Steam Big Picture Mode from within Kodi
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
You can shutdown steam with

steam -shutdown

I don't use emulators on Linux but in windows I forcibly kill the emulator process (because some emulators use alt f4, some ESC etc), so something like

killall -9 emulator_name

I have one entry for each emulator I use in a script that's mapped to a remote button. Only thing is that any config changes arent saved, so when you're configuring the emulator you need to exit it properly.
Yeah! Finally I wrote this script that works PERFECTLY!!!!

First of all follow this instructions for Kodibuntu (I don't apply the PulseAudio because I use ALSA for all): http://forum.kodi.tv/showthread.php?tid=...pid1919154

Then put the following in a terminal:

sudo nano $HOME/.config/openbox/start.sh

And paste this code:

Quote:#!/bin/bash
while [ 1 ] # do forever
do
steampid=$(pidof steam)
kodipid=$(pidof kodi.bin)
firefoxpid=$(pidof firefox)
if [ -z $kodipid ]; then # checks if kodi is running if not..
if [ -z $steampid ]; then # checks if steam is running if not...
if [ -z $firefoxpid ]; then # checks if firefox is running if not...
/usr/bin/kodi
else # If Firefox is running, then....
echo ""
fi
else # If Steam is running, then....
echo ""
fi
sleep 1
else # If Kodi is running, then....
echo ""
fi
sleep 1
done
done &

Save it (CTRL+X and then ENTER) and now in a terminal again put:

sudo nano $HOME/.config/openbox/autostart.sh

change the line /usr/bin/kodi & with /home/YOURUSERNAME/.config/openbox/start.sh & ; save it and restart.

EDIT: I wrote it with 3 variables (Kodi, Firefox and Steam). If you don't use Firefox, please, use this script instead the previous:

Quote:#!/bin/bash
while [ 1 ] # do forever
do
steampid=$(pidof steam)
kodipid=$(pidof kodi.bin)
firefoxpid=$(pidof firefox)
if [ -z $kodipid ]; then # checks if kodi is running if not..
if [ -z $steampid ]; then # checks if steam is running if not...
/usr/bin/kodi
else # If Steam is running, then....
echo ""
fi
sleep 1
else # If Kodi is running, then....
echo ""
fi
sleep 1
done
done &

Make executable the script with sudo chmod +x $HOME/.config/openbox/start.sh

HOW WORKS THE SCRIPT?

Ok. The complete script (3 variables) works like:

- If Kodi is running, nothing happens.
- If Kodi isn't running BUT Steam yes, nothing happens (With Steam launcher and the "quit kodi" option enabled, only Steam is runnning).
- If Kodi isn't running, Steam isn't running BUT Firefox yes, nothing happens (you only have running Firefox).
- If Kodi isn't running, Steam isn't running and Firefox isn't running, Kodi starts again (very useful for ocasionally Kodi crashes).

EDIT2: For launch Firefox or another browser I use this script with Executor (or Advanced Launcher):

Quote:#!/bin/bash
killall -9 kodi.bin
firefox
killall -9 firefox
/usr/bin/kodi

Regards.
(2015-03-03, 00:07)teeedubb Wrote: [ -> ]You can shutdown steam with

steam -shutdown

I don't use emulators on Linux but in windows I forcibly kill the emulator process (because some emulators use alt f4, some ESC etc), so something like

killall -9 emulator_name

I have one entry for each emulator I use in a script that's mapped to a remote button. Only thing is that any config changes arent saved, so when you're configuring the emulator you need to exit it properly.

I didn't know I could map commands to irexec. Nice. The emulation is also being streamed, so I can't kill the emulator directly. Alt-F4 works in steam (meaning it kills steam), but not while the emulator is active (seemingly only F4 gets accepted. Alt-F4 works when I use my keyboard, but not when using irexec (again, it does work while steam is active). I'm going to try steam -shutdown, although that will keep anything running on my game pc upstairs running, so it's not perfect.
Is there a way to launch steam big picture mode directly into game library view? (Windows 8.1) That would be awesome Smile
(2013-12-29, 21:16)teeedubb Wrote: [ -> ]
(2013-12-29, 04:39)staticn0de Wrote: [ -> ]Hi all,

Thanks for the great addon - but I can't get it to work.

I have downloaded and installed 0.9.2 and installed the wmctrl program from the repo.

I have running XBMC 12.3 on Ubuntu 12.04.3 with Nvidia 331.20 Drivers installed.

XBMC is being run as an xsession so it launches automatically when I start the computer without loading the desktop.

If I run the addon from Programs > Steam, the screen flashes blank, I see the X symbol in the middle of the screen and then it starts to launch XBMC again. That does not work out though. I have a blank screen with the cursor.

If I run top, I can see that both xbmc.bin and steam are running processes but neither are up on my screen.

I was considering that it may be because I am running XBMC as an xsession.

Any advice?

EDIT: Seems that the xsession has something to do with it. If I run xbmc from the desktop, I can use the addon just fine. When it runs from the xsession, buy default it uses xbmc-standalone not xbmc. I made my own xsession to use xbmc but that does not work either. It opens fine but once I run the addon, it closes xbmc and drops me back to the login screen.

The script kills xbmc so this causes problems with a xbmc xsession. I run XBMC as a xsession too and launch a openbox session just for steam. This is a straight copy/paste from my system so it may need to be configured for yours and you can remove extras for loading chromium, mythtv, pulseaudio etc...You need the program mingetty installed for this to work:

This will most likely not work with xbmcbuntu/etc with out some additional steps (Im guessing disabling lightdm + xbmc init scripts, but this will depend on the distro) and the information below is geared towards a ubuntu minimal install.

/etc/init/tty2.conf
Code:
/etc/init/tty2.conf
# tty2 - getty
#
# This service maintains a getty on tty2 from the point the system is
# started until it is shut down again.

start on runlevel [23]
stop on runlevel [!23]

respawn
exec /sbin/mingetty --autologin=xbmc tty2

~/.bash_profile
Code:
while [ -f /tmp/xbmc.disabled ]; do
  echo /tmp/xbmc.disabled present, exiting...
  echo ...................................
  sleep 1
done

###load steam
if  [[ -f /tmp/steam.load ]] && [[ ! $DISPLAY && ! -e /tmp/.X11-unix/X0 ]] && (( EUID )); then
  exec xinit -- /usr/bin/X -nolisten tcp vt7 :0
  exit

###load steam-os
elif  [[ -f /tmp/steam-os.load ]] && [[ ! $DISPLAY && ! -e /tmp/.X11-unix/X0 ]] && (( EUID )); then
  exec xinit -- /usr/bin/X -nolisten tcp vt7 :0
  exit

###load chromium
elif [[ -f /tmp/chromium.load ]] && [[ ! $DISPLAY && ! -e /tmp/.X11-unix/X0 ]] && (( EUID )); then
  exec xinit -- /usr/bin/X -nolisten tcp vt7 :0
  exit

###load openbox
elif [[ -f /tmp/openbox.load ]] && [[ ! $DISPLAY && ! -e /tmp/.X11-unix/X0 ]] && (( EUID )); then
  exec xinit -- /usr/bin/X -nolisten tcp vt7 :0
  exit

###myth-frontend
elif [[ -f /tmp/mythtv.load ]] && [[ ! $DISPLAY && ! -e /tmp/.X11-unix/X0 ]] && (( EUID )); then
  pulseaudio -k &
  exec xinit -- /usr/bin/X -nolisten tcp vt7 :0
  exit
fi

##########################
###load xbmc, must be last
if [[ ! $DISPLAY && ! -e /tmp/.X11-unix/X0 ]] && (( EUID )); then
  pulseaudio -k &
  exec xinit -- /usr/bin/X -nolisten tcp vt7 -nocursor :0
  exit
fi

~/.xinitrc
Code:
#!/bin/sh

if [ -f /tmp/steam.load ]; then
   exec /usr/bin/openbox-session

elif [ -f /tmp/steam-os.load ]; then
  exec /usr/bin/.scripts/steamos-session-xbmc

elif [ -f /tmp/openbox.load ]; then
  exec /usr/bin/openbox-session

elif [ -f /tmp/chromium.load ]; then
  exec /usr/bin/openbox-session

elif [ -f /tmp/mythtv.load ]; then
   exec /usr/bin/mythfrontend
else
  exec ck-launch-session /usr/bin/xbmc
fi

exit

Underneath the line that has Linux) in the file ~/.xbmc/userdata/addon_data/script.steam.launcher/scripts/steam-launch.sh paste in the following:
Code:
if [[ ! -f /tmp/steam*.load ]]; then
        if [[ $3 = 1 ]]; then
            touch /tmp/steam-os.load
        elif [[ $3 = 0 ]]; then
            touch /tmp/steam.load
        fi
     kill -9 $(pidof xbmc.bin)
fi
The above will allow you to choose between a steam-os session or a openbox session with the 'Ask whether to quit XBMC' option. See here for using parts of steam os in ubuntu.

An example of my Openbox autostart file:
~/.config/openbox/autostart.sh
Code:
#!/bin/sh
export DISPLAY=:0
xsetroot -solid black &
hsetroot -solid "#000000" &
unclutter -root &

  if [ -f /tmp/steam.load ]; then
    pulseaudio --start
    compton --backend glx --paint-on-overlay --glx-no-stencil --vsync opengl-swc --unredir-if-possible &
    (sleep 5 && ~/.xbmc/userdata/addon_data/script.steam.launcher/scripts/steam-launch.sh "/usr/bin/steeeeam" "/usr/bin/xbmc")&
    sleep 1
    /usr/bin/steam -bigpicture
    rm -rf /tmp/*.load
    pulseaudio -k
    /usr/bin/.scripts/ob-exit.sh
  fi

  if [ -f /tmp/chromium.load ]; then
    pulseaudio --start
    compton --backend glx --paint-on-overlay --glx-no-stencil --vsync opengl-swc --unredir-if-possible &
    sleep 1
    (sleep 5 && xdotool key F11)&
    /usr/bin/chromium-browser --start-maximized
    rm -rf /tmp/*.load
    pulseaudio -k
    /usr/bin/.scripts/ob-exit.sh
  fi

  if [ -f /tmp/emulator.load ]; then
    if [ -f /tmp/pulseaudio.load ]; then
            pulseaudio --start
    else
            pulseaudio -k
    fi

  fi

I use a script to close openbox and remove all /tmp/*.load files so the xbmc session loads again when openbox is exited. It can go anywhere, but you need to update above with its location:
Code:
#!/bin/bash
if [[  $(pidof steam) ]]; then
        steam -shutdown
        sleep 5
fi

for FILE in /tmp/*.load; do rm -f ${FILE}; done &&

killall xinit


So when the addon is run a openbox session for steam is run. The openbox session stays open as long as steam is open, whether it's BPM or DM, and will stay open until you exit steam. Exiting steam to desktop will run xbmc in the openbox session. See the first post for some tips on Openbox.

More info and wiki links here.

(2013-12-29, 06:36)snyderman32x33 Wrote: [ -> ]do we need to delete scripts if we're using your repo for updates?

Yeah, you can do so from the addon settings, although the old version will still work. Only the scripts in the addon_install directory are updated with updates and the scripts in the addon_data directory are run by the addon. Deleting the addon_data scripts will make the addon copy them from the addon_install location on next run.

Hello teeedubb, are the instructions from this post you wrote back in 2013 still good? I'm running Kodi in an xsession (Ubuntu 14.04) using ALSA. Thanks a lot for this great addon!
Yeah it should, I's still running the same config - though you'll probably need to adapt it for your system (eg the username in /etc/init/tty2.conf)
I am sure I am missing something easy, but here goes.
using newest KODI and windows 8.1 using an xbox wireless controller, I launch steam and steam big picture comes up. but then after a few seconds it looses focus to a program running in my taskbar (the program is "lights out" for my windows home server). This is an issue because I then have to plug in a keyboard and alt tab to steam.

I think this happens because when I launch kodi, it uses kodi as the shell. when I launch steam it takes a few seconds for all the extra programs to load up.

Is there a setting I could use to delay the steam launch for 5-10 seconds or so after the windows shell launches?

thanks for your help.
Make a pre steam script that quits kodi then sleeps for x seconds.
Thank you, I will do that.... Ill report back later tonight.
Thanks for all your work.
(2015-03-13, 05:00)teeedubb Wrote: [ -> ]Yeah it should, I's still running the same config - though you'll probably need to adapt it for your system (eg the username in /etc/init/tty2.conf)
Hi, I'm using the upstart script to start Kodi in standalone mode (from the Kodi wiki) on a minimal Ubuntu 14.04 install. Do I need to remove that before I can use your scripts? Or do I need to follow the SteamOS + Ubuntu instructions? The amount of possibilities are a bit overwhelming for a not-hardcore Linux user Blush

To clarify, I'm running an old Asrock Ion 330 box (so less bloat the better) and only planning to run Kodi and Steam on it. i use SSH for the occasional admin tasks.
You could change that upstart script to launch openbox instead of kodi, then start kodi via openbox's autostart file.
Running your 3.1.1 script with Kodi 14.2rc1. Your script does not close Kodi, it seems to minimize it even when told to quit. A second after Steam loads it seems to freeze up, the BPM video stopping, before it goes to Steam's main window except it has no audio and you can see Kodi minimized in the bottom left corner.

I am running Kodi as the shell using Launcher4Kodi, I told it to disable focus as before it would pull focus away from Steam and give it to Kodi, even though Kodi SHOULD be closing and not minimizing.

The issue does not seem to be Launcher4Kodi or Steam, but your script failing to close Kodi after launching the script. When I exit Steam it will go back to Kodi, like it should, except it never closed like I asked.
Read the 'issues' section in the first post of this thread.
Since I had to go through the trouble of plugging in a mouse and keyboard and starting up explorer just to get your log I went ahead and tried one more thing, COMPLETELY removing Any trace your script had on my system and reinstalled it. Now it works fine. I should have known better than to think Kodi could handle things on its own when I "removed" your script.