Kodi Community Forum

Full Version: LIRC Power Button Remapping Issue
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm trying to change the functionality of the Power Button on my remote control, but I can't seem to get it to do anything besides its default function.

Like many others before me, I want the power button to turn off the screen but not the machine itself, as it also functions as a seedbox and I want it to stay on 24/7.
Using this source, I was able to put together the script monitor_control.sh, shown here:
Code:
#!/bin/bash

VOLUME=$(aumix -vq | awk '{ print $3 }' )
MONITOR=$( xset -q | grep Monitor | awk ' { print $3 $4 } ' )

case "$MONITOR" in
"On")
if [ "$VOLUME" != "0" ] ; then
mute
fi
xset dpms force standby
;;
*)
xset dpms force on
sleep 1
xset s reset
if [ "$VOLUME" == "0" ] ; then
mute # unmute actually                            
fi
;;
esac
After a bit of tweeking from the original source, the script runs perfectly when I execute it from the command line, so I know that it isn't the issue.


I also created an .lircrc file in the xbmc home directory, and linked the shell script to the remote control. The file is as follows:
Code:
# Power Button
begin
        prog = irexec
        button = Power
        repeat = 4
        config = /home/monitor_control.sh
end


In my lircmap.xml file, I removed the line for "<power>Power</power>," but the computer still shuts down as soon as the power button is pressed. I've also tried remapping the power button to other functions like "<start>Power</start>" but to no avail.

Is there something here that I am failing to do properly? I'm still kinda new to all of this.

Thanks in advance for any help.
My guess is that you are editing the wrong Lircmap.xml or remote.xml files.
What is the path of the files you are editing?


Are you sure your Power button is named Power in lircd.conf?


You may also need the remote name in the .lircrc file
First of all, thanks for the speedy reply. Nod

So I need a "remote.xml" file? I don't have one and everything has functioned well up until this point. In fact, I don't have a keymap.xml file in the ".xbmc/userdata/keymaps" folder either. I don't think I have ever quite understood the difference between keymap.xml and lircmap.xml, let alone remote.xml. Could you explain? The xbmc wiki is kind of vague in that area. It says not to confuse them, but little else.

Quote:What is the path of the files you are editing?

My lircmap.xml is in the ".xbmc/userdata" folder, and currently contains the following:
Code:
<lircmap>
<remote device="mceusb">
<pause>Pause</pause>
<stop>Stop</stop>
<forward>Forward</forward>
<reverse>Rewind</reverse>
<left>Left</left>
<right>Right</right>
<up>Up</up>
<down>Down</down>
<select>OK</select>
<pageplus>ChanUp</pageplus>
<pageminus>ChanDown</pageminus>
<back>Back</back>
<menu>PreviousMenu</menu>
<title>Play</title>
<info>More</info>
<skipplus>Skip</skipplus>
<skipminus>Replay</skipminus>
<display>Teletext</display>
<start>Home</start>
<record>Record</record>
<volumeplus>VolUp</volumeplus>
<volumeminus>VolDown</volumeminus>
<mute>Mute</mute>
<myvideo>Videos</myvideo>
<mymusic>Music</mymusic>
<mypictures>Pictures</mypictures>
<mytv>TV</mytv>
<one>One</one>
<two>Two</two>
<three>Three</three>
<four>Four</four>
<five>Five</five>
<six>Six</six>
<seven>Seven</seven>
<eight>Eight</eight>
<nine>Nine</nine>
<zero>Zero</zero>
<mytv>Red</mytv>
<mymusic>Green</mymusic>
<mypictures>Yellow</mypictures>
<myvideo>Blue</myvideo>
</remote>
</lircmap>
Similarly, my lircd.conf is in the "/etc/lirc/" folder, and currently contains the following:
Code:
# brand:                        HP
# model no. of remote control:  TSGH-IR01
# devices being controlled by this remote: HP Slimline S3100y
#
# RC-6 config file
#
# source: http://home.hccnet.nl/m.majoor/projects_remote_control.htm
#         http://home.hccnet.nl/m.majoor/pronto.pdf
#
# used by: Philips
#
#########
#
# Philips Media Center Edition remote control
# For use with the USB MCE ir receiver
#
# Dan Conti  dconti|acm.wwu.edu
#
# Updated with codes for MCE 2005 Remote additional buttons
# *, #, Teletext, Red, Green, Yellow & Blue Buttons
# Note: TV power button transmits no code until programmed.
# Updated 12th September 2005
# Graham Auld - mce|graham.auld.me.uk
#
# Radio, Print, RecTV are only available on the HP Media Center remote control
#
#
# Updated with codes for MCE 2007 Remote additional buttons
# Visualization, Aspect, SlideShow, Eject
# Note:
# Renamed some buttons: DVD->DVDMenu, More->MoreInfo, Star->Asterisk, Hash->Pound
# Note:
# Blue, Yellow, Green, Red, and Teletext buttons do not exist on the HP remote

begin remote

  name        mceusb
  bits                 16
  flags  RC6|CONST_LENGTH
  eps                  30
  aeps                100

  header       2667   889
  one           444   444
  zero          444   444
  pre_data_bits        21
  pre_data        0x37FF0
  gap              105000
  toggle_bit           22
  rc6_mask    0x100000000


      begin codes

