[mythtv-users] how to make idle frontend exit?

Thomas Boehm mythtv-users at lists.boehmi.net
Mon Jul 9 12:07:42 UTC 2012


Petr Stehlik wrote:
> in the new 0.25 mythfrontend there's an idle timer. How can I set it up
> so that the final action is not the current "turn off screen" but "exit
> the frontend" or "run this sleep script"?

I have a much simpler approach than Mike. When the mythtv user logs in I
run the Perl script below to another script which ends mythfrontend. You
need to use xscreensaver since gnome-screensaver doesn't seem to work
with MythTV (anymore).

-----------------------------
> #!/usr/bin/perl
> 
> my $blanked = 0;
> open (IN, "xscreensaver-command -watch |");
> while (<IN>) {
>         if (m/^(BLANK|LOCK)/) {
>                 if (!$blanked) {
>                          system "/usr/local/bin/kill_frontend_on_idle.sh";
>                          $blanked = 1;
>                 }
>         } elsif (m/^UNBLANK/) {
>                  system "sound-on";
>                  $blanked = 0;
>         }
> } 
------------------------------

The script which gets executed looks like this.

------------------------------
> #!/bin/bash
> #set -x
> DELAY=2
> echo "escape"
> nc localhost 6546 <<EOF
>         key escape
> EOF
> sleep $DELAY
> echo "enter"
> nc localhost 6546 <<EOF
>         key enter
> EOF
> sleep $DELAY
> echo "mainmenu"
> nc localhost 6546 <<EOF
>         jump mainmenu
> EOF
> sleep $DELAY
> echo "escape"
> nc localhost 6546 <<EOF
>         key escape
> EOF
> sleep $DELAY
> echo "down"
> nc localhost 6546 <<EOF
>         key down
> EOF
> sleep $DELAY
> echo "enter"
> nc localhost 6546 <<EOF
>         key enter
> EOF
> sleep 4
> 
> killall mythfrontend.real
> killall mythfrontend
--------------------------------

In case a show is paused it adds a bookmark, goes to the mainmenu and
exits mythfrontend gracefully. If that fails, mythfrontend gets killed
the hard way. I had to add a delay of two seconds between each key
press, otherwise some of them wouldn't be executed.

HTH
Thomas


More information about the mythtv-users mailing list