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.
Steam Launcher + KODIbuntu v14

Steam BPM will not work in the Kodi session as it appears Steam BPM (and wmctrl too, which the addon uses to detect whether Steam is in BPM) needs a window manager to run properly, plus by default the addon kills Kodi which causes the session, therefore Kodi, to restart - it needs to be run from a desktop session, either Lubuntu or Openbox, both of which are included in KODIbuntu. You can try running Steam BPM in the Kodi session via SSH to see for yourself the problems it has with the following command:
Code:
DISPLAY=:0 steam -bigpicture

To configure KODIbuntu to boot to a light weight Openbox session, which includes a window manager, that auto starts Kodi either log in via SSH or exit Kodi and log into the Lubuntu desktop session, open a terminal and enter the following:

*Update the system and install wmctrl:
Code:
sudo apt-get update && sudo apt-get dist-upgrade && sudo apt-get install wmctrl

*Install Steam
Code:
wget http://media.steampowered.com/client/installer/steam.deb && sudo dpkg -i steam.deb
If you get errors regarding dependencies you need to run sudo apt-get -f install

*Enable Openbox:
Code:
sudo cp /usr/share/xsessions/hidden/openbox.desktop /usr/share/xsessions/

Set Openbox as the default session:
Code:
sudo dbus-send --system --type=method_call --print-reply --dest=org.freedesktop.Accounts /org/freedesktop/Accounts/User1000 org.freedesktop.Accounts.User.SetXSession string:openbox
If this doesnt set the Openbox session to auto-boot, exit Kodi and at the login screen press 'F9' to open the windowmanager selection box and select Openbox there.

Set the Openbox background to black and Kodi to auto start:
Code:
mkdir -p $HOME/.config/openbox/ && echo "export DISPLAY=:0" >> $HOME/.config/openbox/autostart.sh && echo "xsetroot -solid black &" >> $HOME/.config/openbox/autostart.sh && echo "/usr/bin/kodi &" >> $HOME/.config/openbox/autostart.sh && chmod +x $HOME/.config/openbox/autostart.sh

*To get audio out of both Steam BPM and games you need either PulseAudio or a ~/.asoundrc file with dmix enabled. Both methods resample audio to mix together multiple streams, so they can reduce the quality of audio coming out of Kodi, but of course YMMV - the PulseAudio wiki entry has a good pro's/con's list of both. For me PA was by far the easiest to get working - surround sound/passthrough and bluetooth headset worked with zero config, plus it seems like Steam is designed to use PA. It is possible to start/stop PA as needed to get the best of both worlds. ALSA with dmix is trickier to setup and the config below will give you 2ch sound and probably no mic, but there are many more examples on the net.

-For ALSA:
You need to edit the line with pcm "hw:0,3" to suit your system, use aplay -l to see available devices (in the example 0 is the card, 3 is the device).
Code:
nano ~/.asoundrc
and paste in the following:
Code:
pcm.dsp {
    type plug
    slave.pcm "dmixer"
}

pcm.dsp0 {
    type plug
    slave.pcm "dmixer"
}

pcm.!default {
    type plug
    slave.pcm "dmixer"
}

ctl.!default {
        type hw
        card 0
        }

pcm.dmixer  {
        type dmix
        ipc_key 101
        slave {
            pcm "hw:0,3"
            period_time 0
            period_size 1024
            buffer_size 4096
            rate 44100
        }
        bindings {
            0 0
            1 1
        }
    }