#seen on HP Pavilion dv3t remote  --Tim Mann, 3 Nov 2009                                    
        Media         0x00007b7f
        PlayPause     0x00007b91


#unused by HP remote
        Blue          0x00007ba1
        Yellow        0x00007ba2
        Green         0x00007ba3
        Red           0x00007ba4
        Teletext      0x00007ba5

#ba6 - bae unused
        BA6           0x00007ba6
        BA7           0x00007ba7
        BA8           0x00007ba8
        BA9           0x00007ba9
        BAA           0x00007baa
        BAB           0x00007bab
        BAC           0x00007bac
        BAD           0x00007bad
        BAE           0x00007bae

        Radio         0x00007baf
        Print         0x00007bb1

#bb2 - bb4 unused
        BB2           0x00007bb2
        BB3           0x00007bb3
        BB4           0x00007bb4

        Videos        0x00007bb5
        Pictures      0x00007bb6
        RecTV         0x00007bb7
        Music         0x00007bb8
        TV            0x00007bb9

#bba - bbf unused
        BBA           0x00007bba
        BBB           0x00007bbb
        BBC           0x00007bbc
        BBD           0x00007bbd
        BBE           0x00007bbe
        BBF           0x00007bbf
#bc1 - bca unused
        BC1           0x00007bc1
        BC2           0x00007bc2
        BC3           0x00007bc3
        BC4           0x00007bc4
        BC5           0x00007bc5
        BC6           0x00007bc6
        BC7           0x00007bc7
        BC8           0x00007bc8
        BC9           0x00007bc9
        BCA           0x00007bca

        Eject         0x00007bcb
        SlideShow     0x00007bcc
        Visualization 0x00007bcd

#bce - bcf unused
        BCE           0x00007bce
        BCF           0x00007bcf
#bd1 - bd7 unused
        BD1           0x00007bd1
        BD2           0x00007bd2
        BD3           0x00007bd3
        BD4           0x00007bd4
        BD5           0x00007bd5
        BD6           0x00007bd6
        BD7           0x00007bd7

        Aspect        0x00007bd8
        Guide         0x00007bd9
        LiveTV        0x00007bda
        DVD           0x00007bdb
#NoGap
        Back          0x00007bdc
        OK            0x00007bdd
        Right         0x00007bde
        Left          0x00007bdf
        Down          0x00007be0
        Up            0x00007be1
#NoGap
        Star          0x00007be2
        Hash          0x00007be3
#NoGap
        Replay        0x00007be4
        Skip          0x00007be5
        Stop          0x00007be6
        Pause         0x00007be7
        Record        0x00007be8
        Play          0x00007be9
        Rewind        0x00007bea
        Forward       0x00007beb
#NoGap
        ChanDown      0x00007bec
        ChanUp        0x00007bed
        VolDown       0x00007bee
        VolUp         0x00007bef
#NoGap
        More          0x00007bf0
        Mute          0x00007bf1
        Home          0x00007bf2
        Power         0x00007bf3
#NoGap
        Enter         0x00007bf4
        Clear         0x00007bf5
#NoGap
        Nine          0x00007bf6
        Eight         0x00007bf7
        Seven         0x00007bf8
        Six           0x00007bf9
        Five          0x00007bfa
        Four          0x00007bfb
        Three         0x00007bfc
        Two           0x00007bfd
        One           0x00007bfe
        Zero          0x00007bff
      end codes

end remote

Quote:You may also need the remote name in the .lircrc file
What would I have to name it, and how is the syntax to specify said name?
check /usr/share/xbmc/system/Lircmap.xml and Disable the power button

.lircrc might look like

Code:
begin
     remote = mceusb
     button = Power
     prog = irexec
     repeat = 0
     config = /home/monitor_control.sh             [color=Red][b][size=medium]<---------------------[/size][/b][/color]
end


Edit: you sure the script is in /home and not /home/xbmc?
Your script looks good, as does your .lircrc file. Do you have irexec running? To ensure it started properly, I added this to my /etc/init.d/rc.local file

su -c '/usr/bin/irexec -d /home/xbmc/.lircrc' -l xbmc

Also, I don't have a lircmap.xml file, and I think the reason your setup works fine without a remote.xml file is that it's using the default values for everything. I don't know if you can delete a command in the lircmap file and have it not propogate, but i do know that if you create an empty entry in the remote.xml file it will override the activity - similar to important thing to entries like this

<power></power>

Removing the command in the definition overrides it. I actually have a similar setup - I have the power button mapped to a custom reboot script

begin
prog = irexec
button = Power
config = /home/xbmc/scripts/reboot.sh
end
boykster Wrote:Your script looks good, as does your .lircrc file. Do you have irexec running? To ensure it started properly, I added this to my /etc/init.d/rc.local file

su -c '/usr/bin/irexec -d /home/xbmc/.lircrc' -l xbmc

