Universal emulator kill switch/exit button
-
Hi I ran into the problem that some emulators were not killable by my meta key binding.
Especially some obscure japanese machines were not killable that way.
I solved the problem for me by adding a watcher daemon via systemd which watches on my selected joystick over the correct button / button combo to be issued and then runs through a list
of possible emulators and kills them via the kill command.The script is not perfect, but you get the idea.
https://gist.github.com/werpu/99ac729a9a66ff3c710bf1d34c7b3db2
Feel free to use and/or adapt it
-
@werpu said in Universal emulator kill switch/exit button:
Especially some obscure japanese machines were not killable that way.
Can you give some examples ? Most of the emulators in your list are, well, non-Libretro cores, so the
Hotkey + Start
might not be applicable to them, so it's normal they don't exit on this key combo. -
@mitu Well the list is just a generic list, the idea is simply to kill the running emulator, which can be anything.
for instance where i ran into problems was the sharp x68000 emulator (served by I think retroarch) but the beauty is that this script simply kills the currently running emulator and throws you back into emustation via hotkey start does not matter if it is scummvm or anything else.
This basically gives a universal exit button the easy way.
If you run into an emulator not working, simply add the process name into the list and be done with it. -
@cyperghost's shutdown script has an option to close the current emulator, by detecting which processes are started from Emulationstation through runcommand. There's no need to configure the emulator names in this case, you might be able to adapt it so it's less configuration. Also, I don't recommend using
kill -9
unconditionally, only when the process is not responding to a normalkill
command. -
@mitu thx i will have a look
-
@mitu said in Universal emulator kill switch/exit button:
Also, I don't recommend using kill -9 unconditionally, only when the process is not responding to a normal kill command.
Yes +1
kill -9 (-SIGKILL) is last resort and lead you in some trouble. But there are some emulators that does not respong to kill -15 (-SIGTERM)
So I wait 2 to 3 seconds and if PID is still alive then SIGKILL signal is sent.@werpu
Array of emulators is nice but you always have to update it. So it's better (imho) to operate through Parent/Child tree -
Thx I could replace the entire emulator loop with a simple call to the universal shutdown script with --es-closeemu, way simpler.
Thanks guys for your insight, I was not aware of the script until you pushed me towards it. -
@werpu You can also take it to the next step - use the built-in triggerhappy service and call the script. Here's a recent topic on how to take a screeenshot when a certain key is pressed on the keyboard.
-
@mitu Ok thanks for the hint, looks good basically a shortcut to what my tcl/expect based service script does, but given that my config already works as it should I probably will skip this for now. The topic is basically closed for me. But I will keep it in mind if the need arises.
If I had known that upfront this would have saved me an hour or two :-)Btw unrelated to that, I learned to love systemd when I did all my configurations regarding the expect script and molten gamepad, it is so much better than the old sysv init system.
-
@werpu said in Universal emulator kill switch/exit button:
If I had known that upfront this would have saved me an hour or two :-)
It's always fun to do things yourself and tinker - this way you learned more systemd trickery :).
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.