[GUIDE] Keyboard shortcuts with triggerhappy

According to the Volumio command line client documentation

volumio stop stops the Volumio service, not playback. So I wouldn’t use that command for a hotkey/remote/etc.
I don’t know if Volumio does have a command to stop playback at all - only pause.

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!

hello,

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?
Regards

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

https://youtu.be/83Q9bihbmcI

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

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:

#VOLUMIO TRIGGERHAPPY CONFIGURATION FILE

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

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

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

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

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

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

#CLEAR QUEUE
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:
KEY_UP
KEY_DOWN
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

#VOLUMIO REMOTE TRIGGERHAPPY CONFIGURATION FILE

#MUTE TOGGLE
KEY_HOME 1 /usr/local/bin/volumio volume toggle

#VOLUME UP
KEY_VOLUMEUP 1 /usr/local/bin/volumio volume plus

#VOLUME DOWN
KEY_VOLUMEDOWN 1 /usr/local/bin/volumio volume minus

#PLAY PAUSE TOGGLE
KEY_ENTER 1 /usr/local/bin/volumio toggle

#FAST FORWARD 10 SECONDS
KEY_UP 1 /usr/local/bin/volumio seek plus

#REWIND 10 SECONDS
KEY_DOWN 1 /usr/local/bin/volumio seek minus

#NEXT SONG
KEY_RIGHT 1 /usr/local/bin/volumio next

#PREVIOUS SONG
KEY_LEFT 1 /usr/local/bin/volumio previous

#TOGGLE RANDOM
KEY_COMPOSE 1 /usr/local/bin/volumio random

#TOGGLE REPEAT
KEY_ESC 1 /usr/local/bin/volumio repeat

#CLEAR CURRENT QUEUE
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:

#RADIO PARADISE
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"}' 

#RADIO PARADISE ROCK
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"}' 

#RADIO EGOFM
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

#SPOTIFY RELEASERADAR
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"}' 

#SPOTIFY DISCOVER WEEKLY
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

#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

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.

2 Likes

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!