-For PulseAudio:
Installation of PulseAudio is blocked by default on KODIbuntu:
Code:
sudo mv /etc/apt/preferences.d/libasound2-plugins.pref /etc/apt/preferences.d/libasound2-plugins.pref.bak && sudo mv /etc/apt/preferences.d/pulseaudio.pref /etc/apt/preferences.d/pulseaudio.pref.bak
Install PA (I also had to install pulseaudio-module-bluetooth to get a bluetooth headset working):
Code:
sudo apt-get install pulseaudio libasound2-plugins
Disable autospawing of PA:
Code:
sudo nano /etc/pulse/client.conf
and add the following to the bottom of the file:
Code:
autospawn = no
daemon-binary = /bin/true
You need a basic ~/.asoundrc file pointing to the default ALSA device so it's automatically selected when PA isn't running. KODIbuntu should auto generate one (if the wrong device is selected in the ~/.asoundrc file delete it, select the correct output device in Kodi and restart your system - a new asoundrc file should be auto generated), but in case here is a example (You need to edit the card and device, use aplay -l to see available devices):
Code:
pcm.!default {
    type hw
    card 0
    device 7
    }

    ctl.!default {
    type hw
    card 0
    device 7
    }
In Kodi's settings select the default ALSA device (make sure PA isnt running).
Now you need to pre/post steam scripts to start/stop PA and after creating them configure the addon to launch pre/post scripts:
pre-steam.sh
Code:
#!/bin/bash
#change the KILL_KODI_BEFORE_STARTING_PULSEAUDIO= to yes if you want to stop Kodi before starting pulseaudio
#killing Kodi before starting pulseaudio will ensure the steam bpm gui has sound but will reduce the seamlessness of the addon

KILL_KODI_BEFORE_STARTING_PULSEAUDIO=no

if [[ $KILL_KODI_BEFORE_STARTING_PULSEAUDIO = yes ]] ; then
  kill -9 $(pidof kodi.bin)
fi

pulseaudio --start
post-steam.sh
Code:
#!/bin/bash
#change the ALWAYS_KILL_PULSEAUDIO_BEFORE_STARTING_KODI= to yes if you want to stop pulseaudio before starting Kodi
#killing pulseaudio before starting Kodi will ensure that Kodi always uses alsa, but steam may not like having pulseaudio stopped while steam is still running (via 'exit to desktop')

ALWAYS_KILL_PULSEAUDIO_BEFORE_STARTING_KODI=no

if [[ $ALWAYS_KILL_PULSEAUDIO_BEFORE_STARTING_KODI = yes ]] ; then
  pulseaudio -k
fi

#change the KILL_PULSEAUDIO_ONLY_WHEN_COMPLETELY_EXITING_STEAM= to no if you dont want to stop pulseaudio only when completely exiting steam
#if yes Kodi will use pulseaudio when steam is running (via 'exit to desktop')
#change the SECONDS_TO_WAIT= to alter the time to wait after closing BPM to check if steam is still running, 2 seconds is good for my system although this could vary from system to system. This will cause Kodi to take 2 seconds longer to restart.

KILL_PULSEAUDIO_ONLY_WHEN_COMPLETELY_EXITING_STEAM=yes
SECONDS_TO_WAIT=2

if [[ $KILL_PULSEAUDIO_ONLY_WHEN_COMPLETELY_EXITING_STEAM = yes ]] ; then
  sleep $SECONDS_TO_WAIT
  if [[ ! $(pidof steam) ]] ; then
    pulseaudio -k
  fi
fi
Mark both of them as executable:
Code:
chmod +x pre-steam.sh post-steam.sh

*Optional sound config: Set the ALSA system volume:
Code:
alsamixer && sudo alsactl store

*Optional sound config: Enable to option 'Suspend Kodi audio when running Steam' in the Steam Launcher addon - this may help with sound issues.

*To return to the KODIbuntu login screen right click on the desktop and select Log Out, or via SSH/terminal:
Code:
openbox --exit

*Reboot to check that it all works and make the changes take effect. Run the following command to check that openbox and wmctrl are setup properly - If it gives no output everything is ok:
Code:
DISPLAY=:0 wmctrl -l > /dev/null 2>&1 || echo "***wmctrl unable to run***" ; pidof openbox > /dev/null 2>&1 || echo "***openbox not running***"

After restarting install the addon and for automatic updates install the repo too, links in first post. Now the addon will be available under "Programs", follow the prompts to finish setup. First time Steam runs you need a keyboard/mouse enter password to install extra packages for steam and to accept the EULA. Steam may or may not start in BPM on the first run, I dont remember... But I recommend exiting Kodi and starting Steam desktop mode the first time you run it.

