[LINUX] HOW-TO shutdown applications runned by launcher plugin with a remote control

  Thread Rating:
  • 1 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
scalpel Offline
Senior Member
Posts: 106
Joined: Jun 2010
Reputation: 0
Thumbs Up  [LINUX] HOW-TO shutdown applications runned by launcher plugin with a remote control Post: #1
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
(This post was last modified: 2010-12-02 22:43 by scalpel.)
find quote
htrodscott Offline
Member
Posts: 61
Joined: Dec 2009
Reputation: 8
Post: #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.
find quote
scalpel Offline
Senior Member
Posts: 106
Joined: Jun 2010
Reputation: 0
Post: #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]
find quote
htrodscott Offline
Member
Posts: 61
Joined: Dec 2009
Reputation: 8
Post: #4
Thanks a lot. I'll try it when I get home tonight!
find quote
htrodscott Offline
Member
Posts: 61
Joined: Dec 2009
Reputation: 8
Post: #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.
find quote
TheHazel3yes Offline
Senior Member
Posts: 159
Joined: Jan 2010
Reputation: 0
Post: #6
for me it's working great! no more need for irexec to run a command... Wink
find quote
scalpel Offline
Senior Member
Posts: 106
Joined: Jun 2010
Reputation: 0
Post: #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.
find quote
Temar Offline
Senior Member
Posts: 259
Joined: Nov 2008
Reputation: 8
Post: #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
find quote
htrodscott Offline
Member
Posts: 61
Joined: Dec 2009
Reputation: 8
Post: #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.
find quote
TheHazel3yes Offline
Senior Member
Posts: 159
Joined: Jan 2010
Reputation: 0
Post: #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.
find quote
Post Reply