•   
  • 1
  • 7
  • 8
  • 9(current)
  • 10
  • 11
  • 12
  •   
Release Gamestarter: Retrogaming add-ons for LibreELEC (RPi/Generic).
How is the progress on 0.9.7? Is this release imminent or a few weeks away?

Also, if @Wintermute0110 could chime in on the plugin URL info, I'd be very grateful. I'm new to Kodi scripting and available documentation on this specifically is pretty thin.

Thanks again everyone.
Reply
(2017-09-04, 16:41)crono141 Wrote: How is the progress on 0.9.7? Is this release imminent or a few weeks away?

Definitely not imminent. I've done a lot of progress but still there is a mayor feature to implement and a lot of polishing to be done (there were changes in the database format to accommodate new features and that always causes some disruptions in the code). You can see the progress in the changelog.

(2017-09-04, 16:41)crono141 Wrote: Also, if @Wintermute0110 could chime in on the plugin URL info, I'd be very grateful. I'm new to Kodi scripting and available documentation on this specifically is pretty thin.

Thanks again everyone.

AEL URLs are not documented yet and still are changing because I discover bugs or things that can be improved.. You can see some examples of the widgets in Estuary AEL MOD in this commit that use some of the URLs.
Reply
(2017-09-04, 17:32)Wintermute0110 Wrote: AEL URLs are not documented yet and still are changing because I discover bugs or things that can be improved.. You can see some examples of the widgets in Estuary AEL MOD in this commit that use some of the URLs.

