Software & AppsOperating SystemLinux

Fixing Volume and Brightness Controls in i3 Window Manager and Binding the Mod Key to Win Key

Ubuntu 13

The i3 window manager is a popular tiling window manager that is highly configurable and perfect for power users. However, one common issue that users may face is that the volume and brightness controls may not work out of the box. Additionally, you may want to bind the mod key to the Win key for convenience. This article will provide detailed instructions on how to address these issues.

Quick Answer

To fix volume and brightness controls in i3 window manager, you can use either the pactl or amixer command to bind keys for volume up, volume down, and mute. For brightness controls, you can use the xbacklight command to bind keys for increasing and decreasing brightness. To bind the mod key to the Win key, modify the i3 configuration file to set the mod key as Mod4.

Prerequisites

Before we start, make sure you have installed the necessary packages for brightness and volume control. You can do this by running the following command:

sudo apt-get update; sudo apt-get install xbacklight alsa-utils pulseaudio

Fixing Volume Controls

The first issue we will address is the volume control. For this, we can use the pactl or amixer command from the pulseaudio or alsa-utils package respectively.

Using pactl

Open the i3 configuration file located at ~/.config/i3/config. Add the following lines to the configuration file:

# 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

Here, bindsym is used to bind a command to a key, XF86AudioRaiseVolume, XF86AudioLowerVolume, and XF86AudioMute are the keys for volume up, volume down, and mute respectively. exec is used to execute a command, and --no-startup-id is used to prevent a startup notification from being sent. pactl is a utility to control a running PulseAudio sound server.

Using amixer

If you prefer to use amixer, you can do so by replacing the pactl commands with amixer commands as follows:

bindsym XF86AudioRaiseVolume exec amixer sset Master 5%+
bindsym XF86AudioLowerVolume exec amixer sset Master 5%-
bindsym XF86AudioMute exec amixer sset Master toggle

Here, amixer is a command-line mixer for ALSA sound-card driver, and sset is used to set a simple mixer control.

After adding these lines, save the configuration file and reload it by running i3-msg reload.

Fixing Brightness Controls

Next, we will address the brightness control. For this, we can use the xbacklight command from the xbacklight package.

Open the i3 configuration file and add the following lines:

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

Here, XF86MonBrightnessUp and XF86MonBrightnessDown are the keys for brightness up and down respectively. -inc and -dec are used to increase and decrease the brightness by a certain percentage.

If xbacklight does not work, you can try using the brightnessctl script or the light tool by haikarainen. You can find the instructions for installing and using these tools on their respective GitHub pages.

Binding the Mod Key to Win Key

Finally, we will bind the mod key to the Win key. Open the i3 configuration file, look for the line set $mod, and change it to set $mod Mod4. Here, Mod4 is the identifier for the Win key. Save the configuration file and reload it.

Conclusion

In this article, we have covered how to fix the volume and brightness controls in the i3 window manager and how to bind the mod key to the Win key. These instructions should help you to customize your i3 window manager to better suit your needs. Remember to check the comments for additional tips and modifications that may be required for specific hardware or software versions.

How do I find the i3 configuration file?

The i3 configuration file is located at ~/.config/i3/config.

Can I use a different key instead of the Win key as the mod key?

Yes, you can use a different key as the mod key by changing the set $mod line in the i3 configuration file. Just replace Mod4 with the desired key identifier.

Leave a Comment

Your email address will not be published. Required fields are marked *