Total IR Control for Linux
Home arrow Support arrow LIRC Scripting
 
The .lircrc Event File and Examples
The .lircrc file assigns software actions to remote-control button-push events, for example:
 
'Play' button detected -> Send 'Play' event to MythTV, Xine, Mplayer, VLC
'Power' button detected -> Run a script to power on/off external devices
'Vol+' button detected -> Either send 'Vol+' event to programs, or change the volume on an external device
 
The file contains as many stanzas of event mappings that you want.  As outlined in the official LIRC documentation for lircrc :
 
    begin
prog = ...
remote = ...
button = ...
repeat = ...
delay = ...
config = ...
mode = ...
flags = ...
end
 
Each program has a specific list of 'config's, or events, that can be triggered from LIRC.  Each remote has a specific list of buttons which can be detected by LIRC.  The .lircrc maps the buttons to program events. 
 

Examples

The .lircrc file is usually saved in the home directory of your user account.  Example: /home/mythtv/.lircrc .   

 

Example: Configuring 2 buttons for MythTV

Note, since "remote =" was not specified, any remote with a 'DOWN' button can be used to trigger MythTV's 'Down' event:
 
begin
prog = mythtv
button = DOWN
repeat = 3
config = Down
end

begin
prog = mythtv
button = LEFT
repeat = 3
config = Left
end
 

Example: Triggering Your Own Scripts

LIRC's 'irexec' program will run whatever command you specify in the 'config' line for any particular remote button.  
To test this, save the .lircrc and run 'irexec'. 
 
begin
 prog = irexec
 button = ok
 config = echo "You just pressed 'OK'!"
end

Example: Power On/Off Script with .lircrc

In .lircrc: 
 
begin
 prog = irexec
 button = power
 config = /home/mythtv/my_power_script.sh
end
 
Assuming:
  • A receiver named 'denon' is on emitter #3
  • A TV named 'samsung' is on emitter #4
  • If set-top boxes were on emitters #1 and #2 they will be left on for recording

In /home/mythtv/my_power_script.sh:

For CommandIR Mini

For CommandIR II

#!/bin/bash
irsend set_transmitters 3
irsend send_once denon power 
irsend set_transmitters 4
irsend send_once samsung power 
#!/bin/bash
irsend send_once commandir settransmitters-3
irsend send_once denon power 
irsend send_once commandir settransmitters-4       
irsend send_once samsung power 
 
 

Example: Change Volume on an External Device

Remove any other stanzas in your .lircrc that assign program actions to your 'vol+' and 'vol-' buttons, then add: 

 
begin
 prog = irexec
 button = vol+
 config = /home/mythtv/change_volume.sh vol+
end
 
begin
 prog = irexec
 button = vol-
 config = /home/mythtv/change_volume.sh vol-
end

Assuming:
  • A receiver named 'denon' is on emitter #3

In /home/mythtv/change_volume.sh:

For CommandIR Mini

For CommandIR II

#!/bin/bash
irsend set_transmitters 3
irsend send_once denon $1
#!/bin/bash
irsend send_once commandir settransmitters-3
irsend send_once denon $1 

Make this Easier with LIRC Config

Clearly it can be alot of work to configure every remote for every program so we created LIRC Config, an online LIRC configuration tool that makes lircrc's from your lircd.conf's and program selections. 
 

Last Updated: Sunday, 08 June 2008
 
 
  



CommandIR Control Technologies is a division of InnovationOne Applied Technology.

(C) 2006-2012, All Rights Reserved. 

Last update: Mon Oct 29 22:23:04 EDT 2012

 

Privacy   Terms of Use