Thanks. Is there a way to get the currently active URL programatically? My plan is to get the current URL at rom launch (so I'll need to make further modifications to the addon.sh script) and write that to my AEL.launch file. Then in my autoexec.py script we'll read from that file the last internal URL, and pass that to the activewindow function to bring us right back to where we were when we launched retroarch.

This way, you can change your internal URLs as much as necessary and it won't effect the return script I'm writing.
Reply
(2017-09-04, 17:44)crono141 Wrote:
(2017-09-04, 17:32)Wintermute0110 Wrote: AEL URLs are not documented yet and still are changing because I discover bugs or things that can be improved.. You can see some examples of the widgets in Estuary AEL MOD in this commit that use some of the URLs.

Thanks. Is there a way to get the currently active URL programatically? My plan is to get the current URL at rom launch (so I'll need to make further modifications to the addon.sh script) and write that to my AEL.launch file. Then in my autoexec.py script we'll read from that file the last internal URL, and pass that to the activewindow function to bring us right back to where we were when we launched retroarch.

This way, you can change your internal URLs as much as necessary and it won't effect the return script I'm writing.

I believe ricardo85x has already done a script that does what you want. Have a look at this post. Note that you don't need to modify AEL's Python code anymore, AEL now supports the argument keywords $categoryID$, $launcherID$ and $romID$.

Also, I may publish a wrapper launcher script soon in AEL's thread that restores Kodi when the launched application finished myself, based on ricardo85x work and tested by myself. I have discovered that in my setup (Intel NUC + Kodibuntu + Kodi Krypton) Kodi eats a lots of CPU time and the NUC fan is working all the time and I want to shut down Kodi, then launch Retroarch, then restore Kodi.
Reply
(2017-09-05, 09:51)Wintermute0110 Wrote: I believe ricardo85x has already done a script that does what you want. Have a look at this post. Note that you don't need to modify AEL's Python code anymore, AEL now supports the argument keywords $categoryID$, $launcherID$ and $romID$.

interesting...

I think the magic is in this line:
Code:
kodi-send --host=127.0.0.1 --port=9777 --action="ActivateWindow(1,plugin://plugin.program.advanced.emulator.launcher/?catID=$categoryID&com=SHOW_ROMS&launID=$launcherID)"

I will make some tests...
Reply
(2017-09-05, 10:03)bite_your_idols Wrote:
(2017-09-05, 09:51)Wintermute0110 Wrote: I believe ricardo85x has already done a script that does what you want. Have a look at this post. Note that you don't need to modify AEL's Python code anymore, AEL now supports the argument keywords $categoryID$, $launcherID$ and $romID$.

interesting...

I think the magic is in this line:
Code:
kodi-send --host=127.0.0.1 --port=9777 --action="ActivateWindow(1,plugin://plugin.program.advanced.emulator.launcher/?catID=$categoryID&com=SHOW_ROMS&launID=$launcherID)"

I will make some tests...

I'm not sure I understand how he gets the current categoryID, launcherID, or romID from his script. I'm decent at python scripting, but absolutely awful at bash scripting.
Reply
(2017-09-05, 14:28)crono141 Wrote:
(2017-09-05, 10:03)bite_your_idols Wrote:
(2017-09-05, 09:51)Wintermute0110 Wrote: I believe ricardo85x has already done a script that does what you want. Have a look at this post. Note that you don't need to modify AEL's Python code anymore, AEL now supports the argument keywords $categoryID$, $launcherID$ and $romID$.

interesting...

I think the magic is in this line:
Code:
kodi-send --host=127.0.0.1 --port=9777 --action="ActivateWindow(1,plugin://plugin.program.advanced.emulator.launcher/?catID=$categoryID&com=SHOW_ROMS&launID=$launcherID)"

I will make some tests...

I'm not sure I understand how he gets the current categoryID, launcherID, or romID from his script. I'm decent at python scripting, but absolutely awful at bash scripting.

Bash scripting is much easier than Python programming, although Bash syntax is sometimes horrible. Suppose your wrapper script is called run_retroarch.sh. Then (I'm using standard Linux paths, adapt for the distribution of the Pi):

Code:
Application -> /home/kodi/bin/run_retroarch.sh
Arguments   -> core_name "$rom$" $categoryID$ $launcherID$ $romID$

IDs are MD5 hashes or strings with no spaces and ASCII-only characters, so the quotes "" are not necessary.

Regarding the URLs... best thing you can do now it to look at AEL's source code. However, last couple of days I've thinking about the current URL model in AEL. As you know, AEL started of a fork of Advanced Launcher and so it has inherited some of his flaws (also some AL's good things Wink). For example, the URL to display ROMs in a launcher:

Code:
plugin://plugin.program.advanced.emulator.launcher/?com=SHOW_ROMS&catID=$categoryID&launID=$launcherID

I have realised that the the categoryID is redundant: because all launcher IDs are unique, the categoryID can be easily determined with the launcherID if necessary.

Another issue is that now AEL has many different commands. For example:

Code:
SHOW_ADDON_ROOT -> Renders the addon root window
SHOW_ROMS -> Renders ROMs in a normal launcher
SHOW_FAVOURITES -> Renders Favoruite ROMs
SHOW_VLAUNCHER_ROMS -> Renders ROMs in a virtual launcher
etc.

This made sense during development: a new idea came to my mind and then implemented it with a new function. However, now that I started to do some skinning myself (Estuary AEL MOD) then I realised how URLs are used in plugins and discovered that from the skinner point of view is easier to have the less URL commands as possible and introduce the complexity into AEL. For example, it is not neccesary to have two commands SHOW_ROMS and SHOW_VLAUNCHER_ROMS. Instead, a unique command SHOW_ROMS and depending of the launcherID AELs renders ROMs in a launcher, ROMs in Favourites, ROMs in a Virtual Launcher, etc.

Yet another issue is that currently I don't know how to preselect an item (ROM) in a ListItem. That is, when returning to Kodi you will return to the Launcher but the ROM you launched will not be selected. I will investigate this and talk with Kodi Core developers about the implementation.
Reply
OK, now I'm having another problem

After letting my Pi sit and AEL scan my mame folder (of 56000 files) for 4 days straight (because even though the UI froze up, the log file was still showing activity), I finally had to kill it an reboot. Now though, nothing launches.

Here's the relevant portion.

20:01:31.122 T:1373971360 ERROR: AEL INFO : _command_run_rom() Launching ROM in Launcher ...
20:01:31.350 T:1373971360 ERROR: AEL INFO : _command_run_rom() Using Launcher standard arguments
20:01:31.351 T:1373971360 ERROR: AEL INFO : _command_run_rom() Sigle ROM detected (no multidisc)
20:01:31.351 T:1373971360 ERROR: AEL INFO : _command_run_rom() ROMFileName OP "/storage/emulators/roms/Nintendo Game Boy Advance/Roms/Advance Wars (USA) (Rev 1).gba"
20:01:31.351 T:1373971360 ERROR: AEL INFO : _command_run_rom() ROMFileName P "/storage/emulators/roms/Nintendo Game Boy Advance/Roms/Advance Wars (USA) (Rev 1).gba"
20:01:31.352 T:1373971360 ERROR: AEL INFO : _command_run_rom() categoryID 2b494a422afb2474f89a7b693328fe92
20:01:31.352 T:1373971360 ERROR: AEL INFO : _command_run_rom() launcherID c2b7de4d1f1ffc9e7eb09866d79a156e
20:01:31.352 T:1373971360 ERROR: AEL INFO : _command_run_rom() romID 18927807bbbae1f0518ad982e17821b9
20:01:31.353 T:1373971360 ERROR: AEL INFO : _command_run_rom() romfile "/storage/emulators/roms/Nintendo Game Boy Advance/Roms/Advance Wars (USA) (Rev 1).gba"
20:01:31.353 T:1373971360 ERROR: AEL INFO : _command_run_rom() rompath "/storage/emulators/roms/Nintendo Game Boy Advance/Roms"
20:01:31.353 T:1373971360 ERROR: AEL INFO : _command_run_rom() rombase "Advance Wars (USA) (Rev 1).gba"
20:01:31.353 T:1373971360 ERROR: AEL INFO : _command_run_rom() rombasenoext "Advance Wars (USA) (Rev 1)"
20:01:31.353 T:1373971360 ERROR: AEL INFO : _command_run_rom() romtitle "Advance Wars (USA) (Rev 1)"
20:01:31.353 T:1373971360 ERROR: AEL INFO : _command_run_rom() application "/storage/.kodi/addons/game.retroarch/addon.sh"
20:01:31.353 T:1373971360 ERROR: AEL INFO : _command_run_rom() apppath "/storage/.kodi/addons/game.retroarch"
20:01:31.354 T:1373971360 ERROR: AEL INFO : _command_run_rom() romext "gba|zip"
20:01:31.665 T:1373971360 ERROR: AEL INFO : _command_run_rom() raw arguments "mgba "%rom%""
20:01:31.665 T:1373971360 ERROR: AEL INFO : _command_run_rom() final arguments "mgba "/storage/emulators/roms/Nintendo Game Boy Advance/Roms/Advance Wars (USA) (Rev 1).gba""
20:01:32.283 T:1373971360 ERROR: AEL INFO : fs_write_Favourites_JSON() File special://profile/addon_data/plugin.program.advanced.emulator.launcher/most_played.json
20:01:32.600 T:1373971360 ERROR: AEL INFO : _command_run_rom() Launcher is not Kodi Retroplayer.
20:01:33.435 T:1373971360 ERROR: AEL ERROR: SingleInstance::__exit__() Unhandled excepcion in protected code
20:01:33.741 T:1373971360 ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type: <type 'exceptions.OSError'>
Error Contents: [Errno 2] No such file or directory
Traceback (most recent call last):
File "/storage/.kodi/addons/plugin.program.advanced.emulator.launcher/addon.py", line 39, in <module>
main.Main().run_plugin()
File "/storage/.kodi/addons/plugin.program.advanced.emulator.launcher/resources/main.py", line 248, in run_plugin
with SingleInstance(): self.run_protected(args)
File "/storage/.kodi/addons/plugin.program.advanced.emulator.launcher/resources/main.py", line 339, in run_protected
self._command_run_rom(args['catID'][0], args['launID'][0], args['romID'][0])
File "/storage/.kodi/addons/plugin.program.advanced.emulator.launcher/resources/main.py", line 6743, in _command_run_rom
self._run_process(application.getPath(), arguments, apppath, romext)
File "/storage/.kodi/addons/plugin.program.advanced.emulator.launcher/resources/main.py", line 6845, in _run_process
retcode = subprocess.call(exec_list, stdout = f, stderr = subprocess.STDOUT)
File "/usr/lib/python2.7/subprocess.py", line 168, in call
File "/usr/lib/python2.7/subprocess.py", line 390, in __init__
File "/usr/lib/python2.7/subprocess.py", line 1024, in _execute_child
OSError: [Errno 2] No such file or directory
-->End of Python script error report<--

I've verified that the requested core exists. I know there used to be a symlink in the cores folder though that would truncate the "_libretro.so" portion of the command, but I don't see it anymore and I don't know how to recreate it. Chances are I downloaded the full Lakka cores, found out they didn't work, and then purged the whole directory, killing the symlink in the process. And I can't figure out how to recreate it either. Sad

LibreELEC:~/.kodi/userdata/addon_data/game.retroarch/cores # ls -l
total 9450
-rw-r--r-- 1 root root 2068216 Sep 6 19:59 desmume_libretro.so
-rw-r--r-- 1 root root 56900 Sep 6 19:59 emux_gb_libretro.so
-rw-r--r-- 1 root root 331704 Sep 6 19:59 fceumm_libretro.so
-rw-r--r-- 1 root root 157680 Sep 6 19:59 gambatte_libretro.so
-rw-r--r-- 1 root root 2686204 Sep 6 20:00 genesis_plus_gx_libretro.so
-rw-r--r-- 1 root root 532492 Sep 6 20:00 mednafen_pce_fast_libretro.so
-rw-r--r-- 1 root root 567408 Sep 1 15:19 mgba_libretro.so
-rw-r--r-- 1 root root 527488 Sep 6 20:00 pcsx_rearmed_libretro.so
-rw-r--r-- 1 root root 1219020 Sep 6 20:00 snes9x2010_libretro.so
-rw-r--r-- 1 root root 1431776 Sep 6 19:59 stella_libretro.so
-rw-r--r-- 1 root root 91924 Sep 6 19:59 tgbdual_libretro.so

Also, I can no longer launch retroarch from the plugin menu. The splash screen shows but the RA interface never appears. The retroarch executable never launches (as shown by a ps -ef | grep retro). However, from SSH I can manually kill kodi and launch the retroarch-RPi executable in the addon folder, and the app launches. Below appears to be the only relevant log entries for this problem.

20:07:57.928 T:1352135584 NOTICE: LoadJpeg: unable to load /storage/.kodi/addons/game.retroarch/fanart.jpg
20:07:58.013 T:1778381728 ERROR: EXCEPTION: XBMC is not playing any file
20:08:03.184 T:1778381728 ERROR: Previous line repeats 51 times.
20:08:03.184 T:1778381728 NOTICE: PLEX.kodimonitor -> No current File, cancel OnPlayBackStart...

I've tried updating the plugin, but that doesn't solve the problem.
Reply
Nevermind. I've given up on the project, and I figured out a way to get Advanced Emulator Launcher (AEL) to work with retropie's runcommand.sh. It was quite easy, actually. In AEL, you call this script:

#!/bin/bash

videomode=$1
sysport=$2
system=$3
rom=$4

kodi-send --host=127.0.0.1 --port=9777 --action='Quit'
/opt/retropie/supplementary/runcommand/runcommand.sh $videomode $sysport $system "${rom}"
/home/pi/RetroPie/roms/ports/Kodi.sh

You need kodi-send and its dependencies installed for this to work. Then in AEL, instead of invoking runcommand.sh, you envoke the above script with the exact same command line parameters as runcommand, only this one quits kodi first before executing the runcommand emulator. I still need to setup the AEL url script, and the then Kodi autoexec.py script to bring you back to AEL once the emulator is done launching.

Thanks anyway for all the support in this thread.
Reply
(2017-09-07, 02:24)crono141 Wrote: OK, now I'm having another problem

After letting my Pi sit and AEL scan my mame folder (of 56000 files) for 4 days straight (because even though the UI froze up, the log file was still showing activity), I finally had to kill it an reboot. Now though, nothing launches.

MAME has about 30,000 machines, including parents and clones. Where do you get 56000 files?

Also, AEL can deal with no problems with such a big launcher but you need appropriate settings. Did you use offline or online metadata scraper? Did you use online scraper for artwork? If you use the offline scraper and search for local images scanning 30000 MAME ROMs should take less than 30 minutes. In the ROM scanner most of the time is consumed searching for artwork. Searching for metadata in the offline scraper is already optimised even for big databases like MAME. I'm working in a way of accelerating the scanning speed of artwork for 0.9.7 by using a caches of directory listings.

So, to summarise, if you have a full MAME collection I recommend the following settings/procedures:

1) Always use the offline metadata scraper.

2) In "Metadata scan policy" chose "Scrapers".

3) "Ignore Scrapped Titles (use ROM filenames instead)" must be OFF for MAME ROMs.

4) In "Asset scan policy" choose "Local Images"

