Ubuntu – Simulate media keys on a keyboard that doesn’t have them

media-buttonsshortcut-keys

Following on from the solutions in this question, I've been trying to get simulated media keys working on Ubuntu 18.04 on a Lenovo T480s.

First step was to verify that the command xdotool key --clearmodifiers XF86AudioPlay and indeed it did.

Next I remapped the existing functions enter image description here however this resulted in the following symbol being displayed: enter image description here.

After attempting to use this new shortcut, the command line version stopped working as well (would display the same symbol).

I reverted the remapped commands and tried again using custom shortcut mappings enter image description here with no success.

Eventually something I am doing seems to cause the command line version to work again (haven't been able to figure out what, just seems to happen after doing other tasks for a while) but it will break as soon as I attempt to use one of the defined shortcuts.

Can anyone shed some light what I'm doing here that is causing the keyboard shortcuts to not only not work but to get into an unworkable state?

Best Answer

You need to add an artificial delay in your shortcut command :

xdotool sleep 0.100 key --clearmodifiers XF86AudioPlay

This works like a charm on my computer (Ubuntu 18.04).

Source : https://github.com/jordansissel/xdotool/issues/210

Related Question