2

What commands are invoked when I press my media keys (play / pause, next, previous)?

I had a look at simulate media keys in the terminal, and my requirement is the same, except I cannot use the approach in the answer. The answers simulates the keys themselves using xdotools, which I cannot do because I have re-mapped what these keys do. What I want to know is the underlying mechanism in the OS which sends messages to apps which need to know multimedia keys are pressed. I suspect it may be related to dbus.

Background

I had to re-map my media keys (play / pause, next, previous) to other commands this link contains some background.

I did this by removing the previous key-bindings for these media keys and re-assigning them in settings > keyboard > shortcuts.

I want to know the original command so that I can invoke spotify-command ; original-command on the keypress instead of just invoking spotify-command.

Peeyush Kushwaha
  • 399
  • 1
  • 2
  • 17

1 Answers1

1

when you press Multimedia Keys, they have keysymbols which can be known with the command xmodmap -pke | grep Audio

Example:

$ xmodmap -pke | grep Audio
keycode 121 = XF86AudioMute NoSymbol XF86AudioMute
keycode 122 = XF86AudioLowerVolume NoSymbol XF86AudioLowerVolume
keycode 123 = XF86AudioRaiseVolume NoSymbol XF86AudioRaiseVolume
keycode 171 = XF86AudioNext NoSymbol XF86AudioNext
keycode 172 = XF86AudioPlay XF86AudioPause XF86AudioPlay XF86AudioPause
keycode 173 = XF86AudioPrev NoSymbol XF86AudioPrev
keycode 174 = XF86AudioStop XF86Eject XF86AudioStop XF86Eject
keycode 175 = XF86AudioRecord NoSymbol XF86AudioRecord
keycode 176 = XF86AudioRewind NoSymbol XF86AudioRewind
keycode 198 = XF86AudioMicMute NoSymbol XF86AudioMicMute
keycode 208 = XF86AudioPlay NoSymbol XF86AudioPlay
keycode 209 = XF86AudioPause NoSymbol XF86AudioPause
keycode 215 = XF86AudioPlay NoSymbol XF86AudioPlay
keycode 216 = XF86AudioForward NoSymbol XF86AudioForward
keycode 234 = XF86AudioMedia NoSymbol XF86AudioMedia
$

from the link you provided, these commands should work for your Custom Keyboard Shortcuts

enter image description here

for Play/ Pause

dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause

for Next

dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next

for Previous

dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous

for Stop

dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Stop

for Play

dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Play