5) Download all the available MAME artwork from Pleasuredome (about 56 GB including manuals and Software Lists artwork) or Progretto SNAPs. Scraping MAME artwork is very inefficient. Downloading the artwork pack is much more quicker and convenient!

Also, you can try Advanced MAME Launcher which is designed specifically for MAME and supports both MAME Machines and Software Lists ROMs (over 100,000 ROMs in total). However, TTBOMK, nobody has used AML so far in the Pi and there could be out of memory problems. If you wish to give AML a try and have any issues please tell me here or in the AML and I will think of a solution.

(2017-09-07, 02:24)crono141 Wrote: Here's the relevant portion.

20:01:31.122 T:1373971360 ERROR: AEL INFO : _command_run_rom() Launching ROM in Launcher ...

AEL gets an OSError from Python subprocess module. Can you enable the debug log in AEL so I can see the whole argument list passed onto subprocess.exec()?
Reply
@crono141 I realised there could be an issue with launching shell files on Linux. Have a look at this post on AEL's thread for more info. This weekend I will have a look at it.
Reply
This is a copy of a post in AEL's thread that may be also of interest here.

--------------------------------------------

Yesterday I tried to use a wrapper script in Linux (Kodibuntu) and it works well with 0.9.7-alpah. It should work also with 0.9.6 because the Linux launching code is exactly the same. This is the wrapper script:

