I recently bought an USB DAC with hardware volume buttons.
Unfortunately, it turned out that these buttons do not actually
physically adjust the volume, but instead register as a keyboard and
send media key keyboard events. After a bit of research, I found a
fairly simple way to get the buttons working with LMS.
This approach should work with any device supported by the Linux input
subsystem (keyboards and mice (including wireless / bluetooth) , etc.).
As it uses the 'LMS API'
(http://htmlpreview.github.io/?https://github.com/Logitech/slimserver/blob/public/7.9/HTML/EN/html/docs/cli-api.html),
any LMS action can be triggered.

First, download and install 'inputexec'
(https://github.com/rbarrois/inputexec). The page has documentation on
how to install, get your device working and find out which input events
are sent by it.

To run inputexec as a daemon / system service, you'll also need 'this'
(https://github.com/rbarrois/inputexec/issues/3#issuecomment-403109095)
if you run systemd (not tested by me). For OpenRC, an init script is
available on request.

Next, create inputexec-actions.ini
Example:

Code:
--------------------
    
  keypress.KEY_VOLUMEDOWN = /bin/bash /usr/local/bin/sb-command.sh "mixer 
volume +5"
  keypress.KEY_VOLUMEUP =  /bin/bash /usr/local/bin/se-volume.sh "mixer volume 
+5"
  
--------------------


And finally the script to control LMS:
/usr/local/bin/sb-command.sh

Code:
--------------------
    
  #/bin/bash
  # adjust player ID (00:00...) and LMS server (lmsserver)
  echo "00%3A00%3A00%3A00%3A00%3A00 $1" |  /bin/busybox nc lmsserver 9090
  
--------------------


How to automatically start inputexec as a daemon when the system boots
depends on the Linux distribution. For Gentoo:

Code:
--------------------
    
  rc-update add inputexec default
  
--------------------


After starting the service, LMS should respond to the input device
events. If not, check the logs (inputexec, system, LMS).



SW: 'Web UI for LMS'
(http://forums.slimdevices.com/showthread.php?98186-Announce-Alternative-Web-Interface-(beta))
| 'Playlist Editor / Generator'
(http://forums.slimdevices.com/showthread.php?108199-Announce-LMS-Playlist-Editor)
| 'Music Classification'
(http://forums.slimdevices.com/showthread.php?108278-Announce-Essentia-Integration-music-classification-(moods-genres-))
| 'Similar Music'
(http://forums.slimdevices.com/showthread.php?108495-Announce-LMSmusly-play-similar-music)
| 'LMSlib2go' (https://www.nexus0.net/pub/sw/lmslib2go/)
HowTos: 'build a self-contained LMS'
(http://forums.slimdevices.com/showthread.php?99648-Howto-build-a-self-contained-LMS)
| 'Ogg Opus'
(http://forums.slimdevices.com/showthread.php?107011-Howto-play-Ogg-Opus-files)
| 'Bluetooth/ALSA'
(http://forums.slimdevices.com/showthread.php?107230-Howto-Bluetooth-streaming-to-from-LMS-(ALSA-only-no-PulseAudio))
------------------------------------------------------------------------
Roland0's Profile: http://forums.slimdevices.com/member.php?userid=56808
View this thread: http://forums.slimdevices.com/showthread.php?t=110470

_______________________________________________
unix mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/unix

Reply via email to