[LINUX] HOW-TO shutdown applications runned by launcher plugin with a remote control
#1
Thumbs Up 
1. create script called shutdown.sh in your home directory
this will kill your app, zsnes in my example
Code:
#!/bin/bash
killall zsnes

2. edit keymap in /usr/share/xbmc/system/keymaps/remote.xml
choose your key which will be execute script and add launch for script
i choose mute key
Quote:<mute>System.Exec(/home/youruser/shutdown.sh)</mute>

3. save and test

If you have better idea tell it and don't forget give your results.


Regards
Reply
#2
Awesome!

I was just thinking about this. One question though... In the shutdown.sh code, you only have "killall zsnes." If I have mednafen, mupen64plus, zsnes and gens installed, would it look like this?

Code:
#!/bin/bash
killall zsnes
killall mednafen
killall mupen64plus
killall gens

...or would I have to create a shutdown file for each emu?

Thanks.
Reply
#3
Yes it just like your but you should add some specific character at the end line that will cause make another command :

Code:
#!/bin/bash
killall zsnes [color=green]&[/color]
killall mednafen [color=green]&[/color]
killall mupen64plus [color=green]&[/color]
killall gens [color=green]&[/color]
Reply
#4
Thanks a lot. I'll try it when I get home tonight!
Reply
#5
I tried this and it isn't working for me...

Nothing apparent happened when I pressed the remote button. I then pressed esc on the keyboard, and rather than exiting back to the menu with the roms like normal, it took the emulator screen and shrunk it to the top left quarter of the screen (there was also an X in the middle of the screen). When I pressed esc again, XBMC restarted (not the whole system, just XBMC).

I double checked my code in remote.xml and it was correct. I also made the shutdown.sh file executable. I then tried eliminating all the excess killall commands (thinking this might change something), so it looked just like the first example you posted with only one line and one emu. This gave the same results as the first time. Do you have any ideas on what might be going on?

I'm really looking forward to getting this to work.

Thanks.
Reply
#6
for me it's working great! no more need for irexec to run a command... Wink
Reply
#7
htrodscott Wrote:I tried this and it isn't working for me...

Nothing apparent happened when I pressed the remote button. I then pressed esc on the keyboard, and rather than exiting back to the menu with the roms like normal, it took the emulator screen and shrunk it to the top left quarter of the screen (there was also an X in the middle of the screen). When I pressed esc again, XBMC restarted (not the whole system, just XBMC).

I double checked my code in remote.xml and it was correct. I also made the shutdown.sh file executable. I then tried eliminating all the excess killall commands (thinking this might change something), so it looked just like the first example you posted with only one line and one emu. This gave the same results as the first time. Do you have any ideas on what might be going on?

I'm really looking forward to getting this to work.

Thanks.

For me doesn't work with some keys on remote, don't know why. Try at first on keyboard.xml and add this function to a keyboard key. There is one problem, system.exec command minimalize xbmc and if you press this button without app runned by launcher plugin, then xbmc will minimalize.
Reply
#8
scalpel Wrote:If you have better idea tell it and don't forget give your results.

Instead of using killall, it's also possible to kill exactly the one process which was launched. This however requires to store the PID of the launch-script.

Here is a very simple example how this can be accomplished:

launch.sh
Code:
#!/bin/sh

## save current PID to /tmp/launch.pid
echo $$ > /tmp/launch.pid

## it is important to use "exec" to launch the application
## as otherwise the shell will fork a new process and the pid will change
exec "$@"

You can use launch.sh to launch any application, i.e.: launch.sh firefox

kill.sh
Code:
#!/bin/sh

PID=`cat /tmp/launch.pid`

kill $PID
Reply
#9
Temar-
Could you please explain this method a bit more? I'm still learning and could use a bit mote detail. Thanks.

Everyone else...
Pressing esc on the keyboard works so well. Isn't there a way to map a keyboard esc press to a key on the remote and use that to close the launched emu? Thanks again to everyone. This is exactly what I need to finish up my emu install.
Reply
#10
Totally agree, a simple ESC on the remote would be fine. AFAIK there are possibilities with lirc (and its tools), however you'd have to install/activate them and I think most of us want to go the cleanest and simplest way.
Reply
#11
What does the "allow remote to send keyboard presses" in the system options do? Would that help with this problem? I've searched around and haven't found much about it.
Reply
#12
htrodscott Wrote:Temar-
Could you please explain this method a bit more? I'm still learning and could use a bit mote detail. Thanks.

Hmm, do you have a specific question? I don't really know what to explain. Basically the launch script saves the process identifier into a file and then starts the application which was given on the command line as parameter.

The kill script reads the process id from the file and kills the specifig process which was launched by launch.sh. For those who use fluxbox as windowmanager they can add a "killall fluxbox" or get the PID with "pidof fluxbox" to kill the fluxbox process.
Reply
#13
Temar-

More specifically, I am running Dharma RC2 off the internal HDD of an Acer Aspire Revo 3610. I currently use the "Launcher" add-on to launch roms with the appropriate emus. When I select the rom I want, the launcher program first calls out...

/home/xbmc/launcher.sh
Code:
/usr/bin/killall -STOP xbmc.bin
"$@"
/usr/bin/killall -CONT xbmc.bin

...and then calls out the emu. I do this because the I need all the cycles I can get to run the mupen64plus emu smoothly, and killing XBMC during the use of it helps significantly.

That being said, is there a way to work that code you gave into my system of killing XBMC while I run the emu, and then using a remote button to exit the emu and bring XBMC back?

I hope this was specific enough.

Thanks again.
Reply
#14
htrodscott Wrote:I currently use the "Launcher" add-on to launch roms with the appropriate emus. When I select the rom I want, the launcher program first calls out...

/home/xbmc/launcher.sh
Code:
/usr/bin/killall -STOP xbmc.bin
"$@"
/usr/bin/killall -CONT xbmc.bin

...and then calls out the emu. I do this because the I need all the cycles I can get to run the mupen64plus emu smoothly, and killing XBMC during the use of it helps significantly.

So currently you have to exit the emu manually and then the XBMC process continues. With my solution you wouldn't be able to exit the emu manually anymore because XBMC would no longer get the continue-signal - you would have to use a button on your remote to exit the emu. However you could workaround that problem by using two launch-scripts.


Quote:That being said, is there a way to work that code you gave into my system of killing XBMC while I run the emu, and then using a remote button to exit the emu and bring XBMC back?

A solution which would allow you to either exit the emu manually or kill it using a button on your remote, could look like this:

/home/xbmc/launcher.sh
Code:
#!/bin/sh

/usr/bin/killall -STOP xbmc.bin

/home/xbmc/launcher-run.sh "$@"

/usr/bin/killall -CONT xbmc.bin


/home/xbmc/launcher-run.sh
Code:
#!/bin/sh

echo $$ > /home/xbmc/launcher.pid

exec "$@"


/home/xbmc/launcher-kill.sh
Code:
#!/bin/sh

kill `cat /home/xbmc/launcher.pid`

As your XBMC process is not running, you can not add the kill-script to your remote.xml file, like the OP suggested in his first post. Instead you have to use "irexec" to execute the kill script when a button on the remote is pressed.
Reply
#15
I'll try this out... Now all I need to do is learn about "irexec." Shocked

Thanks for your help. I'll post after I try it.
Reply

Logout Mark Read Team Forum Stats Members Help
[LINUX] HOW-TO shutdown applications runned by launcher plugin with a remote control1