Code:
#!/bin/sh
# Script arguments: core_name "$rom$" $categoryID$ $launcherID$ $romID$
#
RETROARCH="/home/kodi/bin/retroarch"
LIBRETRO_PATH="/home/kodi/bin/libretro/"
LOG_FILE="/home/kodi/bin/run_retroarch.log"
LOG_RETROARCH="/home/kodi/bin/retroarch.log"

kodi_rpc()
{
    METHOD="$1"
    json_str="{\"jsonrpc\":\"2.0\",\"id\":\"1\",\"method\":\"$METHOD\"}\""
    curl -H "Content-type: application/json" -d "$json_str" http://localhost:8080/jsonrpc
}

kodi_rpc_params()
{
    METHOD="$1"
    PARAMS="$2"
    json_str="{\"jsonrpc\":\"2.0\",\"id\":\"1\",\"method\":\"$METHOD\",$PARAMS}\""
    curl -H "Content-type: application/json" -d "$json_str" http://localhost:8080/jsonrpc
}

# --- Print some information ---
echo "Retroarch core  \"$1\"" > $LOG_FILE
echo "ROM filename    \"$2\"" >> $LOG_FILE
echo "Category ID     \"$3\"" >> $LOG_FILE
echo "Launcher ID     \"$4\"" >> $LOG_FILE
echo "ROM ID          \"$5\"" >> $LOG_FILE
echo "PID             \"$$\"" >> $LOG_FILE
echo "Parent PID      \"$PPID\"" >> $LOG_FILE

