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.
sweet, just added the repo, updated immediately
Steam, Linux and Lirc
Steam BPM running on Linux doesnt detect remote keypresses via Lirc (although if you are not using Lirc and only the in-kernel drivers Steam will probably respond). One way around this is to use irxevent, which is a program "to send button clicks and key presses to X applications triggered by a LIRC driven remote control." Once this is configured, when irxevent is running your remote will send key key presses as well the Lirc keypresses (this can cause problems with xbmc, see below).

First off create a lirc config file:
nano ~/.lircrc
And paste in something like the following:
Code:
###irxevent
begin
prog = irxevent
button = KEY_UP
repeat = 1
config = Key Up CurrentWindow
end

begin
prog = irxevent
button = KEY_DOWN
repeat = 1
config = Key Down CurrentWindow
end

begin
prog = irxevent
button = KEY_LEFT
repeat = 1
config = Key Left CurrentWindow
end

begin
prog = irxevent
button = KEY_RIGHT
repeat = 1
config = Key Right CurrentWindow
end

begin
prog = irxevent
button = KEY_PLAY
config = Key Return CurrentWindow
repeat = 1
end

begin
prog = irxevent
button = KEY_ENTER
config = Key Return CurrentWindow
repeat = 1
end

To find out which remote keypress corresponds to 'button =' use the program irw. For a list of keysymbols to use for 'config =' see here and here.

As mentioned above running irxevent with programs that use Lirc input (eg xbmc) will result in double keypresses. I work around this by modifying steam-launch.sh to only run irxevent when Steam BPM is running:

Quote:.....
echo Kill XBMC
kill -9 $(pidof xbmc.bin) #There are better ways of doing this but this is the most consistent
echo "Shutdown XBMC"

if [ ! $(pidof irxevent) ]
then
irxevent &
fi


echo Is Steam running?
.....

Quote:.....
while [ $(wmctrl -l | grep "$STEAM_WIN_ID") ]; do
echo "Steam BPM running!"
sleep 1
done

if [ $(pidof irxevent) ]
then
kill -9 $(pidof irxevent)
fi


if [ $(pidof xbmc.bin) ] ; then
.....

After this you should be able to control Steam BPM, along with other programs such as Chrome and games/emulators with your remote control.

UPDATE: After having issue with irxevent not launching with chromium Ive changed how I run it. I run this script as my user from /etc/rc.local and it runs in the background. With this script there is no need to edit steam-launch.sh to run irxevent.
Code:
#!/bin/bash
export DISPLAY=:0

while true; do
        if [[ $(pidof xbmc.bin) ]]; then
                if [[ $(pidof irxevent) ]]; then
                        kill $(pidof irxevent)
                        echo Killing irxevent, xbmc running
                else
                        echo Xbmc running, irxevent not running.
                fi
        else
                if [[ ! $(pidof irxevent) ]]; then
                        irxevent -d /home/xbmc/.lircrc
                        echo Starting irxevent, xbmc + irxevnet not running.
                else
                        echo irxevent running, xbmc not running.
                fi

        fi
sleep 1
done
Update in first post, 0.9.2. Scripts have been updated so deleting the scripts is addon_data is recommended.

Code:
0.9.2
Changes to default.py
Check if script files exist before deleteing, prevents a error.
Updated Steam-Lanuch-AHK.exe - Additional checks incase BPM is already active + for when BPM is restarted for forced/beta updates, script will check for 5 seconds for BPM or the steam update window to show up again, if it does it kills xbmc and waits for BPM to be closed. Also removed all hard timeouts and now everything happens on window events, eg XBMC is killed when either the BPM or steam update window appear.
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, by 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.
(2013-12-29, 02:06)teeedubb Wrote: [ -> ]Update in first post, 0.9.2. Scripts have been updated so deleting the scripts is addon_data is recommended.

Code:
0.9.2
Changes to default.py
Check if script files exist before deleteing, prevents a error.
Updated Steam-Lanuch-AHK.exe - Additional checks incase BPM is already active + for when BPM is restarted for forced/beta updates, script will check for 5 seconds for BPM or the steam update window to show up again, if it does it kills xbmc and waits for BPM to be closed. Also removed all hard timeouts and now everything happens on window events, eg XBMC is killed when either the BPM or steam update window appear.

