Linux Single Running Instance
#1
Is there a way to force xbmc to only ever run a single instance?

I haven't nailed down why this happens to me exactly, but it seems to work fine for a couple weeks and then I'll have a crash from a locked up video and then the next time I open xbmc via the remote I'll get 2 instances. Still works fine via mouse click though.

I'll tweak my lirc delay and repeat settings a tad, and all will work again for a few weeks or less. Whatever the problem, if I could restrict xbmc to a single instance, this should all go away. I checked the switches for xbmc but didn't see an option for this. I also searched the forums and couldn't find anything relevant to my problem. Any help is much appreciated.

Cheers

xubuntu 12.04 Precise
xbmc eden
Reply
#2
Maybe you can create a script that checks for an existing XBMC session before deciding whether or not to actually launch XBMC? You can then set your remote button to launch that script rather than XBMC directly.
Code:
#!/bin/bash
ISXBMCUP=`ps -e | grep xbmc | wc -l`   # Check if XBMC already running (don't want to start another session).

if [ $ISXBMCUP -eq 0 ]; then           # If XBMC isn't running, then OK to start it.
  xbmc &
fi
exit
Reply
#3
(2012-12-22, 19:56)artrafael Wrote: Maybe you can create a script that checks for an existing XBMC session before deciding whether or not to actually launch XBMC? You can then set your remote button to launch that script rather than XBMC directly.
Code:
#!/bin/bash
ISXBMCUP=`ps -e | grep xbmc | wc -l`   # Check if XBMC already running (don't want to start another session).

if [ $ISXBMCUP -eq 0 ]; then           # If XBMC isn't running, then OK to start it.
  xbmc &
fi
exit

Instead try:

Code:
ISXBMCUP=`ps -e | grep xbmc | grep -v grep | wc -l`   # Check if XBMC already running (don't want to start another session).

otherwise it'll always return at least one line.
Reply
#4
Thank you very much for the replies.

I guess it is never simple =P
I already start xbmc using a script so I guess I could check for that script instead of xbmc directly, except that script seems leaves behind instances that I have to close manually. (Someone helped me make it and I never figured out why it does that.)

xdotool-xbmc.sh
Code:
#!/bin/bash
xdotool mousemove 2500 0&& screen -d -m xbmc; sleep 35s; devilspie -a
done

ie..
Code:
ps -e | grep xbmc
6153 ?        00:00:00 xdotool-xbmc.sh
6154 ?        00:00:00 xdotool-xbmc.sh
8403 ?        00:00:00 xdotool-xbmc.sh
8729 ?        00:00:00 xdotool-xbmc.sh
9713 ?        00:00:00 xdotool-xbmc.sh
22941 ?        00:00:00 xdotool-xbmc.sh
24174 ?        00:00:00 xdotool-xbmc.sh
24179 pts/3    00:00:00 xbmc
24188 pts/3    00:12:52 xbmc.bin
32614 ?        00:00:00 xdotool-xbmc.sh

Now that I look at it I guess I could just grep xbmc.bin instead. I'll report back if I get it sorted out.

Thanks again.




Reply
#5
@magao,
Hmm... I don't see the grep request itself listed in the output when I use "ps -e", as opposed to something like "ps -ef", which does.
Code:
art@my-laptop:~$ ps -e | grep xbmc
8290 ?        00:00:00 xbmc
8303 ?        00:04:50 xbmc.bin
art@my-laptop:~$ ps -ef | grep xbmc
art       8290     1  0 12:32 ?        00:00:00 /bin/sh /usr/bin/xbmc
art       8303  8290 25 12:32 ?        00:04:54 /usr/lib/xbmc/xbmc.bin
art       8399  8149  0 12:52 pts/0    00:00:00 grep --color=auto xbmc
However, I agree it's probably safer to include "grep -v grep" to remove any possibility of a false-positive from the grep command itself.
Reply
#6
Well that seems to have sorted it. You both have my gratitude. I can't tell you how much this has been frustrating me.

If either of you can surmise why I get the lingering processes for both xdotool-xbmc.sh as well as devilspie it would really feel like Christmas, but either way, I'm ecstatic.

+1 rep around

Cheers

Reply
#7
D'oh. Didn't even notice you'd done -e rather than -ef - I'm just so used to always doing -ef ...
Reply
#8
Is that xdotool worked for you, I am running xbmc over Raspberry pi and one of my pi instance on my Linux pc by ssh. as i am giving xdotool mousemove 10 10 nothing is happening over xbmc screen.
Reply
#9
(2014-07-26, 07:11)rahul_jain Wrote: Is that xdotool worked for you, I am running xbmc over Raspberry pi and one of my pi instance on my Linux pc by ssh. as i am giving xdotool mousemove 10 10 nothing is happening over xbmc screen.

I am using the xdotool to open xbmc in the display I want on my dual monitor setup.
http://forum.xbmc.org/showthread.php?tid=139854
On dual monitor setups, xbmc will open to the screen that the mouse is active on, so I manually move my mouse with xdotool to place it on my secondary monitor and xbmc will launch there every time.
A setting of mousemove 10 10 should place your mouse exactly 10 pixels left, and 10 pixels down from the upper left corner of your screen. It doesn't sound to me like this is what you are trying to do though. Maybe I'm misunderstanding.
Reply

Logout Mark Read Team Forum Stats Members Help
Single Running Instance0