[Solution] Retroarch from Kodi Standalone
#1
Apologies if this is in the wrong section - not really sure which area is best suited to this question.

I recently bought a couple of Xbox controllers and am interested in doing some emulation on my htpc. I've seen guides that detail how you can switch between Kodi and Retroarch using a window manager and I've seen guides on how to do it in OpenELEC/LibreElec, however I'm running Kodi as a standalone service using systemd.

Has anyone successfully accomplished RetroArch/Kodi switching using kodi-standalone?

Edit: Read below for the solution.
Reply
#2
you have to start a window manager, e.g. openbox
Or you use retroplayer...
Reply
#3
@wsnipex that appears not to be the case as I have it working with a basic x window system just fine. Whilst I would love to use retroplayer - unfortunately the backbone of my htpc is Emby which is not yet compatible with krypton.

Here's how I accomplished it in the end - the way it works is when you exit Kodi, Retroarch will start and when you exit Retroarch, Kodi will start; additionally if either of the two crash it will restart that particular service and not the other service.

If you are using polkit then you need to allow both the Retroarch service and your Kodi service to be controlled by your Kodi user, so create the file "/etc/polkit-1/rules.d/10-htpc.rules":
Code:
polkit.addRule(function(action, subject) {
    if (action.id == "org.freedesktop.systemd1.manage-units") {
        if (action.lookup("unit") == "[email protected]" || action.lookup("unit") == "[email protected]") {
            var verb = action.lookup("verb");
            if (verb == "start" || verb == "stop" || verb == "restart") {
                return polkit.Result.YES;
            }
        }
    }
});

Next create a Kodi service template and enable it with "systemctl enable kodi@kodi":
Code:
[Unit]
Description = Kodi Media Center
After = systemd-user-sessions.service network.target sound.target
Conflicts = retroarch@%i.service

[Service]
User = %i
Group = %i
Type = simple
ExecStart = /usr/bin/xinit /usr/bin/dbus-launch --exit-with-session /usr/bin/kodi-standalone -- :0 -nolisten tcp vt7
ExecStopPost = /usr/bin/systemctl start retroarch@%i.service
SuccessExitStatus=1
Restart = on-failure
RestartSec = 0.1

[Install]
WantedBy = multi-user.target

Create the Retroarch service template:
Code:
[Unit]
Description = Retroarch Arcade
Conflicts = kodi@%i.service

[Service]
User = %i
Group = %i
Type = simple
ExecStart = /usr/bin/xinit /usr/bin/dbus-launch --exit-with-session /usr/bin/retroarch --appendconfig=/etc/retroarch-standalone.cfg -- :0 -nolisten tcp vt7
ExecStopPost = /usr/bin/systemctl start kodi@%i.service
SuccessExitStatus=1
Restart = on-failure
RestartSec = 0.1

[Install]
WantedBy = multi-user.target

Start the Kodi service template with "systemctl start kodi@kodi" and that's it!

With the above examples the second kodi in kodi@kodi/retroarch@kodi is your Kodi user account - you can change that to suit your needs.

It's all working great.
Reply

Logout Mark Read Team Forum Stats Members Help
[Solution] Retroarch from Kodi Standalone0