[ATrpms-users] gnome-screensaver with mythtv?

Jeffrey J. Kosowsky atrpms at kosowsky.org
Wed Dec 30 10:34:45 CET 2009


Paulo Cavalcanti wrote at about 06:28:50 -0200 on Wednesday, December 30, 2009:
 > On Wed, Dec 30, 2009 at 3:35 AM, Jeffrey J. Kosowsky <atrpms at kosowsky.org>wrote:
 > 
 > > Paul wrote at about 16:06:32 +1100 on Wednesday, December 30, 2009:
 > >  > On 30/12/2009 2:05 PM, Jeffrey J. Kosowsky wrote:
 > >  > > Anybody know how (if?) you can have mythtv disable the screensaver
 > >  > > when at TV or Video stream is running?
 > >  > >
 > >  > > Thanks
 > >  > >
 > >  > > _______________________________________________
 > >  > > atrpms-users mailing list
 > >  > > atrpms-users at atrpms.net
 > >  > > http://lists.atrpms.net/mailman/listinfo/atrpms-users
 > >  > >
 > >  >
 > >  > System->Preferences->Look & feel-> Screen saver
 > >
 > > I know I can shut it off manually whenever I want
 > > The question was how do I have *mythtv* disable the screensaver...
 > >
 > >
 > If you use xscreensaver (not gnome-screensaver), you can use a script like
 > that,
 > for calling mythfrontend:
 > 
 > 
 > #!/bin/sh
 > 
 > xscreensaver-command -exit
 > 
 > mythfrontend
 > 
 > xscreensaver &
 > 

I was hoping that there would be a cleaner way than using a
wrapper. It would be great if you could specify a list of programs
(either via a config file or via a gui) that gnome-screensaver would
check before activating.

But if I need to do a wrapper, it seems like I could do a similar
thing with gnome-screensaver. 

If you want the analog of the xscreensaver script, you can just do:

----------------------------------------------------------------
#!/bin/bash
gnome-screensaver-command -exit
mythfrontend
gnome-screensaver
----------------------------------------------------------------

However, if you want something a little fancier and more robust you
can use the '--inhibit' switch and also add a trap to ensure that the
inhibition is removed (and the screensaver restored) even if you kill
the script and it exits non-naturally. The trap probably has more
error checking than necessary, but why not be paranoid...

Note the use of "gnome-screensaver-command --inhibit" together with
using the trap to selectively only kill the corresponding process on
termination means that you can have several wrapper scripts for
multiple programs that independently inhibit the screensaver such that
the screensaver only can activate once *all* the programs terminate.

-----------------------------------------------------------------------
#/bin/bash
#Wrapper to inhibit gnome-screensaver when launching mythfrontend
#Jeff Kosowsky

function killonexit ()
{
	procs=$(pgrep -d ' ' -u $USER -f "$command")
	[[ -n $pid  && "$procs" =~ $pid ]] && kill -KILL $pid
}

trap killonexit INT EXIT

command='gnome-screensaver-command --inhibit --application-name="mythfrontend" --reason="Mythfrontend running..."'

$command &
pid=$!
mythfrontend

-------------------------------------------------------------------------




More information about the atrpms-users mailing list