Also, I don't have a lircmap.xml file, and I think the reason your setup works fine without a remote.xml file is that it's using the default values for everything. I don't know if you can delete a command in the lircmap file and have it not propogate, but i do know that if you create an empty entry in the remote.xml file it will override the activity - similar to important thing to entries like this

<power></power>

Removing the command in the definition overrides it. I actually have a similar setup - I have the power button mapped to a custom reboot script

begin
prog = irexec
button = Power
config = /home/xbmc/scripts/reboot.sh
end

I dont think so.

He's got a lircmap. He posted it. In addition the path for the script in .lircrc is suspect.


The files you think you dont have are likely in the /usr/share/xbmc directory.
Yep, you're right - my Lircmap.xml is in /usr/share/xbmc/system, but I'm not sure that deleting a command from lircmap.xml will override the key being passed to XBMC and the event firing.

I would use irw and irexec (with XBMC stopped) to confirm that lirc and the custom script work in the absence of XBMC,and then once that's solid approach getting it to work with XBMC.

I have the power button remapped on my setup, and I posted the details above. I added a command to .lircrc file, and removed the command entry from my remote.xml file - not delete, but leave the key, but remove the command. Not sure if that's necessary, but that's what worked for me.

His setup is obviously still processing the XBMC default action for that key, and removing it from lircmap.xml didn't solve the issue.

It might be as simple as adding a remote.xml file with the following:
Code:
<keymap>
  <global>
    <remote>
      <power></power>
    </remote>
   </global>
</keymap>
Quote:you sure the script is in /home and not /home/xbmc?
Good catch, FishOil! That was definitely my bad, and its the kind of thing that I would probably have spent a couple more hours pulling my hair out before I noticed that.

But it now works!
Code:
<keymap>
  <global>
    <remote>
      <power></power>
    </remote>
   </global>
</keymap>
Saving this lil snippet as remote.xml seems to have fixed it. Now the button is doing exactly what I want it to.

Correct me if I'm wrong here, but it seems that the data in /home/user/.xbmc/userdata/keymaps/remote.xml overrides /home/user/.xbmc/userdata/lircmap.xml, which in turn overrides usr/share/xbmc/system/Lircmap.xml ... Is that right?


Thank you both for all of you help.
ericisshort Wrote:Correct me if I'm wrong here, but it seems that the data in /home/user/.xbmc/userdata/keymaps/remote.xml overrides /home/user/.xbmc/userdata/lircmap.xml, which in turn overrides usr/share/xbmc/system/Lircmap.xml ... Is that right?


Thank you both for all of you help.


Yes and no. You're confused a bit. No biggie. As long as it works.Big Grin
Glad it works - nice catch on the script path by FishOil. Here's how I understand how lirc and xbmc interact:

1) lircd.conf defines how lirc interacts with the remote and defines how it interprets raw IR codes received and translates them into 'lirc key' commands

Code:
name Play
                                8993 4497 579 579 579 579
                                579 579 579 579 579 1683
                                579 579 579 1683 579 579
                                579 1683 579 1683 579 1683
                                579 1683 579 579 579 1683
                                579 579 579 1683 579 579
                                579 579 579 579 579 579
                                579 579 579 579 579 579
                                579 579 579 1683 579 1683
                                579 1683 579 1683 579 1683
                                579 1683 579 1683 579 1683
                                579

2) Lircmap.xml defines mappings between the lirc device / 'lirc key' and 'XBMC key' commands in the format <XBMC_COMMAND>LircButtonName</XBMC_COMMAND>

Code:
<play>Play</play>

3) keymap.xml / remote.xml files translate XBMC keycommands into actions inside XBMC in the format <button>action</button> - there's more hierarchy - device / context but the command structure is consistent

Code:
<play>Play</play>

In this case it's confusing because the Lircmap.xml and the remote.xml entry look identical, but they actually mean different things. the Lircmap entry maps the lirc key 'Play' to the xbmc remote key 'play'. The remote.xml entry maps the xbmc remote key 'play' to the XBMC internal command 'Play'.

A better example to show how it all fits together would be a remote key that has been over-ridden. I use the green button to tell XBMC to update the library

My lircd.conf file has a definition for the key 'Green' similar to Play above:

Code:
name Green
                                8993 4497 579 579 579 579
                                579 579 579 579 579 1683
                                579 579 579 1683 579 579
                                579 1683 579 1683 579 1683
                                579 1683 579 579 579 1683
                                579 579 579 1683 579 1683
                                579 1683 579 1683 579 579
                                579 579 579 579 579 579
                                579 579 579 579 579 579
                                579 579 579 1683 579 1683
                                579 1683 579 1683 579 1683
                                579

My Lircmap.xml file has the lirc-xbmc mapping similar as well:

Code:
<green>Green</green>

but my remote.xml file overrides the default command for XBMC key 'green', and calls an internal XBMC command

Code:
<green>XBMC.UpdateLibrary(video)</green>

Also, the keymap/remote files are optional - if it is omitted, XBMC reverts to a default set of commands. By including the key definition <power></power> but omitting the command, you are telling XBMC that it doesn't need to process that XBMC key with an action.
thanks boykster. That makes perfect sense now.