# --- Check if libretro core exists ---
core_file="$LIBRETRO_PATH/$1_libretro.so"
if [ ! -f "$core_file" ]; then
    PARAMS="\"params\":{\"title\" : \"run_retroarch error\", \"message\":\"Core file not found\"}"
    kodi_rpc_params "GUI.ShowNotification" "$PARAMS"
    exit 1
fi
echo "Core \"$core_file\" found." >> $LOG_FILE

# --- Check if retroarch executable exists ---
if [ ! -f "$RETROARCH" ]; then
    PARAMS="\"params\":{\"title\" : \"run_retroarch error\", \"message\":\"Retroarch exectuable not found\"}"
    kodi_rpc_params "GUI.ShowNotification" "$PARAMS"
    exit 1
fi
echo "Retroarch executable \"$RETROARCH\" found." >> $LOG_FILE

# --- In LibreELEC use this ---
# echo "Shutting down Kodi (LibreELEC) ..." >> $LOG_FILE
# systemctl stop kodi

# --- In Kodibuntu kill the Kodi process after shutdown ---
echo "Shutting down Kodi (Linux) ..." >> $LOG_FILE
kodi_rpc "Application.Quit"
sleep 2
killall -9 kodi
killall -9 kodi.bin

echo "Running Retroarch ..." >> $LOG_FILE
$RETROARCH -L $core_file -v "$2" > $LOG_RETROARCH 2>&1

