[GUIDE] Keyboard shortcuts with triggerhappy

volumio vstop should do the trick

Thanks, I didn’t know about that!

I started to play around with the command line client. Indeed playback commands don’t seem to work at all. Things like ‘status’ and ‘volume’ work as expected, but using ‘volumio play’ or ‘volumio next’ simply does nothing.
Using ‘/volumio/app/plugins/system_controller/volumio_command_line_client/commands/playback.js play’ directly shows the same behavior, so I guess there’s a bug in that file. I’m not able to see it, though :wink:

(there’s also a bugreport on github: github.com/volumio/Volumio2/issues/952 )

Happy easter!

I would like to implement a super simple way to have some basic volumio (2) control with a keyboard or similar (joystick?) thing (without soldering/using GPIO pins which are used by the DAC).

My current idea:

  • use a USB numpad
  • maybe use “triggerhappy” as discussed here?
  • use REST API?

Assuming “KEY_1” the correct triggerhappy key for the key “1” I assume then putting something like:

KEY_1 0 curl volumio.local/api/v1/commands/?cmd=playplaylist&name=1stPlaylist

in the config file (as explained above) would make volumio play the playlist named “1stPlaylist”.

Am I right in assuming this works? (Unfortunately I just notice the command “playplaylist” doesn’t seem to be recognized…)

Any idea how this could work? Or a simpler idea?

Hard- and software wise?

(I would like my 3-year old daughter + my wife to be able to press a simple key to play something predefined without starting a bigger programming/engineering project…)

If I understood well, I cannot use mpc commands to play playlists?

Thanks! Florian

Thank you for this useful information!


i did try triggerhappy with some controllers it act great but some of keys doest work. is it normal? is there anything to make it work?

thanks working!

KEY_VOLUMEUP 1 /usr/local/bin/volumio volume $((($(/usr/local/bin/volumio volume)) + 1))

KEY_VOLUMEUP 2 /usr/local/bin/volumio volume $((($(/usr/local/bin/volumio volume)) + 3))

KEY_VOLUMEDOWN 1 /usr/local/bin/volumio volume $((($(/usr/local/bin/volumio volume)) - 1))

KEY_VOLUMEDOWN 2 /usr/local/bin/volumio volume $((($(/usr/local/bin/volumio volume)) - 3))

KEY_PLAYPAUSE 0 /usr/local/bin/volumio toggle

KEY_NEXTSONG 0 /usr/local/bin/volumio next

KEY_PREVIOUSSONG 0 /usr/local/bin/volumio previous


Very interesting project. Thanks for sharing.
Could you post your Arduino sketch?

Thanks, wow! This way I was able to use the wireless remote control with USB dongle offered by HiFiBerry. Very good deal, lightweight and good quality clickable buttons.
I programmed these keys:


KEY_VOLUMEUP 1 curl "http://volumio.local:3000/api/v1/commands/?cmd=volume&volume=plus"

KEY_VOLUMEDOWN 1 curl "http://volumio.local:3000/api/v1/commands/?cmd=volume&volume=minus"

KEY_ENTER 1 curl "volumio.local:3000/api/v1/commands/?cmd=toggle"

KEY_RIGHT 1 curl "volumio.local:3000/api/v1/commands/?cmd=next"

KEY_LEFT 1 curl "volumio.local:3000/api/v1/commands/?cmd=prev"

KEY_ESC 1 curl "volumio.local:3000/api/v1/commands/?cmd=stop"

KEY_COMPOSE 1 curl "volumio.local:3000/api/v1/commands/?cmd=clear"

So the following keys excluded, because they were not recognised or there was no use for them:
The on/off key does not work
The home key does not work
The pointer key does not work

1 Like

Here’s an updated config file for triggerhappy with extended functionality that works with the hifiberry USB remote and the current build of Volumio (2.861). Here are the contents of /etc/triggerhappy/triggers.d/audio.conf


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

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

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

KEY_ENTER 1 /usr/local/bin/volumio toggle

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

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

KEY_RIGHT 1 /usr/local/bin/volumio next

KEY_LEFT 1 /usr/local/bin/volumio previous

KEY_COMPOSE 1 /usr/local/bin/volumio random

KEY_ESC 1 /usr/local/bin/volumio repeat

KEY_POWER 1 /usr/local/bin/volumio clear

After editing, you must restart the service with

sudo /etc/init.d/triggerhappy reload

Functions of each key are listed in the comments above the command.

IMPORTANT NOTE: This remote has a mouse control button in the upper right of the control. This button toggles mouse mode and totally messes up the mapping, making the remote almost useless. Don’t push it, don’t map it, and the keys above will work just fine.

After editing, you must restart the service with

sudo /etc/init.d/triggerhappy reload
1 Like

Quite good hint here! This is actually really powerfull, you can even add whole spotify playlists or radio Urls:

KEY_1 1 /usr/bin/curl -i --header "Content-Type: application/json" localhost:3000/api/v1/replaceAndPlay --data '{  "service": "webradio",  "type": "webradio",  "title": "RadioParadise",  "uri": "https://stream.radioparadise.com/aac-320",  "albumart": "https://radioparadise.com/graphics/logo_flat_350x103.png"}' 

