[HowTo] Start/Stop Kodi with your remote (headless mode)

Thanks for this very useful guide! I’m trying to get this working with my Harmony remote that I have paired as a bluetooth keyboard device by setting the Vero up as a Microsoft Kodi device in the Harmony App. The pairing process in myOSMC was successful and the remote shows up as a “Harmony Keyboard”. It works very well and fast in Kodi. However I’m stuck with most likely a startup timing issue with triggerhappy and the bluetooth service. I have set up the osmc.conf file and when I log in via ssh and run

# evtest found harmony keyboard at /dev/input/event7
thd --triggers /etc/triggerhappy/triggers.d/ --deviceglob /dev/input/event7

it works and the scripts I have assigned to harmony buttons run as expected when I press the keys. However although the triggerhappy service ist enabled and automatically started when I restart the Vero it just doesn’t work by itself. I have tracked it down to the /dev/input/event7 harmony input device not being available yet when the service starts. I have already modified the triggerhappy service file at /lib/systemd/system/triggerhappy.service as follows:

[Unit]
Description=triggerhappy global hotkey daemon
After=local-fs.target bluetooth.target bluetooth.service
Requires=bluetooth.target bluetooth.service

[Service]
Type=notify
ExecStart=/usr/sbin/thd --triggers /etc/triggerhappy/triggers.d/ --deviceglob /dev/input/event*

[Install]
WantedBy=multi-user.target

ps -ef shows that the service is up and running, but the key presses are just not recognized. Subsequently, if I change the service command line to “…/dev/input/event7” in the service configuration file the service start fails because the harmony most likely isn’t available yet… I have also tried to start the service from rc.local but with no luck either.

Where and when do I have to start the triggerhappy service to make sure it connects to the bluetooth paired harmony? @sam_nazarko can you help? Thanks!!