# --- In LibreELEC use this ---
# echo "Starting Kodi (LibreELEC) ..." >> $LOG_FILE
# systemctl start kodi

# --- In Kodibuntu use this ---
echo "Starting Kodi (Linux) ..." >> $LOG_FILE
/usr/bin/kodi &
sleep 2

# --- Tell Kodi to open AEL in the correct Launcher ---
echo "Starting AEL Launcher ..." >> $LOG_FILE
ael_id="\"addonid\":\"plugin.program.advanced.emulator.launcher\""
ael_pars="\"params\":{\"com\":\"SHOW_ROMS\",\"catID\":\"$3\",\"launID\":\"$4\"}"
PARAMS="\"params\":{$ael_id,$ael_pars}"
kodi_rpc_params "Addons.ExecuteAddon" "$PARAMS"

An a launcher example of how to use it:

Code:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<advanced_emulator_launcher_configuration>
<launcher>
  <name>GameCube (Retroarch wrapper)</name>
  <category>Nintendo</category>
  <year>2001</year>
  <genre>Sixth generation console</genre>
  <developer>Nintendo</developer>
  <rating></rating>
  <plot>The GameCube is a home video game console released by Nintendo in Japan on September 14, 2001; in North America on November 18, 2001; in Europe on May 3, 2002; and in Australia on May 17, 2002. The sixth-generation console is the successor to the Nintendo 64 and competed with Sony Computer Entertainment's PlayStation 2 and Microsoft's Xbox. The GameCube is the first Nintendo console to use optical discs as its primary storage medium. The discs are similar to the miniDVD format; as a result of their smaller size and the console's small disc compartment, the system was not designed to play standard DVDs or audio CDs. The console supports online gaming for a small number of titles via the broadband or modem adapter and connects to the Game Boy Advance via the link cable, allowing players to access exclusive in-game features using the handheld as a second screen and controller.</plot>
  <platform>Nintendo GameCube</platform>
  <application>/home/kodi/bin/retroarch</application>
  <args>dolphin &quot;$rom$&quot; $categoryID$ $launcherID$ $romID$</args>
  <ROM_path>/home/kodi/AEL-ROMs/nintendo-gamecube/</ROM_path>
  <ROM_ext>iso|gcm</ROM_ext>
  <ROM_asset_path>/home/kodi/AEL-assets/nintendo-gamecube</ROM_asset_path>
  <Asset_Prefix>GameCube</Asset_Prefix>