*Optional: Updating graphics drivers (nvidia only) - Ubuntu 14.04 uses nvidia-304 by default, which I have found to be a lot slower than newer versions with games. To update to the latest in the trusty repos:
Code:
sudo apt-get install nvidia-331-updates
Newer drivers than the ones in Ubuntu's repo's can be found in this PPA.

*Optional: Ubuntu uses the xpad driver for 360 controllers, although there are others available - xboxdrv and Valve's xpad driver. You can install valves driver from this PPA, it fixes the flashing ring of light issue, plus others:
Code:
sudo apt-add-repository ppa:mdeslaur/steamos
Update and install driver:
Code:
sudo apt-get update && sudo apt-get install steamos-xpad-dkms
Sometimes the steamos driver fails to load and the xpad one is used - I reload the driver on boot to prevent this from happening:
Code:
sudo nano /etc/rc.local && sudo chmod +x /etc/rc.local
Add the following before the 'exit 0':
Code:
(until [ "`lsmod | grep xpad`" ] ; do sleep 1 ; done ; rmmod xpad && modprobe xpad)&
UPDATE: A xpad driver with various additional fixes exists, see here (untested by me).

*Optional: For a better Openbox right click menu that contains entries for Steam, Steam BPM, Kodi, Chromium and others:
Code:
sudo apt-get install menu
nano ~/.config/openbox/menu.xml
And paste in the following:
Code:
<?xml version="1.0" encoding="UTF-8"?>

<openbox_menu xmlns="http://openbox.org/"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://openbox.org/
                file:///usr/share/openbox/menu.xsd">

<menu id="root-menu" label="Openbox 3">
  <item label="Terminal">
    <action name="Execute"><execute>x-terminal-emulator</execute></action>
  </item>
  <item label="Chromium">
    <action name="Execute"><execute>chromium-browser</execute></action>
  </item>
  <item label="PCManFM">
    <action name="Execute"><execute>dbus-launch pcmanfm</execute></action>
  </item>
<item label="Kodi">
    <action name="Execute"><execute>kodi</execute></action>
  </item>
  <item label="Steam">
    <action name="Execute"><execute>steam</execute></action>
  </item>
  <item label="Steam BPM">
    <action name="Execute"><execute>~/.config/openbox/steam-bpm.sh</execute></action>
  </item>
  <!-- This requires the presence of the 'menu' package to work -->
  <menu id="/Debian" />
  <separator />
<item label="Reboot">
    <action name="Execute">
        <prompt>Are you sure you want to reboot?</prompt>
<execute>dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Restart</execute>                                                                                                                                              
    </action>                                                                                                                                                  
</item>                                                                                                                                                        
                                                                                                                                                                
<item label="Shutdown">                                                                                                                                        
    <action name="Execute">                                                                                                                                    
        <prompt>Are you sure you want to shutdown?</prompt>                                                                                                                                              
        <execute>dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop</execute>
    </action>
</item>

<item label="Suspend">                                                        
    <action name="Execute">                                                    
        <prompt>Are you sure you want to suspend?</prompt>                    
        <execute>dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Suspend</execute>
    </action>
</item>

<item label="Log Out">
    <action name="Execute">
      <prompt>Are you sure you want to log-out?</prompt>
        <execute>openbox --exit</execute>
    </action>
  </item>
</menu>

</openbox_menu>
Create a script to launch Steam BPM, it needs a different command if steam is already running:
Code:
nano ~/.config/openbox/steam-bpm.sh && chmod +x ~/.config/openbox/steam-bpm.sh
and paste in the following:
Code:
#!/bin/bash

if [[ $(pidof steam) ]] ; then
    steam steam://open/bigpicture
else
    steam -bigpicture
fi

*Optional: If the Openbox background changes colour after running steam you need to use the program hsetroot to set the wallpaper:
Code:
sudo apt-get install hsetroot && echo "hsetroot -solid "#000000" &" >> ~/.config/openbox/autostart.sh

