Difference between revisions of "Customized Remote Control Keys"

From MythTV Official Wiki
Jump to: navigation, search
(Restart Mythtv key)
m (See Also)
 
(18 intermediate revisions by 8 users not shown)
Line 1: Line 1:
[[Remote Control Key]]s
+
This page documents remote control tips, hints, and customised '''remote control buttons'''. These are generally applicable to all remote control setups. For setup steps and customisations specific to a particular type of remote control see ???
=Remote Control Keys- hints, tips etc=
+
==Tips, Hints, and customised keys for remote controls==
+
  
This page documents remote control tips, hints, and customised '''remote control keys'''.  These are generally applicable to all remote control setups.  For setup steps and customisations specific to a particular type of remote control see ???
+
=Button Customization=
  
===Customised keys===
+
==Alt-Tab Emulation==
 +
You need to have irexec (lirc-x in debian) running to call external scripts and xdotool running in order to emulate keyboard input.
 +
Call the script with:
  
====Restart Mythtv key====
+
<code>
 +
begin
 +
remote = devinput
 +
prog = irexec
 +
button = KEY_CYCLEWINDOWS
 +
config = /usr/local/bin/alttab.sh &
 +
repeat = 0
 +
delay = 0
 +
end
 +
</code>
 +
 
 +
and alttab.sh should be simply:
 +
 
 +
<code>
 +
#!/bin/bash
 +
xdotool key Alt+Tab
 +
exit
 +
</code>
  
 +
==Restart Mythtv Button==
 
Give the mythtv user permission to restart mythtv via sudo. Edit /etc/sudoers and add the following line:
 
Give the mythtv user permission to restart mythtv via sudo. Edit /etc/sudoers and add the following line:
  
Line 20: Line 38:
  
 
Add something like this to the <i>lircrc</i> file in your ~/.mythtv directory (or is it the .lircrc file in your home directory for irexec?) e.g. if user fred runs mythtv on your system this would be <i>/home/fred/.mythtv/lircrc</i>:
 
Add something like this to the <i>lircrc</i> file in your ~/.mythtv directory (or is it the .lircrc file in your home directory for irexec?) e.g. if user fred runs mythtv on your system this would be <i>/home/fred/.mythtv/lircrc</i>:
 
  
 
<code>
 
<code>
Line 27: Line 44:
 
  prog = irexec
 
  prog = irexec
 
  button = OFF
 
  button = OFF
  config = /script/to/re-cycle/everything
+
  config = /usr/local/bin/my_myth_restart
 
  end
 
  end
 
</code>
 
</code>
  
From PaulPick in the mythtv mailing list.
+
Put the following script into <i>/usr/local/bin/my_myth_restart</i>
 +
<code>
 +
#!/bin/sh
 +
 +
sudo /etc/init.d/mythbackend restart
  
==== Configuring the power button to do DPMS sleep/unsleep ====
+
</code>
 +
 
 +
Then make it executable with <code>chmod a+x /usr/local/bin/my_myth_restart</code>
 +
 
 +
From PaulPick in the mythtv mailing list.
  
DPMS is useful for avoiding burned-in screen. Most people do not want to use DPMS or screensavers because you need to press a key on the keyboard or move the mouse to wake up the screen once DPMS activates. This is painful if a remote control is normally used to control Mythtv. If you configure the power button on the remote to toggle DPMS on or off then you can avoid burned-in screens.
+
==Configure power button for DPMS sleep/unsleep==
 +
DPMS is useful for avoiding burned-in screen. Most people do not want to use DPMS or screensavers because you need to press a key on the keyboard or move the mouse to wake up the screen once DPMS activates. This is painful if a remote control is normally used to control Mythtv. If you configure the power button on the remote to toggle DPMS on or off then you can avoid burned-in screens.
  