</launcher>
</advanced_emulator_launcher_configuration>

The wrapper script must be place in /home/kodi/bin/run_retroarch.sh and permissions must be 755. Also, for LibreELECT some modifications are required which are commented in the script code. The script checks if Retroarch executable and the core exist. If they don't exist, a warning notification shows up in Kodi. The wrapper script requires the curl command to be installed to use Kodi JSON RPC interface.

There are currently a couple of (minor) problems:

1) Kodi cannot be stopped because AEL uses a blocking launcher. I have to kill the process.

2) When Kodi is restarted is complains that the remote interface cannot be inisialised. This could be a side effect of having to use the kill command with Kodi.

I'm investigating how to solve those problems.
Reply
I have created a new version of the script. I have been doing some tests and if the launcher process is non-blocking Kodi can be stopped using the JSON RPC interface. Tomorrow I will add a per-launcher setting to AEL to make processes non-blocking. This is the new version of the script:

Code:
#!/bin/sh
# Script arguments: core_name "$rom$" $categoryID$ $launcherID$ $romID$
#
RETROARCH="/home/kodi/bin/retroarch"
LIBRETRO_PATH="/home/kodi/bin/libretro/"
LOG_FILE="/home/kodi/bin/run_retroarch.log"
LOG_RETROARCH="/home/kodi/bin/retroarch.log"

kodi_rpc()
{
    METHOD="$1"
    json_str="{\"jsonrpc\":\"2.0\",\"id\":\"1\",\"method\":\"$METHOD\"}\""
    curl -H "Content-type: application/json" -d "$json_str" http://localhost:8080/jsonrpc
}

kodi_rpc_params()
{
    METHOD="$1"
    PARAMS="$2"
    json_str="{\"jsonrpc\":\"2.0\",\"id\":\"1\",\"method\":\"$METHOD\",$PARAMS}\""
    curl -H "Content-type: application/json" -d "$json_str" http://localhost:8080/jsonrpc
}

kodi_rpc_notification()
{
    TITLE="$1"
    MSG="$2"
    PARAMS="\"params\":{\"title\" : \"$TITLE\", \"message\":\"$MSG\"}"
    json_str="{\"jsonrpc\":\"2.0\",\"id\":\"1\",\"method\":\"GUI.ShowNotification\",$PARAMS}\""
    curl -H "Content-type: application/json" -d "$json_str" http://localhost:8080/jsonrpc
}

# --- Print some information ---
echo "Retroarch core  \"$1\"" > $LOG_FILE
echo "ROM filename    \"$2\"" >> $LOG_FILE
echo "Category ID     \"$3\"" >> $LOG_FILE
echo "Launcher ID     \"$4\"" >> $LOG_FILE
echo "ROM ID          \"$5\"" >> $LOG_FILE
echo "PID             \"$$\"" >> $LOG_FILE
echo "Parent PID      \"$PPID\"" >> $LOG_FILE
ps -p $PPID >> $LOG_FILE

# --- Check if libretro core exists ---
core_file="$LIBRETRO_PATH/$1_libretro.so"
if [ ! -f "$core_file" ]; then
    kodi_rpc_notification "run_retroarch error" "Core file $1 not found"
    exit 1
fi
echo "Core \"$core_file\" found." >> $LOG_FILE

# --- Check if Retroarch executable exists ---
if [ ! -f "$RETROARCH" ]; then
    kodi_rpc_notification "run_retroarch error" "Retroarch exectuable not found"
    exit 1
fi
echo "Retroarch executable \"$RETROARCH\" found." >> $LOG_FILE

# --- Check if Retroarch file is executable ---
if [ ! -x "$RETROARCH" ]; then
    kodi_rpc_notification "run_retroarch.sh error" "Retroarch exectuable has non-exec permission"
    exit 1
fi
echo "Retroarch executable has executable permissions." >> $LOG_FILE

