Setting Up and Configuring the OSMC Remote with Volumio Using Triggerhappy
ms

matt shepherd

Created Dec 19, 2023

Setting Up and Configuring the OSMC Remote with Volumio Using Triggerhappy

The OSMC Remote Controller is a compact and intuitive remote designed for the OSMC (Open Source Media Center). It is known for its simplicity, reliability, and ease of use. Featuring essential buttons for media control, the OSMC Remote offers a straightforward way to navigate and control media playback. It communicates with devices using a USB receiver, making it compatible with a variety of systems, including the Raspberry Pi running Volumio.

234
1

1. OSMC remote

I found an unused remote still in its original packaging, and I decided it was the perfect opportunity to make good use of it. While there are various 2.4GHz remotes on the market, keep in mind that they may require unique mapping configurations to work properly.

If you're interested in acquiring one, you can find them directly on the OSMC website:

https://osmc.tv/store/product/osmc-remote-control/

OSMC remote
2

2. How to map the remote via Triggerhappy (Volumio)

Editing Triggerhappy Configuration for the OSMC Remote with Volumio

1. Connect to Your Raspberry Pi:

- SSH into your Raspberry Pi running Volumio. You'll need the IP address and SSH credentials.

2. Install Triggerhappy (if not already installed):

- Run sudo apt-get install triggerhappy in the terminal.

3. Open the Triggerhappy Configuration File:

- Use sudo nano /etc/triggerhappy/triggers.d/audio.conf to open the configuration file in the nano text editor. And paste in the code below.

#VOLUMIO TRIGGERHAPPY CONFIGURATION FILE

#MUTE TOGGLE

KEY_ENTER 1 /usr/local/bin/volumio volume toggle

#VOLUME UP

KEY_EQUAL 1 /usr/local/bin/volumio volume plus

KEY_EQUAL 2 /usr/local/bin/volumio volume plus

#VOLUME DOWN

KEY_MINUS 1 /usr/local/bin/volumio volume minus

KEY_MINUS 2 /usr/local/bin/volumio volume minus

#PLAY PAUSE TOGGLE

KEY_PLAYPAUSE 1 /usr/local/bin/volumio toggle

#STOP

KEY_STOP 1 /usr/local/bin/volumio stop

#CLEAR

KEY_ESC 1 /usr/local/bin/volumio clear

#NEXT

KEY_RIGHT 1 /usr/local/bin/volumio next

#PREVIOUS

KEY_LEFT 1 /usr/local/bin/volumio previous

#SEEK FORWARD

KEY_UP 1 /usr/local/bin/volumio seek plus

#SEEK BACKWARD

KEY_DOWN 1 /usr/local/bin/volumio seek minus

#REPEAT

KEY_C 1 /usr/local/bin/volumio repeat

#RANDOM

KEY_I 1 /usr/local/bin/volumio random

4. Save and Exit:

- Press Ctrl + X, then Y to save, and Enter to exit nano.

5. Reload Triggerhappy:

- Run sudo /etc/init.d/triggerhappy reload to apply the changes.

6. Test the Remote:

- Use your OSMC Remote to ensure the buttons perform the configured actions in Volumio.

3

3. How to map the remote via Triggerhappy (Moode)

Editing Triggerhappy Configuration for the OSMC Remote with MoOde

1. Connect to Your Raspberry Pi:

- SSH into your Raspberry Pi running MoOde. You'll need the IP address and SSH credentials.

2. Install Triggerhappy (if not already installed):

- Run sudo apt-get install triggerhappy in the terminal.

3. Open the Triggerhappy Configuration File:

- Use sudo nano /etc/triggerhappy/triggers.d/audio.conf to open the configuration file in the nano text editor. And paste in the code below.

# MPD/MPC TRIGGERHAPPY CONFIGURATION FILE

# MUTE TOGGLE

# Note: MPC does not have a direct mute toggle command. This can be simulated by saving and setting volume to 0.

# This functionality requires additional scripting not directly provided by mpc.

# VOLUME UP

