[LINUX] HOW-TO shutdown applications runned by launcher plugin with a remote control
#16
Temar Wrote: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.




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.

I don't fully understand how/when/from where these scripts should be executed.
My target is to run command:
mednafen </path/to/rom.nes>
and before this command will be executed I would like to exit XBMC and then after pressing key on the remote I would like to return to XBMC.
Reply
#17
bedek Wrote:I don't fully understand how/when/from where these scripts should be executed.
My target is to run command:
mednafen </path/to/rom.nes>
and before this command will be executed I would like to exit XBMC and then after pressing key on the remote I would like to return to XBMC.

If you want to exit XBMC first, then you have to take a totally different approach. You could use i.e. irexec to kill XBMC and then start the other program.

The scripts you quoted are ment to be used with the "Executer" or "Launcher" plugin. Instead of running "mednafen /path/to/rom.nes" you would run "/home/xbmc/launcher.sh mednafen /path/to/rom.nes". Still you have to use irexec if you want to switch back to XBMC by pressing a button on your remote.
Reply
#18
Sweet Baby Jesus! Why didn't I think of this. You my friend are a genius. Maybe you should alert Angelscry so he can add this into the first post of the ALA thread.
How to use Git
| AMD Athlon II X3 Triple Core Processor 2.9 GHz |GIGABYTE GA-MA785GM-US2H Mobo 2GB DDR2 Ram | MSI N430GT |
| Logitec Harmony Smart Control Remote| 52" Sharp Aquos LED TV | Denon AVR-X1000 |
| Freenas Server with 18TB ASRock Intel Avoton C2750 |
Reply
#19
htpc guy Wrote:Sweet Baby Jesus! Why didn't I think of this. You my friend are a genius. Maybe you should alert Angelscry so he can add this into the first post of the ALA thread.

Are you talking to me? If so, well thanks, but I have no idea what you are talking about. Which ALA thread?
Reply
#20
Temar Wrote:If you want to exit XBMC first, then you have to take a totally different approach. You could use i.e. irexec to kill XBMC and then start the other program.

The scripts you quoted are ment to be used with the "Executer" or "Launcher" plugin. Instead of running "mednafen /path/to/rom.nes" you would run "/home/xbmc/launcher.sh mednafen /path/to/rom.nes". Still you have to use irexec if you want to switch back to XBMC by pressing a button on your remote.

First of all thnx for super fast answer Smile

Unfortunately this is not still clear for me, I've few short questions:

1) So the method described above is not "killing" XBMC it just puts it into "sleep" mode which is expressed by " -STOP" option of killall command ? And as result after exiting form emulator (mednafen / zsnes) XBMC will return to it's state before starting emulator ?

2) I understand that to finish emulator I need to call script "/home/xbmc/launcher-kill.sh" from remote control using irexec program ?

3) Script "launcher-run.sh" will be not directly used by me - it's only used internally
by "launcher.sh" ?

4) And just aside of this discussion - if I would like to kill XBMC before running emulator the script probably would look like this:

killall xbmc.bin
megnafen -fs 1 /path/to/rom.nes
xbmc.bin

and the difference between this method and your method would be that XBMC would not return to it's initial state before running emulator but to normal state - same as the one then starting it for a first time when media centre is starting up.
Reply
#21
bedek Wrote:1) So the method described above is not "killing" XBMC it just puts it into "sleep" mode which is expressed by " -STOP" option of killall command ? And as result after exiting form emulator (mednafen / zsnes) XBMC will return to it's state before starting emulator ?

Yes, if you send a stop signal to a process the operating system will no longer execute the code. It just suspends execution until it gets the continue-signal.

Quote:2) I understand that to finish emulator I need to call script "/home/xbmc/launcher-kill.sh" from remote control using irexec program ?

Either you use irexec to kill the process or you have to exit the emulator manually.

Quote:3) Script "launcher-run.sh" will be not directly used by me - it's only used internally
by "launcher.sh" ?

Yes, launcher-run.sh is just required to get the process id of the emulator process. It should not be called directly.

Quote:4) And just aside of this discussion - if I would like to kill XBMC before running emulator the script probably would look like this:

killall xbmc.bin
megnafen -fs 1 /path/to/rom.nes
xbmc.bin

and the difference between this method and your method would be that XBMC would not return to it's initial state before running emulator but to normal state - same as the one then starting it for a first time when media centre is starting up.

Basically yes, but it's not that easy. There are multiple problems which you have to overcome. First, if you exit XBMC it will be restarted immediately by the XBMC startup scripts. So you have to edit the XBMC init scripts to prevent that. Second, if you kill XBMC and you prevent the init scripts from restarting it, then your X server will terminate. So you can't start megnafen directly but you have to start a new X session and then launch megnafen.
Reply
#22
Thank you for answer - I'll use your method, looks to be the simplest solution.
Reply
#23
Temar Wrote:Are you talking to me? If so, well thanks, but I have no idea what you are talking about. Which ALA thread?

The Advanced Launcher Aplication (ALA) Thread. This post would help a lot of people out.

http://forum.xbmc.org/showthread.php?tid=85724
How to use Git
| AMD Athlon II X3 Triple Core Processor 2.9 GHz |GIGABYTE GA-MA785GM-US2H Mobo 2GB DDR2 Ram | MSI N430GT |
| Logitec Harmony Smart Control Remote| 52" Sharp Aquos LED TV | Denon AVR-X1000 |
| Freenas Server with 18TB ASRock Intel Avoton C2750 |
Reply
#24
Works fine, but to make it work I had to update my distribution Smile
sudo aptitude dist-upgrade
then all works fine

