[mythtv-users] Start frontend from irexec

John Morris jmorris at beau.org
Sun May 6 02:30:59 UTC 2012


On Sat, 2012-05-05 at 21:54 +0200, Josu Lazkano wrote:
> Hello all, I am trying to configure my remote to start the frontend.
> 
> I am using gnome on my system, I read this wiki page:
> http://www.mythtv.org/wiki/Frontend_Loading_Script
> 
> I try lots of configuration but I can not start from the desktop, this
> is my script:
> 
> #!/bin/sh
> 
> if [ ! "$(pidof mythfrontend)" ]
> then
>         echo "Mythfrontend is not started. Starting Mythfrontend..."
>         #DISPLAY=:0 xset -dpms
>         #DISPLAY=:0 mythfrontend 2>&1 &
>         mythfrontend
> else
>         echo "Mythfrontend is already started. Stoping Mythfrontend..."
>         killall mythfrontend
> fi
> 
> exit 0

I have dealt with this sort of thing.  I would guess you are starting
irexec as a daemon and it isn't working. If you launched the daemon from
a terminal window it would probably work until you logged out; unless it
is purging your environment 'for your protection' of course.

The nub of the problem is you need both the DISPLAY environment variable
to correctly name the display to connect to, which for 99% of people
will be :0.0 but you also need the XAUTHORITY variable.  In the olden
days it just pointed to ~/.Xauthority and would be trivial to recreate.
Alas, it has been made 'perfectly safe'... again for your protection.

Below is a fragment of bash code to deal with this issue that I have in
production on CENTOS 6.  The idea is to latch onto the session manager
process at the top of the tree and grope around in it's environment
looking for the authority file.  Obviously this is only going to work
reliably if the script that launches irexec is running with root privs.
That means you probably want to make sure it then takes care to run
mythfrontend as the right user.  If you are implementing this as a more
general solution you can just go back into the session manager's
environment and look for the USER variable.

I am running Fedora on the laptop I'm typing this on but XFCE instead of
GNOME3 so I can't tweak it for the post GNOME2 world.

SESSMANPID=`ps aux | grep gnome-session | grep -v root | awk '{print
$2}'`

if [ "$SESSMANPID" = "" ] ; then
        SESSMANPID=`ps aux | grep "sh /usr/bin/startkde" | \
		grep -v root | awk '{ print $2}'`
fi

if [ "$SESSMANPID" = "" ] ; then
        echo "No session identified."
        exit 1
fi

TEMPFILE=`mktemp -t notify.XXXXXX`
cat /proc/$SESSMANPID/environ | tr '\000' '\n' | grep XAUTHORITY \
	| cut -f2 -d '=' >$TEMPFILE
XAUTHORITY=`cat $TEMPFILE`
rm $TEMPFILE

if [ "$XAUTHORITY" = "" ] ; then
        echo "Couldn't find XAUTHORITY, fatal."
        exit 1
fi

DISPLAY=:0.0

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <http://www.mythtv.org/pipermail/mythtv-users/attachments/20120505/442bdc12/attachment.sig>


More information about the mythtv-users mailing list