*Optional: Install the program unclutter, it hides the mouse cursor after X seconds, useful for hiding the mouse in games/emulators.
Code:
sudo apt-get install unclutter && echo "unclutter -root &" >> ~/.config/openbox/autostart.sh

*Optional: If you get tearing in games/fmv you can install a compositing manager, such as compton:
Code:
sudo apt-get install compton && echo "compton --backend glx --paint-on-overlay --glx-no-stencil --vsync opengl-swc & #--unredir-if-possible &" >> ~/.config/openbox/autostart.sh

*Optional: Install bash-completion. Nothing to do with Kodi or Steam, but it makes working in a terminal so much easier.

*Optional: If Steam complains about missing 32-bit libraries the first time you run it, the following command may help: sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib
What a shame it doesn't work in kodi, i guess i have to use windows as HTPC OS instead then Sad
What doesn't work?
Well you just wrote:
Steam BPM will not work in the Kodi session as it appears

so i just figured, it doesn't work ?
and i haven't gotten a solution for my problem yet, so that's why i just figured it doesn't work.
I wrote the same in the xbmcbuntu guide - that's why you need to setup openbox or another window manager.
okay, it's just, i've followed the guide as i wrote earlier, and it still doesn't work Sad
Are you able to log in to openbox?
No, i don't think so.
If i exit Kodi, i can login, but i can't change what to log in to.
Image
Image


so i tried installing openbox, but it seems to already be installed

xbmc@Gotham:~$ sudo apt-get install openbox obconf
[sudo] password for xbmc:
Reading package lists... Done
Building dependency tree
Reading state information... Done
obconf is already the newest version.
obconf set to manually installed.
openbox is already the newest version.
openbox set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Run this and reboot

sudo dbus-send --system --type=method_call --print-reply --dest=org.freedesktop.Accounts /org/freedesktop/Accounts/User1000 org.freedesktop.Accounts.User.SetXSession string:openbox

after reboot run this

DISPLAY=:0 wmctrl -l > /dev/null 2>&1 || echo "***wmctrl unable to run***" ; pidof openbox > /dev/null 2>&1 || echo "***openbox not running***"
xbmc@Gotham:~$ sudo dbus-send --system --type=method_call --print-reply --dest=org.freedesktop.Accounts /org/freedesktop/Accounts/User1000 org.freedesktop.Accounts.User.SetXSession string:openbox
[sudo] password for xbmc:
method return sender=:1.8 -> dest=:1.55 reply_serial=2

*rebooted*

xbmc@Gotham:~$ DISPLAY=:0 wmctrl -l > /dev/null 2>&1 || echo "***wmctrl unable to run***" ; pidof openbox > /dev/null 2>&1 || echo "***openbox not running***"

*rebooted*

Now i can get into steam in BPM, but...

Now i got no sound, and everything is choppy :S
Both Kodi and steam
pidof pulseaudio

?
(2015-02-08, 13:10)teeedubb Wrote: [ -> ]pidof pulseaudio

?

returns nothing.

I did however not use the pulseaudio commands as stated in the guide, i went with alsa because i think i used that.

EDIT.
As you recommended to install a specific nvidia driver i did.
sudo apt-get install nvidia-331-updates

I did, rebooted and it seemed to fix the video choppiness, however not in live TV only in movies and series.
I still got no sound.
Tested steamstreaming, and it seems to be working, choppy, no sound but working.

My IR reciever isn't working now either Sad
If i try to exit kodi, i don't get a login screen, i just go straigt to screensaver :S
Now i feel kinda stupid Tongue

I went settings via the GUI in Kodi, and chose the correct audio output, and now i got sound and everything inside Kodi is working perfectly as before.

Still got no sound in Steam though.
Sorry for all the spamming, now i got sound in both kodi and steam, but incredible choppy video :S


And now all my kodi settings just went away, went back to standard skin all settings lost :S

And i'm back to choppy video, now with sound