# --- In LibreELEC use this ---
# echo "Shutting down Kodi (LibreELEC) ..." >> $LOG_FILE
# systemctl stop kodi

# --- In Kodibuntu kill the Kodi process after shutdown ---
echo "Shutting down Kodi (Linux) ..." >> $LOG_FILE
kodi_rpc "Application.Quit"

# >> If AEL Launcher is non-blocking there is no need to kill Kodi, it will shutdown with JSON
# >> RPC Application.Quit command.
# sleep 2
# killall -9 kodi
# killall -9 kodi.bin

# --- Wait until Kodi has been terminated ---
while true;
do
    kill -0 $PPID 2>/dev/null
    if [ $? -eq 0 ]; then
        echo "Kodi has completely shut down" >> $LOG_FILE
        break
    else
        echo "Kodi has not finished shutting down. Waiting 1 second ..." >> $LOG_FILE
        sleep 1
    fi
done

# --- Run Retroarch ---
echo "Running Retroarch ..." >> $LOG_FILE
$RETROARCH -L $core_file -v "$2" > $LOG_RETROARCH 2>&1

# --- In LibreELEC use this ---
# echo "Starting Kodi (LibreELEC) ..." >> $LOG_FILE
# systemctl start kodi

# --- In Kodibuntu use this ---
echo "Starting Kodi (Linux) ..." >> $LOG_FILE
/usr/bin/kodi &
sleep 2
kodi_rpc_notification "run_retroarch.sh" "Restarted Kodi"

# --- Tell Kodi to open AEL in the correct Launcher ---
echo "Starting AEL Launcher ..." >> $LOG_FILE
ael_id="\"addonid\":\"plugin.program.advanced.emulator.launcher\""
ael_pars="\"params\":{\"com\":\"SHOW_ROMS\",\"catID\":\"$3\",\"launID\":\"$4\"}"
PARAMS="\"params\":{$ael_id,$ael_pars}"
kodi_rpc_params "Addons.ExecuteAddon" "$PARAMS"

# --- END ---
echo "Finishing run_retroarch.sh" >> $LOG_FILE
exit 0
Reply
Thanks for your work @Wintermute0110 I will try to apply some of those lines to my addon lauccher script. It is a very useful option to get back to AEL when closing emulators instead coming back to kodis home page.
Reply
@bite_your_idols Your are welcomed. Today I coded some features in 0.9.7-alpha:

1) I have added the non-blocking launcher option and it seems to work well. Note that you don't need that in LibreELEC.

2) I have solved the bug of Kodi complaining "Cannot initialise the remote interface". Now, I close the child (launched) process file descriptors for blocking (default) and non-blocking launchers. Technicalities: the problem was that by default a child process inherits all open file descriptors of the parent process. Some of the file descriptors are open sockets. When Kodi was restarted by the child process (the wrapper scripts) the socket of the web interface was already in use by the wrapper script itself! Now, all file descriptors are closed so when Kodi is restarted the socket is not in use anymore.

3) kodi-send can only send Kodi Actions. In order to do more sofisticated stuff like show notifications the JSON RPC interface must be used. The JSON RPC interface needs the command curl to be installed. It is a pretty basic command and I'm sure LibreELEC must have it but please check (connect via ssh and type curl).

4) If you can test the script and confirm that it works that would be great. A couple of days ago I thought maybe there was a problem launching shell files but now I tested it works OK with Linux Kodibuntu. However, nobody has confirmed it works OK in LibreELEC.

5) If you get crashes in 0.9.7-alpha and use No-Intro/Redump DATs try to refresh the audit. "Edit Launcher", "Audit ROMs/Launcher view modes", "Update NoIntro audit"
Reply
  •   
  • 1
  • 7
  • 8
  • 9(current)
  • 10
  • 11
  • 12
  •   



Logout Mark Read Team Forum Stats Members Help
Gamestarter: Retrogaming add-ons for LibreELEC (RPi/Generic).1
This forum uses Lukasz Tkacz MyBB addons.