How can I make media keys work with i3?

Renato Oliveira

I've moved from Gnome to i3 on Manjaro, and I'm almost done with configuring the window manager, and terminal colors and whatnot. After some time I just decided to listen to some music, and after a couple of minutes I realized that the volume keys and playback keys don't work.

I have a Razer Blackwidow Stealth 2014 keyboard, so those media keys are actually together with the Function keys. For example: Play/Pause is on F6, and it acts as a media key when I press the Fn key, like in Fn + F6.

Renato Oliveira

The search for the answer

After some time messing around with the controls, I've found a post on the old i3 FAQ board: https://faq.i3wm.org/question/3747/enabling-multimedia-keys.1.html

It says to paste the following into i3's .config file (bellow is a lightly modified version, with some lines removed, which are not relevant to this particular question):

# Pulse Audio controls
bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume 0 +5% #increase sound volume
bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume 0 -5% #decrease sound volume
bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute 0 toggle # mute sound

# Sreen brightness controls
bindsym XF86MonBrightnessUp exec xbacklight -inc 20 # increase screen brightness
bindsym XF86MonBrightnessDown exec xbacklight -dec 20 # decrease screen brightness

# Media player controls
bindsym XF86AudioPlay exec playerctl play-pause
bindsym XF86AudioPause exec playerctl play-pause
bindsym XF86AudioNext exec playerctl next
bindsym XF86AudioPrev exec playerctl previous

And it didn't work either, however the process of finding the answer is correct.

The real answer

To me, at least, the problem was that after copying those lines, the keys would not work. After some more research, I found out that the volume commands could be a little different, using amixer instead of PulseAudio's pactl.

At the end, those were left like this:

# Media volume controls
bindsym XF86AudioMute exec amixer sset 'Master' toggle
bindsym XF86AudioLowerVolume exec amixer sset 'Master' 5%-
bindsym XF86AudioRaiseVolume exec amixer sset 'Master' 5%+

and they started working.

The playback keys were a little more trickier. I deduced that the .config tells which command is executed to do the action. Then I proceeded to try playerctl play-pause on my terminal. Of course it didn't work, because playerctl was not installed. After installing it (using sudo pacman -S playerctl) those keyboard commands worked just fine too.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Can't make media keys work on i3 window manager

From Dev

How do I make my media keys work again?

From Dev

Media keys on Macbook Pro and i3

From Dev

How can i make this work

From Dev

How can I easily make screenshots of screen regions on Arch Linux with i3 WM?

From Dev

How can I make an ubuntu media server with Samba shares and Deluge?

From Dev

How can I make ACL settings on /run/media/* persistent?

From Dev

How do I make arrow keys work in MIT Scheme interpreter?

From Dev

How do I make arrow keys work in MIT Scheme interpreter?

From Dev

How do i make my multimedia keys work with Lubuntu 18.04?

From Dev

How can I make this JButton work

From Dev

How can I make multiple If statement work?

From Dev

How can I make this work with different columns?

From Dev

How can I make chown work recursively?

From Dev

How can I make interrupt() work?

From Dev

How can I make this work, array Image?

From Dev

How can i make this simple thing work?

From Dev

How can I make this JButton work

From Dev

How can i make this CommandParameter work?

From Dev

How can I make this link work?

From Dev

How can I make this CoffeeScript object work?

From Dev

How can I make this struct work in C?

From Dev

How can i make this program work?

From Dev

How can I make this code work properly?

From Dev

How can I make this calculator work

From Dev

How can I disable my Lenovo touchpad with i3?

From Dev

How can I exit i3 without using a mouse?

From Dev

How can I change the i3 font on NixOS

From Dev

How to make tkinter Window floating in i3 windowmanager