I’ve been trying to get Kodi and Steam to play nice on my Arch HTPC for a while now. It’s been a bit of a pain as all the configs and everything are in transition between XBMC and Kodi.
My cousin asked me to set him one up similarly but also including steam functionality, I thought it couldn’t be so hard… so off I went. It proved nearly impossible for me to get SteamOS running with Kodi well enough not to mention the limited install options to really have something I wanted to leave him with, a non linux user. After alot of trials with various distros I resolved to just use Windows with autologin, Steam-launcher, Kodi Launcher, and Steam-Ice… I did and it works wonderfully … buuuut its Windows and thats good enough for him but not me.
I wanted more or less the same thing.. my HTPC/home server had been running Arch with an autostartup script into XBMC, using a bluetooth keyboard to control everything… it was great. But I figured it’s got enough juice for some steam games so here is my mostly working attempt to get Kodi and Steam big picture to transition from one to another smoothly.
I also use a PS3 controller on bluetooth to make things more complicated.
Link for Steam-Launcher plugin http://forum.kodi.tv/showthread.php?tid=157499
So install Kodi, Steam, openbox and Steam-Launcher.
Since I wasn’t even using a DM before to boot straight into XBMC/Kodi I had to add one, I installed lightdm and set it to autostartup openbox.
Make sure you set your desktop environment from Gnome or KDE or whatever it is to openbox.For some reason changing the DE after setting autostar on lightdm wasn’t happening. No matter what I did the lightdm autostartup kept going into gnome even after changing the autologin-session in /etc/lightdm/lightdm.conf
I found this post about, not sure if its relevant. It’s pretty old – http://forum.kodi.tv/showthread.php?tid=128861
I just followed the Arch page here https://wiki.archlinux.org/index.php/LightDM Kodi + Steam Launcher.
This is what I did to get these working together nicely.
I used this post http://forum.kodi.tv/showthread.php?tid=157499&pid=1742931#pid1742931 and this post http://forum.kodi.tv/showthread.php?tid=157499&pid=1706466#pid1706466 to guide me along getting everything setup, but none of it is updated for Kodi unfortunately..
Also I decided to use openbox to as the DE. Instead of gnome as the guide suggests.
Here is what I did. Modified files for Kodi beneath.
From http://forum.kodi.tv/showthread.php?tid=157499&pid=1742931#pid1742931
- XBMC ontop of Gnome desktop: Firstly, you need the program wmctrl installed. Then create a new desktop entry to launch XBMC as the desktop user (there will be two entries for XBMC so you can still run XBMC as the steam user – if you use XBMC as both users you will probably want to symlink/bind mount the two ~/.xbmc directories so you can share user settings/addons/etc..). The new XBMC entry will be called just “XBMC”:
/usr/share/applications/xbmc-sl.desktop
[Desktop Entry] Version=1.0
Name=XBMC
GenericName=Media Center
Comment=Manage and view your media
Exec=/usr/bin/xbmc-sl.sh
Icon=xbmc
Terminal=false
Type=Application
Categories=AudioVideo;Video;Player;TV;
Steam doesnt like desktop entries using commands with prefixes (in this case sudo), so two script files are necessary – one for steam to launch, which in turn launches the second with sudo rights (this is needed as commands are being executed for different users)
/usr/bin/xbmc-sl.sh
sudo /usr/bin/xbmc-sl2.sh
/usr/bin/xbmc-sl2.sh
#!/bin/bashdbus-send –system –print-reply –dest=org.freedesktop.DisplayManager /org/freedesktop/DisplayManager/Seat0 org.freedesktop.DisplayManager.Seat.SwitchToUser string:’desktop’ string:”
export DISPLAY=:1
until [[ $(sudo -u desktop wmctrl -l |grep “Desktop$”) ]] ; do
sleep 1
done
if [[ $(pidof xbmc.bin) ]] ; then
sudo -u desktop wmctrl -r “XBMC Media Center” -b add,fullscreen &
else
sudo -u desktop xbmc &
fi
Make both script files executable.
chmod +x xbmc-sl.sh
chmod +x xbmc-sl2.sh
Now to edit the sudoers file to allow the above to be executed without a password prompt. Run sudo visudo and add the following to the end:
%steam ALL = NOPASSWD: /usr/bin/xbmc-sl2.sh
%desktop ALL = NOPASSWD: /usr/bin/xbmc-sl2.sh
At the end I also added my kodi user to sudoers file instead of desktop because I don’t have a desktop user.
Then I did this bit
From http://forum.kodi.tv/showthread.php?tid=157499&pid=1706466#pid1706466
Enable Openbox:
sudo mv /usr/share/xsessions/openbox.desktop.dis /usr/share/xsessions/openbox.desktop
Set Openbox as the default session:
sudo nano /etc/lightdm/lightdm.conf
and change the whole line beginning with user-session= to user-session=Openbox
ctrl + x to exit.
If this doesnt set the Openbox session to auto-boot, exit XBMC and at the login screen press ‘F9′ to open the windowmanager selection box and select Openbox there.
Set the Openbox background to black and XBMC to auto start:
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/xbmc &" >> $HOME/.config/openbox/autostart.sh && chmod +x $HOME/.config/openbox/autostart.sh
Then
*Optional: For a better Openbox right click menu that contains entries for Steam, Steam BPM, XBMC, Chromium and others:
sudo apt-get install menu
nano ~/.config/openbox/menu.xml
And paste in the following:
<?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=”XBMC”>
<action name=”Execute”><execute>xbmc</execute></action>
You can modify that last file there to add or remove menu entries to the open box right click menu.
I didnt use any pre or post steam scripts.. everything seems to just work, steam launcher is not in portable mode (if that matters?).
Contents of /home/kodi/.config/openbox/autostart
xsetroot -solid black &
/usr/bin/kodi &
/usr/share/applications/xbmc-sl.desktop ->/usr/share/applications/kodi-sl.desktop
[Desktop Entry]
Version=1.0
Name=Kodi-sl
GenericName=Media Center
Comment=Manage and view your media
Exec=/usr/bin/kodi-sl.sh
Icon=kodi
Terminal=false
Type=Application
Categories=AudioVideo;Video;Player;TV;
/usr/bin/xbmc-sl.sh -> /usr/bin/kodi-sl.sh
sudo /usr/bin/kodi-sl2.sh
/usr/bin/xbmc-sl2.sh ->/usr/bin/kodi-sl2.sh
#!/bin/bash
dbus-send --system --print-reply --dest=org.freedesktop.DisplayManager /org/fr$
export DISPLAY=:1
until [[ $(sudo -u kodi wmctrl -l |grep "Desktop$") ]] ; do
sleep 1
done
if [[ $(pidof kodi.bin) ]] ; then
sudo -u kodi wmctrl -r "Kodi Media Center" -b add,fullscreen &
else
sudo -u kodi kodi &
fi
This is lifted straight from https://wiki.archlinux.org/index.php/Gamepad#PS3_controller
Playstation 3 Controllers via Bluetooth
To make the Playstation 3 controller work over bluetooth you will need to install the sixpair utility.After installing sixpair connect your controller with an USB cable and run sixpair
# sixpair
Disconnect your controller from USB and wait about 5 minutes (not sure if really needed)
Now you will need to pair it with bluez. You will need bluez-utils and bluez-plugins packages.
Disable all bluetooth utilities (like bluedevil or bluemon)
Run the bluetoothctl utility
# bluetoothctl
A bluetooth prompt will appear.
Press the playstation button and watch for connection and disconnection messages and copy the device address (something like 38:C0:96:56:4D:AA)
Wait for the lights stop blinking.
Now, type the following:
agent on
default-agent
discoverable on
pairable on
Hit the playstation button again and while it blinks type the following
connect <device_addr>
Keep trying this command if you see device not available (it will loop between connected and disconnected) until you see something like the following
I usually keep pressing up + enter (repeating the last command)
[CHG] Device <device_addr> Modalias: usb:v054Cp0268d0100
[CHG] Device <device_addr> UUIDs:
00001124-0000-1000-8000-00805f9b34fb
00001200-0000-1000-8000-00805f9b34fb
Now trust the device
trust <device_addr>
You’re done
After you do that your PS3 controller will pair with your computer whenever you press the PS button. However for Kodi and Steam it’t not really going to do you any good. Kodi has an event server for PS3 controllers and works well so long as you sync the controller after Kodi has started up if you sync the controller before Kodi has started it will crash on startup. weird? This isn’t a huuge problem if your only running Kodi, but since I want to switch between Kodi and Steam its a pretty big problem.
You have to emulate your controller as an xbox360 controller, sigh.
I used the script and udev rule from the post in this steam forum http://steamcommunity.com/app/221410/discussions/0/864957183095090885/#c46476691625656444
So first I made the udev rule as described
sudo nano /etc/udev/rules.d/85-input-events.rules
and pasted in a slightly modified version of the steam post.
Original
ATTRS{name}=="PLAYSTATION*", ENV{DEVNAME}=="/dev/input/event*", RUN+="/home/example/sixaxis.sh $devnode"
Modified
ATTRS{name}=="Sony*", ENV{DEVNAME}=="/dev/input/event*", RUN+="/home/example/sixaxis.sh $devnode"
udev wasn’t applying the rule to the controller because it couldn’t find PLAYSTATION* in its name, the controller was called something else. Mine was Sony Wireless Game Controller so I changed the
ATTRS{name}=="PLAYSTATION*"
to
ATTRS{name}=="Sony*"
I suppose this wont work if you have any Sony devices on your system? I don’t so whatever.
Make the sixaxis.sh file
nano ~/sixaxis.sh
#!/bin/bash
function startSixaxis ()
{
chmod 600 $DEVICE; #Change original device permissions so Steam doesn’t detect it
xboxdrv –evdev $DEVICE -d –type xbox360-wireless –silent –evdev-keymap KEY_#300=y,KEY_#302=a,KEY_#301=b,BTN_DEAD=x,BTN_TOP=start,BTN_TRIGGER=back,BTN_A=guide,BTN_BASE6=rb,BTN_BASE5=lb,BTN_TOP2=du,BTN_BASE2=dl,BTN_BASE=dd,BTN_PINKIE=dr,BTN_THUMB=tl,BTN_THUMB2=tr –evdev-absmap ABS_#13=rt,ABS_#12=lt,ABS_X=x1,ABS_Y=y1,ABS_Z=x2,ABS_RX=y2 –mimic-xpad-wireless –axismap -Y1=Y1,-Y2=Y2 –calibration RT=0:127:255,LT=0:127:255 &
PID=$!
echo “$PID” > $PID_FILE
}
DEVICE=$1
PID_FILE=”/tmp/xboxdrv_pid$(echo $DEVICE | sed ‘s/\//_/g’)”
if [[ “$ACTION” == “remove” ]]; then
PID=$(cat $PID_FILE);
kill -9 $PID #SIGKILL is needed because the xboxdrv process can get stuck
fi
if [[ “$ACTION” == “add” ]]; then
startSixaxis
fi
Save it, give it executable permission
sudo chmod +x sixaxis.sh
That’s it your controller should work in both Steam and Kodi.
I want to add, none of this is my work I just patched a bunch of stuff together. So credit goes to the authors of the original fixes.