do we need to delete scripts if we're using your repo for updates?
(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.
Doh!, I included a older broken ahk.exe in 0.9.2, so a new version:

Code:
0.9.3
Fixed wrong AHK.exe.
Added busy dialog when script is run.
Updated docs.

Windows users: Deleting the scripts in addon_data dir is recommended with this update.
Thanks for this add on, it works great. Is there a way to add it to the main menu in xbmc instead of having to go into programs first??
Depends on what skin I guess? Most can display addons on the home screen.
Hi teeedubb,

Thanks for the terrific plugin. It's working almost flawlessly for me.

I have Windows 8.1 and I've configured a user to auto-login and was launching XBMC from the Windows startup menu. XBMC started out of focus for a few seconds, but would regain focus and be fine.

I could then launch Steam, use that, and that would be fine.

Once I exited steam, it would re-launch XBMC, but out of focus (never regaining focus without mouse input).

I noticed this only affects XBMC when it is started from the Startup menu. When I launch it manually, then everything works great.

I downloaded a plugin called "FocusBitch" and gave that a shot. While it works fine in the Startup menu, I seem to still have the focus issue when XBMC re-launches (natively, without the FocusBitch plugin) on Steam exit.

Is it possible/adviseable to change the steam launcher plugin to use FocusBitch instead of launching XBMC directly? I think that would solve my issue. If so, can you possibly point out what file I need to edit and where?

If anyone else has seen this issue and there is a more direct way of resolving it, I'm also open to suggestions.

Thanks
(2013-12-31, 07:29)jwbrown77 Wrote: [ -> ]Hi teeedubb,

Thanks for the terrific plugin. It's working almost flawlessly for me.

I have Windows 8.1 and I've configured a user to auto-login and was launching XBMC from the Windows startup menu. XBMC started out of focus for a few seconds, but would regain focus and be fine.

I could then launch Steam, use that, and that would be fine.

Once I exited steam, it would re-launch XBMC, but out of focus (never regaining focus without mouse input).

I noticed this only affects XBMC when it is started from the Startup menu. When I launch it manually, then everything works great.

I downloaded a plugin called "FocusBitch" and gave that a shot. While it works fine in the Startup menu, I seem to still have the focus issue when XBMC re-launches (natively, without the FocusBitch plugin) on Steam exit.

Is it possible/adviseable to change the steam launcher plugin to use FocusBitch instead of launching XBMC directly? I think that would solve my issue. If so, can you possibly point out what file I need to edit and where?

If anyone else has seen this issue and there is a more direct way of resolving it, I'm also open to suggestions.

Thanks

You could edit the included SteamLaunch-AHK file and use launch xbmc from focusbitch, or maybe use a bat file to launch xbmc via focusbitch and point the addon to the batch file instead of the xbmc.exe.

Another option is to use AutoHotKey to give xbmc focus when its running, PinnacleGameProfiler steals focus about 10 seconds after startup on my system and I use this script to get xbmc back on screen. It runs for 15 seconds but it could be modified to run continuously.

Code:
#NoEnv
#SingleInstance force
SetWorkingDir %A_ScriptDir%

start := A_TickCount
loop
{
Process, Exist, XBMC.exe
if ErrorLevel
  WinActivate ahk_class XBMC
sleep, 1000
now := A_TickCount-start
if now > 15000
break
}
return

ExitApp

Have you tried using advancedsettings.xml (wiki) to give xbmc focus to xbmc? <fullscreen> and <alwaysontop> could help.
(2013-12-31, 07:29)jwbrown77 Wrote: [ -> ]Hi teeedubb,

Thanks for the terrific plugin. It's working almost flawlessly for me.

I have Windows 8.1 and I've configured a user to auto-login and was launching XBMC from the Windows startup menu. XBMC started out of focus for a few seconds, but would regain focus and be fine.

I could then launch Steam, use that, and that would be fine.

Once I exited steam, it would re-launch XBMC, but out of focus (never regaining focus without mouse input).

I noticed this only affects XBMC when it is started from the Startup menu. When I launch it manually, then everything works great.

I downloaded a plugin called "FocusBitch" and gave that a shot. While it works fine in the Startup menu, I seem to still have the focus issue when XBMC re-launches (natively, without the FocusBitch plugin) on Steam exit.

Is it possible/adviseable to change the steam launcher plugin to use FocusBitch instead of launching XBMC directly? I think that would solve my issue. If so, can you possibly point out what file I need to edit and where?

If anyone else has seen this issue and there is a more direct way of resolving it, I'm also open to suggestions.

Thanks

jwbrown - I don't know if this is something that may interest you but its what I did when I used to run XBMC on windows.

I had an emulator that I used to launch and when I finished, it would close and swap back to XBMC.

The focus issue came up for me so I googled a premade autohotkeyscript and compiled it myself in to an .exe. I put this in my startup folder so it ran at boot, threw in a sleep timer and it was good to go.

The script was more or less "if xbmc exists then it has focus, If the emulator exists then it has focus" It was only a handful of lines of code. Sorry I can't post it here. I have long since swapped to Ubuntu so I don't have it anymore.

EDIT: Nevermind, the man with a plan got in first Smile
I'm using Ubuntu 13.10, and it seems like default.py can't import xbmcaddon... Any idea how to address the issue?
(2013-12-31, 07:45)teeedubb Wrote: [ -> ]You could edit the included SteamLaunch-AHK file and use launch xbmc from focusbitch, or maybe use a bat file to launch xbmc via focusbitch and point the addon to the batch file instead of the xbmc.exe.

Another option is to use AutoHotKey to give xbmc focus when its running, PinnacleGameProfiler steals focus about 10 seconds after startup on my system and I use this script to get xbmc back on screen. It runs for 15 seconds but it could be modified to run continuously.

Hi teeedubb,

I don't know why, but I didn't even think to check the plugin's settings. I forgot that you can define the path to XBMC there. I was thinking it was hard coded in the script somewhere.

I changed that from xbmc.exe to the FocusBitch cmd script I created and that works great. It was an easy fix in the end.

I have some experience with AutoIT3. I hadn't even heard of AHK. I'll investigate that if this winds up not working right.

Thanks so much for the advice!

Thank you as well staticn0de. I will definitely keep AHK in mind in the future.
(2013-12-31, 18:58)hfa2010 Wrote: [ -> ]I'm using Ubuntu 13.10, and it seems like default.py can't import xbmcaddon... Any idea how to address the issue?

Not sure whats up there, the addon isnt giving me that error here on several 13.10 machines. Do you have this problem with any other addons? When do you get the error and with which version of XBMC? Can you post a debug log (wiki) of it happening?

(2013-12-31, 19:04)jwbrown77 Wrote: [ -> ]Hi teeedubb,

I don't know why, but I didn't even think to check the plugin's settings. I forgot that you can define the path to XBMC there. I was thinking it was hard coded in the script somewhere.

Changing paths via addon settings is only a recent addition, only a couple of days old Smile