Spotify keyboard controls not working
Solution 1
There is a simple solution credit goes to this thread on Spotify forum, Thanks to schuellerf and rszabla. The solution is pretty simple and works on any Linux distribution.
- Download this file, extract it and make it executable
chmod a+x spotify_control
- Place it anywhere you want, I'll assume that it is placed in Downloads folder
- Go to settings -> keyboard -> keyboard shortcuts -> custom shortcuts
- Add new shortcut by clicking the plus button, I'll override the default play/pause/next and previous keys because I only listen to music on spotify, If you need those shortcuts then assign different ones for Spotify
The command you see in the picture above is for 'play/pause' function
/home/your_username/Downloads/spotify_control playpause
The commands that are available
/home/your_username/Downloads/spotify_control playpause
/home/your_username/Downloads/spotify_control previous
/home/your_username/Downloads/spotify_control next
/home/your_username/Downloads/spotify_control play
/home/your_username/Downloads/spotify_control stop
Please note that you have to do this
/home/your_username/Downloads/spotify_control playpause
Because
~/Downloads/spotify_control playpause
That won't work, at least not in Ubuntu 16.04, unity desktop, the shortcut manager doesn't seem to understand the tilde ~
Solution 2
Here is another link i have found that help me and its the same solutions as k2shah mention it, but with more details.
Instead of downloading the spotify_control, you use the D-Bus commands. Before you add it as a new keyboard command, feel free to execute those commands.
Play/Stop
dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause
Next
dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next
Previous
dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous
Once you validate the above commands, feel free to add them as Key Shortcut. For Ubuntu, "Settings > Devices > Keyboard" than add (+) and put the name and copy the commands, than put the keyboard shortcut.
Solution 3
The top-voted solutions are about adding a custom key mapping, which is kinda cumbersome, as you have to drop every other binding related to the Play/Pause key.
There's only one binding possible for a key so it means that your Play/Pause key stops working anywhere outside Spotify.
Initially, I wanted to do that, but Ubuntu settings didn't let me create a binding so the key was used/captured by something else on my system.
It turned out that Chrome captures hardware media keys by default :)
You can disable this functionality by opening
chrome://flags/
and then disabling
Hardware Media Key Handling
feature.
After doing so, your Play/Stop key along with Next and Previous keys are handled by Ubuntu itself again.
It fixed the issue for me. Now Spotify is the one to capture these keys.
This also happens on Firefox, you can access the option in:
about:config
Then, change
media.hardwaremediakeys.enabled
to false
Solution 4
All i had to do in Fedora is
sudo dnf install playerctl
Anyway, it works in Ubuntu, no idea why such a basic functionality is missing here.
Solution 5
Considering the Aiphee Answer on ubuntu or Debian this works!
sudo apt install playerctl
Package info: utility to control media players via MPRIS https://packages.debian.org/buster/playerctl
Related videos on Youtube
Lynob
Updated on September 18, 2022Comments
-
Lynob over 1 year
I am on Ubuntu 16.04, I cannot play, pause, go to the next or the previous song in spotify. There are many answers but most are complicated, is there a simple solution that doesn't require a command line?
I have a Logitech bluetooth keyboard.
-
mithril_knight over 5 yearsthis worked for me, thx! quick info of my system: ubuntu 16.04 and using an apple (wired)keyboard
-
Barbaros Alp over 4 yearsWhat about "Don't Play This Song" shortcut for playlists?
-
Lucas Vasconcellos Czepaniki over 4 yearsfor next/prev worked like a charm, but for play/pause the audio play/pause key shortcut it doesn't work. If I remap it to 'super + ;' or other modifier + non-func key works. Any idea as to why?
-
IvanAK over 4 yearsCheck if that map is already taken for something else.
-
ibrahim about 4 yearsWorked on 18.04 with spotify installed via snap. thanks
-
JavaRunner almost 4 yearsWorked like a charm!
-
Mark D over 3 yearsWorked like a charm! Thanks!
-
Sina over 3 yearsThis is it! The media keys are working but captured by chrome even if there is no player/youtube on it
-
Vthechamp almost 3 yearsThis solution works for all chromium browsers, including Brave. Thanks!
-
User5468622 almost 3 yearsOn ubuntu 20.04 I was unable to set custom shortcuts to those keys since they were already used by other keyboard shortcuts (upon prompt for pressing keyboard combination nothing was happening when I was pressing Play/Stop button, not even the info line). I had to manually unset them using gsettings set command and then I was able to set it up. You can find the ones to unset in gsettings list-recursively (grep the result).
-
Patrick Barattin over 2 yearsIt also worked for me! Thanks
-
Terry over 2 yearsThis worked for me.
-
Adrug over 2 yearsNow you can add custom shortcut like
playerctl play
and first available player will play. I tested youtube + spotify. -
Saeed Darvish over 2 yearsIts work on Fedora 34, but just play/pause command not worked for me? If any have a solution for me please tell me.
-
Saeed Darvish over 2 yearsI found the solution, This keyboard shortcut set to for two command
-
adxl about 2 yearsIt works, thanks ! Too bad we have to choose between Spotify and Chrome...