KEY_2 1 /usr/bin/curl -i --header "Content-Type: application/json" localhost:3000/api/v1/replaceAndPlay --data '{  "service": "webradio",  "type": "webradio",  "title": "RadioParadiseRock",  "uri": "https://stream.radioparadise.com/rock-320",  "albumart": "https://radioparadise.com/graphics/logo_flat_350x103.png"}' 

KEY_3 1 /usr/bin/curl -i --header "Content-Type: application/json" localhost:3000/api/v1/replaceAndPlay --data '{  "service": "webradio",  "type": "webradio",  "title": "EgoFM",  "uri": "http://mp3ad.egofm.c.nmdn.net/ps-egofm_192/livestream.mp3",  "albumart": "https://www.egofm.de/images/site/logo.svg"}' 

#GET MORE SPOTIFY PLAYLISTS VIA REST command (install a REST plugin for your browser is recommended): http://volumio.local/api/v1/browse?uri=spotify/playlists

KEY_4 1 /usr/bin/curl -i --header "Content-Type: application/json" localhost:3000/api/v1/replaceAndPlay --data '{  "service": "spop", "type": "playlist", "title": "Release Radar", "albumart": "https://newjams-images.scdn.co/v3/release-radar/ab6761610000e5ebda012e44f73353016e419282/en/large", "uri": "spotify:user:spotify:playlist:37i9dQZEVXboZS2Bc5o5qH"}' 

KEY_5 1 /usr/bin/curl -i --header "Content-Type: application/json" localhost:3000/api/v1/replaceAndPlay --data '{ "service": "spop", "type": "playlist", "title": "Discover Weekly", "albumart": "https://newjams-images.scdn.co/v3/discover-weekly/aAbca4VNfzWuUCQ_FGiEFA==/bmVuZW5lbmVuZW5lbmVuZQ==/default", "uri": "spotify:user:spotify:playlist:37i9dQZEVXcKMQKnTB7OVv"}'

found this via:

Does this work with other USB wireless remotes/airmouses (like the ones on Aliexpress)?

It should as long as it shows up as a standard input device (USB HID mode)

And it works so far with the default Playback options. But I would like to assign some keys to my Music Library Network Shares Folders. Like pressing button 1: starts the playback of the first folder, pressing button 2 : starts playback of the the second folder, etc… (This remote has may keys). How can I specify this in the triggerhappy config file? Thanks!

Edit: So the be more clear: If I want start the playback from my NAS (SMB) Share like the folder called (i.e.) “Remixes” what should I type in the config line?

1 Like

I have already solved both the Playlist and the Radio playback with this method on Volumio v.2.917. But will this triggerhappy “workaround” also work with the new v.3.x, just like it was with v.2.917? Anyone here had tried it so far? (I will only update to v.3.x if I can make it work again flawlessly, as the remote controller is essential for me).

I have configured Volumio (3.179 on RPi4) for the OSMC remote control. image
here is my /etc/triggerhappy/tiggers.d/audio.conf


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

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

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

KEY_PLAYPAUSE 1 /usr/local/bin/volumio toggle

KEY_STOP 1 /usr/local/bin/volumio stop

KEY_ESC 1 /usr/local/bin/volumio clear

KEY_RIGHT 1 /usr/local/bin/volumio next

KEY_LEFT 1 /usr/local/bin/volumio previous

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

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

KEY_C 1 /usr/local/bin/volumio repeat

KEY_I 1 /usr/local/bin/volumio random

A couple of points I learned that are not in this thread:
to restart the service in V3 you need to run:

sudo systemctl restart triggerhappy

Not all events are on event0 so if you want to see all the button codes you need to run

sudo thd --dump /dev/input/event*

The volume control uses the step defied in the regular settings menu. If you use my config you should set the stepsize to 1 so that a single click on the volume up or down changes the volume by one increment, but pressing and holding gives a smooth increase or decrease for as long as it is held.


Glad it’s sure now it works also on Volumio 3.xxx! Now I’m confident to update at last…

Does this still work with the recent build of Volumio ?
I just tried to install but it seams trigger happy is already installed (fresh install).

My goal is to add a cheap ali express keyboard with 3 keys and a rotary to have previous/play/next and volume up and down. Just for simple acces.

I tried adressing the keys to the mouse function.
This works for play/pause so my board is working.

Even if i plug in a normal keyboard the code from [adaptiman] does nothing :frowning:
Im a complete noob into this so some help would be welcome :slight_smile:

Thanks in advance

sudo thd --dump /dev/input/event*

Thanks for this, managed to get it working with this dump :slight_smile:

Now how do i play a playlist from a hotkey ?
Anyone has an example ?

Just an FYI
I have a cheap Bluetooth remote control model G20BTS Mouse Remote Control.
I was able to pair it to my RPI4 and then used triggerhappy to control the volume.
Its Great!

I have one wield issue with my remote (G21 pro), which sends out movement info (REL_X REL_Y) rapidly if you move it.
Key mapping for play/next command is fine, but not for volumn controls.
I have to place the remote on the desk and press the key without shaking to make it work. Somehow it is not doing volumn control properly when REL_* are sent at the same time. It doesn’t matter if I map other keys like number keys to volumn control.
My question: why volumn control is affected but not play controls? any workaround?