Linux Infrared Control Part 4: Trigger Apps via IR


Would you like to use a remote control to control your computer? How about using your computer to send remote control signals to your TV or Stereo instead of using the remote?

This is the fourth in a series of posts where I will describe how to use a Raspberry Pi, Raspbian and Linux Infrared Remote Control (Lirc) to receive and send infrared remote control signals. This post will be focused on how to trigger applications and depends on Linux Infrared Control Part 1: Receive IR and Linux Infrared Control Part 2: Send IR.


Ever wanted to use a remote to change a song on your computer, just like your tv? There are mobile phone apps, but they don’t have the same ability to find a button without looking and aren’t as durable as a remote.

There are other creative possibilities, including mapping one remote to another. That is to say, using a different remote with an existing device. Capture both remotes, the configure irexec to use the preferred remote to call irsend to control the device.

Lets start at the beginning, irw and irexec.

What are irw and irexec?

The Lirc irexec is an app that can be configured to launch an program or script when a remote button is press is received. For example you could stop or reboot the computer, change the volume or refresh the screen. irexec is dependent on correctly configured IR receiver and at least one remote.

The Lirc irw app is used to confirm the button presses are being sent through /var/run/lirc/lircd and will simply output the remote and buttons received.


Using irw

First, go through the buttons on your remote and confirm that they are correctly configured. If only a few buttons were configured, like in Linux Infrared Control Part 1: Receive IR, then take this time to re-run irrecord and create a complete lirc.conf configuration file for your remote.

As an example, here is a lirc.conf file for Microsoft’s Xbox One Media Remote:

Next, copy this lirc.conf configuration file to /etc/lirc/lircd.conf.d/:

Test the configuration file by restarting the lircd.service and running irw:

Then start pressing buttons and if everything is working you should see something like this:

Configure irexec

With all the buttons configured, next step is to configure irexec by editing /etc/lirc/irexec.lircrc and make an entry for as many of the buttons as you want.

For example, the following will echo the navigation buttons (up, down, left, right) when pressed:

Restart the irexec service to load the changes:

To see the echo statements above, tail the log for the irexec.service:

Start pressing buttons to confirm your configuration.

Configure irexec to Refresh Screen and Control Volume

With irexec working now the fun can begin. Below is an example irexec.lircrc that has 5 buttons configured.

The first configuration maps KEY_POWER with the command to shutdown the computer, shutdown -h now. As by default irexec runs as root, sudo is not needed.

The second configuration will refresh the screen for the Chromium browser. This could be useful if there is a browser running fullscreen with no keyboard. It sets the DISPLAY environment variable, uses xdotool look for a window called ‘chromium’ and sends a control R key combination to refresh the screen. This requires ‘xdotool’ tool to be installed.

The last three configurations use amixer to set the volume levels and mute the audio. Similarly, they require amixer to be installed.

Save the irexec.lircrc file and restart the irexec service to load the changes:

To watch for any errors, tail the log for the irexec.service:


Hopefully this post gives you an idea of the power of irexec, anything that can be run on the command line can be controlled by a remote.

Comments are closed.