LIRC can be configured to wake up the Mythtv display from DPMS screen blanking. This is done using a script via irexec. The same button can also be used to make the display go to sleep.   
+
LIRC can be configured to wake up the Mythtv display from DPMS screen blanking. This is done using a script via irexec. The same button can also be used to make the display go to sleep.   
  
 
First edit the ~/.lircrc file to include the following stanza. A good Howto and MCE .lircrc file for Fedora Core 4 or 5 you can find here [http://www.netreveal.com/ddalton/2006/04/htpc_remote_on_fedora_core_4_o_1.html]:
 
First edit the ~/.lircrc file to include the following stanza. A good Howto and MCE .lircrc file for Fedora Core 4 or 5 you can find here [http://www.netreveal.com/ddalton/2006/04/htpc_remote_on_fedora_core_4_o_1.html]:
Line 51: Line 77:
 
</code>
 
</code>
  
Note that we need irexec running to make this all work. For me this was done via the myth-load.sh script, detailed in the main HOWTO Jarod Wilson has written [http://www.wilsonet.com/mythtv].
+
Note that irexec must be running to make this all work. This can be done via the myth-load.sh script, detailed in the main HOWTO Jarod Wilson has written [http://www.wilsonet.com/mythtv], but could be different for other linux distributions such as Debian or SUSE or Ubuntu.
  
Created a shell script in <i>/usr/local/bin/</i>, called <i>mythpowerbutton.sh</i>. Thanks to Yeechang Lee for this script [http://www.gossamer-threads.com/lists/mythtv/users/208553?search_string=My%20experience%20with%20mythtv;#208553]:
+
Create a shell script in <i>/usr/local/bin/</i>, called <i>mythpowerbutton.sh</i>:[http://www.gossamer-threads.com/lists/mythtv/users/235105#235105]
  
<code>
+
  #!/bin/bash
  #!/bin/sh
+
PROG=mythfrontend
 +
STATUS=`ps -e | grep $PROG | grep -v grep | wc -l | awk '{print $1}'`
 
   
 
   
  if [ `cat /tmp/mythsleeptogglestatus` == "off" ]  
+
  if [ `echo $DISPLAY | grep -c ":0"` -ge 1 ]
  then  
+
  then
xset dpms force on;
+
    if [ $STATUS -eq 0 ]
  echo "on" > /tmp/mythsleeptogglestatus
+
    then
else
+
        ( $PROG & )
sleep 1;  
+
    else
xset dpms force off;  
+
   
echo "off" > /tmp/mythsleeptogglestatus
+
        if [ -a /tmp/mythpowerbutton-off ]
fi  
+
        then
</code>
+
                touch /tmp/mythpowerbutton-on;
 +
                exit;
 +
        else
 +
                touch /tmp/mythpowerbutton-off;
 +
                sleep 3;
 +
                if [ -a /tmp/mythpowerbutton-on ]
 +
                then
 +
                    rm -rf /tmp/mythpowerbutton-o* && killall $PROG
 +
                fi
 +
                rm -rf /tmp/mythpowerbutton-o*
 +
        fi
 +
        rm -rf /tmp/mythpowerbutton-o*
 +
    fi
 +
fi
 +
exit 0
  
(This script might be able to be modified to not rely on a temp file, it could use xset to list DPMS status and toggle it?)
+
Make the script executable:
  
Make the script executable.
 
 
<code>
 
 
  chmod a+x /usr/local/bin/mythpowerbutton.sh
 
  chmod a+x /usr/local/bin/mythpowerbutton.sh
</code>
 
  
Then
+
If there are any other sections in the <i>~/.lircrc</i> file that are associated with the POWER button, then they should be removed or you may see multiple things happen at once.
  
<code>
+
Now when the Power button on the remote is pressed, the screen should blank (DPMS on) and with one more press the Mythtv GUI should reappear (DPMS off).
echo $PATH
+
</code>
+
  
and make sure <i>/usr/local/bin</i> is in the list. If not you will have to add it to /etc/??? (???- fix this!) and either log out and back in or start up irexec manually to see it function. If there are any other sections in the <i>~/.lircrc</i> file that are associated with the POWER button, then they should be removed or you may see multiple things happen at once.
+
==Using xset to control DPMS directly==
 +
The script above simply stops and starts the mythfrontend process.
 +
You may be able to use "xset" to enable/disable DPMS blanking of the screen.
  
Now when the Power button on the remote is pressed, the screen should blank (DPMS on) and with one more press the Mythtv GUI should reappear (DPMS off).
+
This will disable Energy Star DPMS and turn on the screen.
 +
xset -dpms dpms force on  
 +
 
 +
This will re-enable Energy Star DPMS and turn off the  
 +
screen after 2 minutes of no activity.
 +
xset +dpms dpms 120
 +
 
 +
==Combining DPMS on/off and Launching Myth==
 +
This script will do two things, it will act as a power button for your screen, most useful if your using a monitor for a screen that does not have a remote control but does obey the DPMS power on and off commands (most modern LCD's). It will also act as a way to launch mythfrontend in case it has crashed/etc. This was originally written for Mythbuntu to allow it to better be used as a dedicated frontend without requiring a mouse/keyboard.
 +
 
 +
Create a shell script in <i>/usr/local/bin/</i>, called <i>mythtvpower.sh</i>
 +
 
 +
#!/bin/bash
 +
PROG=mythfrontend.re
 +
MYTHSTATUS=`pgrep -c $PROG`
 +
MONITORSTAT=`xset q|grep -c Monitor\ is\ On`
 +
DPY=`echo $DISPLAY|sed 's/localhost://'|sed 's/\.\w*$//'`
 +
 +
if [ "$MONITORSTAT" -eq "1" ]; then
 +
        echo "monitor is on!"
 +
        xset -display $DPY dpms force off
 +
elif [ "$MONITORSTAT" -eq "0" ]; then
 +
        echo "monitor is off!"
 +
        xset -display $DPY dpms force on
 +
fi
 +
 +
if [ "$MYTHSTATUS" -eq "0" ]; then
 +
        echo "myth not running!"
 +
        mythfrontend.real -l /var/log/mythtv/mythfrontend.log &
 +
elif [ "$MYTHSTATUS" -eq "1" ]; then
 +
        echo "myth is running!"
 +
fi
 +
exit
 +
 
 +
==Add Repeat to Specific Buttons==
 +
By default, buttons will not continually repeat when held down, but must be pressed repeatedly. For common functions, such as scrolling through the program guide, pressing "Down" over and over gets quite annoying. Fortunately, you can add this behavior manually by specifying the "repeat" attribute.
 +
 
 +
begin
 +
  prog = mythtv
 +
  button = Down
 +
  config = Down
 +
  repeat = 3
 +
end
  
This section originally appeared in [[MCE Remote]].
+
The number specified means that every ''n''th instance will be sent. Depending on your system and remote, you may want to increase or decrease this value. (Note: A value of 1 is probably too fast for most situations.)
  
 +
==See Also==
 +
* [[Setting A Button On Your Remote To Toggle The S/PDIF Audio Source]]
 +
* [[Setting A Button On Your Remote To Restart mythfrontend]]
  
--[[User:Indulis|indulis]] 04:48, 3 October 2006 (UTC)
 
 
[[Category:Remote Controls]]
 
[[Category:Remote Controls]]

Latest revision as of 23:41, 4 January 2012

This page documents remote control tips, hints, and customised remote control buttons. These are generally applicable to all remote control setups. For setup steps and customisations specific to a particular type of remote control see ???

Button Customization

Alt-Tab Emulation

You need to have irexec (lirc-x in debian) running to call external scripts and xdotool running in order to emulate keyboard input. Call the script with:

begin
remote = devinput
prog = irexec
button = KEY_CYCLEWINDOWS
config = /usr/local/bin/alttab.sh &
repeat = 0
delay = 0
end

and alttab.sh should be simply:

#!/bin/bash
xdotool key Alt+Tab
exit

Restart Mythtv Button

Give the mythtv user permission to restart mythtv via sudo. Edit /etc/sudoers and add the following line:

mythtv    ALL=NOPASSWD: /etc/init.d/mythbackend

If you are running mythtv as a different user you will change mythtv to the user name you are using.

This sets up sudo so that user mythtv can do "sudo /etc/init.d/mythbackend restart".

Add something like this to the lircrc file in your ~/.mythtv directory (or is it the .lircrc file in your home directory for irexec?) e.g. if user fred runs mythtv on your system this would be /home/fred/.mythtv/lircrc:

# Power Off/Exit
begin
prog = irexec
button = OFF
config = /usr/local/bin/my_myth_restart
end

Put the following script into /usr/local/bin/my_myth_restart

#!/bin/sh 

sudo /etc/init.d/mythbackend restart

Then make it executable with chmod a+x /usr/local/bin/my_myth_restart

From PaulPick in the mythtv mailing list.

Configure power button for DPMS sleep/unsleep

DPMS is useful for avoiding burned-in screen. Most people do not want to use DPMS or screensavers because you need to press a key on the keyboard or move the mouse to wake up the screen once DPMS activates. This is painful if a remote control is normally used to control Mythtv. If you configure the power button on the remote to toggle DPMS on or off then you can avoid burned-in screens.

LIRC can be configured to wake up the Mythtv display from DPMS screen blanking. This is done using a script via irexec. The same button can also be used to make the display go to sleep.

First edit the ~/.lircrc file to include the following stanza. A good Howto and MCE .lircrc file for Fedora Core 4 or 5 you can find here [1]:

begin
    prog = irexec
    button = Power
    repeat = 3
    config = /usr/local/bin/mythpowerbutton.sh
    #config = Key Alt-Escape CurrentWindow
end

Note that irexec must be running to make this all work. This can be done via the myth-load.sh script, detailed in the main HOWTO Jarod Wilson has written [2], but could be different for other linux distributions such as Debian or SUSE or Ubuntu.

Create a shell script in /usr/local/bin/, called mythpowerbutton.sh:[3]

#!/bin/bash
PROG=mythfrontend
STATUS=`ps -e | grep $PROG | grep -v grep | wc -l | awk '{print $1}'`

if [ `echo $DISPLAY | grep -c ":0"` -ge 1 ]
then
    if [ $STATUS -eq 0 ]
    then
        ( $PROG & )
    else

        if [ -a /tmp/mythpowerbutton-off ]
        then
                touch /tmp/mythpowerbutton-on;
                exit;
        else
                touch /tmp/mythpowerbutton-off;
                sleep 3;
                if [ -a /tmp/mythpowerbutton-on ]
                then
                    rm -rf /tmp/mythpowerbutton-o* && killall $PROG
                fi
                rm -rf /tmp/mythpowerbutton-o*
        fi
        rm -rf /tmp/mythpowerbutton-o*
    fi
fi
exit 0

Make the script executable:

chmod a+x /usr/local/bin/mythpowerbutton.sh

If there are any other sections in the ~/.lircrc file that are associated with the POWER button, then they should be removed or you may see multiple things happen at once.

Now when the Power button on the remote is pressed, the screen should blank (DPMS on) and with one more press the Mythtv GUI should reappear (DPMS off).

Using xset to control DPMS directly

The script above simply stops and starts the mythfrontend process. You may be able to use "xset" to enable/disable DPMS blanking of the screen.

This will disable Energy Star DPMS and turn on the screen.

xset -dpms dpms force on 

This will re-enable Energy Star DPMS and turn off the screen after 2 minutes of no activity.

xset +dpms dpms 120

Combining DPMS on/off and Launching Myth

This script will do two things, it will act as a power button for your screen, most useful if your using a monitor for a screen that does not have a remote control but does obey the DPMS power on and off commands (most modern LCD's). It will also act as a way to launch mythfrontend in case it has crashed/etc. This was originally written for Mythbuntu to allow it to better be used as a dedicated frontend without requiring a mouse/keyboard.

Create a shell script in /usr/local/bin/, called mythtvpower.sh

#!/bin/bash
PROG=mythfrontend.re
MYTHSTATUS=`pgrep -c $PROG`
MONITORSTAT=`xset q|grep -c Monitor\ is\ On`
DPY=`echo $DISPLAY|sed 's/localhost://'|sed 's/\.\w*$//'`

if [ "$MONITORSTAT" -eq "1" ]; then
        echo "monitor is on!"
        xset -display $DPY dpms force off
elif [ "$MONITORSTAT" -eq "0" ]; then
        echo "monitor is off!"
        xset -display $DPY dpms force on
fi

if [ "$MYTHSTATUS" -eq "0" ]; then
        echo "myth not running!"
        mythfrontend.real -l /var/log/mythtv/mythfrontend.log &
elif [ "$MYTHSTATUS" -eq "1" ]; then
        echo "myth is running!"
fi
exit

Add Repeat to Specific Buttons

By default, buttons will not continually repeat when held down, but must be pressed repeatedly. For common functions, such as scrolling through the program guide, pressing "Down" over and over gets quite annoying. Fortunately, you can add this behavior manually by specifying the "repeat" attribute.

begin
 prog = mythtv
 button = Down
 config = Down
 repeat = 3
end

The number specified means that every nth instance will be sent. Depending on your system and remote, you may want to increase or decrease this value. (Note: A value of 1 is probably too fast for most situations.)

See Also