0

I'm on elementary OS Odin and I can't seem to get media keys to work with various applications.

I have been using elementary OS with the same keyboard for almost a decade, and Odin does not seem to actually use the next/previous and play/pause media shortcuts to control actively playing media. It's also not just my keyboard, my mouse has the key combination mapped to additional buttons, and I've been using the same mouse for multiple elementary OS releases.

I originally thought this was a problem with the snap integration for Spotify, so I installed it via flatpak and the problem persists. I've also tried to use Music (formerly Noise) and nothing seems to actually listen to the media keys. I tried going into the settings and setting the media keys for controlling playback, but no dice.

Using the sound panel dropdown from wingpanel's top right does see the D-Bus media sources and can control playback, next/previous, so clearly the applications do respond to the right D-Bus interfaces, but it seems that all media key activity is going to /dev/null on Odin.


EDIT: I have reported the bug to the elementary team at elementary/os#569.

1 Answer 1

1

Same issue with my thumb buttons on mouse Logitech G305 after reinstalling elementary Hera to Odin. I use 2 keys for Play/Pause and Next Track in Spotify (snap version). I've tried the same ways that you. It's definitely the problem with new OS Odin.

I found the article and it helped me. Interesting thing, that if you bind your buttons with media presets, OS can't see when you click them (accordingly to xev tool). So I've rebinded them using OS Windows with Logitech G HUB software and set default values (forward / backward for navigation). After that OS Odin saw the response hence I need to rebind these keys again using ubuntu's tools.

Further instructions from the article. Thanks to the author Logix.

To bind the mouse buttons to key combinations we'll use the following tools:

- xbindkeys: a program that grab keys and mouse button events in X and starts associated shell command

- xev: a tool that prints contents of X events

1. Install xbindkeys, xev

sudo apt install xbindkeys x11-utils

2. Grab the mouse button codes

To get the mouse button code(s), run this command:

xev | grep button

Next, focus the small window that pops up and watch the terminal output. Now press the mouse button for which you want to grab the code. After pressing the button you should see its code in the terminal. For instance:

state 0x10, button 8, same_screen YES

In this example, the button code we'll need later is 8.

3. Grab the keystrokes that we'll later send using a mouse button

But in case of media keys/buttons we need XF86Audio* multimedia key symbols.

XF86AudioMute XF86AudioNext XF86AudioPause XF86AudioPlay XF86AudioPrev XF86AudioLowerVolume XF86AudioRaiseVolume XF86AudioRecord XF86AudioRewind XF86AudioStop

4. Create the xbindkeys configuration (in ~/.xbindkeysrc)

You may either create an empty ~/.xbindkeysrc file, or generate a sample configuration file using this command:

xbindkeys -d > ~/.xbindkeysrc

Next, open ~/.xbindkeysrc with your favorite text editor. Note that .xbindkeysrc is a hidden file in your home directory so you'll need to press Ctrl + h (to show hidden files and folders) to see it in your file manager.

To bind a mouse button to a key combination, paste the following at the end of the ~/.xbindkeysrc file (it may already contain some key binds, it may contain the sample configuration or it can be empty - it doesn't matter):

"xdotool key 'KEY-COMBINATION'"
       b:MOUSE-BUTTON-CODE

Where:

  • KEY-COMBINATION are the keystrokes you got under step 3 (separate the keys with a + sign)
  • MOUSE-BUTTON-CODE is the mouse button code that you got under step 2

Example:

"xdotool key 'XF86AudioPlay'"
       b:8

"xdotool key 'XF86AudioNext'"
       b:9

5. Start xbindkeys

Now you can start xbindkeys using a terminal and typing:

xbindkeys

In case xbindkeys was running, you can get it to use the new configuration by issuing:

xbindkeys --poll-rc

This command can failed in a few cases. In such a case you can restart it by killing the xbindkeys process and running it again:

killall xbindkeys
xbindkeys

On Ubuntu distros, xbindkeys is automatically started on system startup if it finds a non-empty (it needs to have lines that are not commented out) ~/.xbindkeysrc configuration file.

2
  • Thanks so much for your response, I was hoping it wouldn't come back to xev, xbindkeys, and xdotool but alas, here we are. Hopefully the elementary team fixes this natively soon. Nov 12, 2021 at 19:41
  • Update: I have reported the bug to the elementary team at elementary/os#569. Nov 12, 2021 at 19:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.