KEY_EQUAL 1 /usr/bin/mpc volume +5

KEY_EQUAL 2 /usr/bin/mpc volume +5

# VOLUME DOWN

KEY_MINUS 1 /usr/bin/mpc volume -5

KEY_MINUS 2 /usr/bin/mpc volume -5

# PLAY PAUSE TOGGLE

KEY_PLAYPAUSE 1 /usr/bin/mpc toggle

# STOP

KEY_STOP 1 /usr/bin/mpc stop

# CLEAR

# Note: MPC clear command clears the current playlist.

KEY_ESC 1 /usr/bin/mpc clear

# NEXT

KEY_RIGHT 1 /usr/bin/mpc next

# PREVIOUS

KEY_LEFT 1 /usr/bin/mpc prev

# SEEK FORWARD

# Note: MPC seek command seeks within the current track. Modify "+5" as needed.

KEY_UP 1 /usr/bin/mpc seek +10

# SEEK BACKWARD

# Note: MPC seek command seeks within the current track. Modify "-5" as needed.

KEY_DOWN 1 /usr/bin/mpc seek -10

# REPEAT

# Note: Toggling repeat mode in MPC.

KEY_C 1 /usr/bin/mpc repeat

# RANDOM

# Note: Toggling random mode in MPC.

KEY_I 1 /usr/bin/mpc random

4. Save and Exit:

- Press Ctrl + X, then Y to save, and Enter to exit nano.

5. Reload Triggerhappy:

- Run sudo /etc/init.d/triggerhappy reload to apply the changes.

6. Test the Remote:

- Use your OSMC Remote to ensure the buttons perform the configured actions in Volumio.

#

Listening to button presses from your remote

9 Steps

If the button codes on your remote are different from the ones provided, or if you wish to customize the actions further, you can modify the configuration file as follows:

4

4. Install evtest

sudo apt-get install evtest
5

5. Identify Your USB Remote

With the USB remote connected to the Raspberry Pi, list all connected input devices to find your remote.

sudo evtest
  • Observe the codes that correspond to each button press while using evtest.

  • Return to editing the /etc/triggerhappy/triggers.d/audio.conf file with nano (or reopen it if you closed it).

  • Replace the key codes in the file with the ones you've identified as necessary. For example, if the "volume up" button on your remote actually sends KEY_VOLUMEUP instead of KEY_EQUAL, update the configuration accordingly.

  • After making your changes, save the file by pressing Ctrl + O, then Enter, and exit nano by pressing Ctrl + X.

6

6. Reload Triggerhappy

sudo systemctl restart triggerhappy

7

7. MoOde Volume scripts

Create a script with nano

sudo nano volume_control.sh

8

8. Paste this volume control script:#!/bin/bash# volume_control.shOPERATION="$1" # Expected "up" or "down"ADJUSTMENT_VALUE=5 # Adjust volume level by this valueif [ "$OPERATION" == "up" ]; then mpc volume +$ADJUSTMENT_VALUEelif [ "$OPERATION" == "down" ]; then mp

Do the usual ctl+x to save

9

9. Create a mute script with nano

sudo nano mute_toggle.sh
10

10. Paste this mute script: #!/bin/bash# mute_toggle.shVOLUME_STATE_FILE="/tmp/mpd_volume_state"CURRENT_VOLUME=$(mpc volume | grep -o '[0-9]*' | head -n 1)if [ -f "$VOLUME_STATE_FILE" ]; then # Unmute: Restore volume from file and remove the file SAVED_VOLUME=$(cat "

save with ctl+x

11

11. Make scripts executable

sudo  chmod +x volume_control.sh mute_toggle.sh

12

12. Update your Triggerhappy configuration to call these scripts.Replace /path/to/ with the actual path to where you've saved the scripts.

KEY_EQUAL 1 /path/to/volume_control.sh up
KEY_MINUS 1 /path/to/volume_control.sh down
KEY_ENTER 1 /path/to/mute_toggle.sh
Well done!
Create how-to guides like this in a snap. Get Tango now.