The only small problem is sound - I need to work on it.
Reply
#25
bedek Wrote:I've created all these scripts, but unfortunately it doesn't work.

Hehe, well I never tested them Big Grin

Quote:Looks like after issuing script command :

next command - so starting emulator cause that the screen goes black Sad

I can see that emulator (mednafen) process is running (ps -aef | grep mednafen)
The only option now is to kill mednafen:
killall -9 mednafen
and xbmc returns to launcher screen.

My guess is you are still seeing the XBMC screen, but as it is not updated you just see a black background. The mednafen window is probably behind the XBMC screen.

Quote:Altough I've observerd then when I run emulator as initially (withoud killall .. STOP CONT..) it runs in full screen and then when I login over ssh and run command:
/usr/bin/killall -STOP xbmc.bin
emulator performance increases significantly.

There are multiple ways you could fix this:

1. You could try and run XBMC in windowed mode hoping that the mednafen window will be opened as front window as XBMC is no longer in fullscreen mode.

2. You could run a simple window manager like fluxbox which should put the mednafen window to the front. You should start fluxbox in the launcher.sh script and kill it in the kill script.

3. You could use a tool like wmctrl to minimize the XBMC window in the launcher.sh script and maximize it in the kill script.

I've tested none of these solutions but basically the wmctrl solution should work. In this thread a guy uses wmctrl to manipulate the XBMC window.
Reply
#26
Temar Wrote:Hehe, well I never tested them Big Grin



My guess is you are still seeing the XBMC screen, but as it is not updated you just see a black background. The mednafen window is probably behind the XBMC screen.



There are multiple ways you could fix this:

1. You could try and run XBMC in windowed mode hoping that the mednafen window will be opened as front window as XBMC is no longer in fullscreen mode.

2. You could run a simple window manager like fluxbox which should put the mednafen window to the front. You should start fluxbox in the launcher.sh script and kill it in the kill script.

3. You could use a tool like wmctrl to minimize the XBMC window in the launcher.sh script and maximize it in the kill script.

I've tested none of these solutions but basically the wmctrl solution should work. In this thread a guy uses wmctrl to manipulate the XBMC window.

Sorry I was editing my post while you've been answering on it's original version Smile
So current result is that almost everything works - I've used the scripts from:
http://forum.xbmc.org/showpost.php?p=659...stcount=14
My current situation is described in:
http://forum.xbmc.org/showpost.php?p=693...stcount=24

Thank you for help.
Reply
#27
bedek Wrote:Sorry I was editing my post while you've been answering on it's original version Smile
So current result is that almost everything works - I've used the scripts from:
http://forum.xbmc.org/showpost.php?p=659...stcount=14
My current situation is described in:
http://forum.xbmc.org/showpost.php?p=693...stcount=24

Thank you for help.

Now all works fine: emulator start and works fast, sound is working great, solution was to pause pulse sound server when starting mednafen, so instead starting mednafen I'm using command:

Quote:pasuspender -- mednafen game_file.nes

PS
Command above is used in script from:
http://forum.xbmc.org/showpost.php?p=659...stcount=14

So the final script for starting emulator looks like this:

Quote:/usr/bin/killall -STOP xbmc.bin
$HOME/Emulators/Launcher/launcher.sh pasuspender -- /usr/games/mednafen -fs 1 $1
/usr/bin/killall -CONT xbmc.bin

Thnx everyone for help Smile
Reply
#28
bedek Wrote:... solution was to pause pulse sound server....

If this is a dedicated XBMC box, you might want to uninstall the pulse sound server and use ALSA directly. Saves you trouble with other programs you might want to start in the future.

You only need the pulse audio server if you want to plug in sound cards on the fly, i.e. USB sound cards or bluetooth headsets. If you don't need this feature, you can uninstall pulse and use alsa directly.
Reply
#29
Temar Wrote:If this is a dedicated XBMC box, you might want to uninstall the pulse sound server and use ALSA directly. Saves you trouble with other programs you might want to start in the future.

You only need the pulse audio server if you want to plug in sound cards on the fly, i.e. USB sound cards or bluetooth headsets. If you don't need this feature, you can uninstall pulse and use alsa directly.

Which of these packages I should uninstall ?
Code:
gstreamer0.10-pulseaudio            
libpulse-browse0                
libpulse0                    
libpulsecore9                    
pulseaudio                    
pulseaudio-esound-compat            
pulseaudio-module-gconf                
pulseaudio-module-hal                
pulseaudio-module-x11                
pulseaudio-utils
Reply
#30
bedek Wrote:Which of these packages I should uninstall ?
Code:
gstreamer0.10-pulseaudio            
libpulse-browse0                
libpulse0                    
libpulsecore9                    
pulseaudio                    
pulseaudio-esound-compat            
pulseaudio-module-gconf                
pulseaudio-module-hal                
pulseaudio-module-x11                
pulseaudio-utils

Should be enough to remove "pulseaudio". To allow applications to use ALSA directly you have to add the users to the group "audio":

Code:
sudo usermod -a -G audio xbmc

This will add the user "xbmc" to the group "audio". You can repeat this command for any user who needs access to the sound devices.
Reply

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