Table of Contents
i3 is a tiling display manager for Linux based systems. Sometimes, there are handy options you can add to the config which I will list here.
i3 config
Trying to configure i3 but missing common functionality? Here are some helper commands I use!
Open certain programs in floating mode
This is useful for some programs like 'pavucontrol' or 'qt5ct'. Use this template for other programs as well
for_window [class="SMPlayer"] floating enable for_window [class="qt5ct"] floating enable sticky enable border normal
Change system volume/mute from media controls
For muting, using ALSA to mute the Master output is a safe bet.
bindsym XF86AudioMute exec amixer -q set Master toggle
To adjust system volume, I have done this in 2 main ways:
Using Pulseaudio
Here, you can change how much you want to adjust the volume by (eg: 1%), and the sink number (eg: 2).
For example, I had the regular volume buttons change the 2nd sink volume, which is my USB DAC, and 'Mod1+XF86AudioRaiseVolume' to change the internal sound card volume by having it control sink 1.
bindsym XF86AudioRaiseVolume exec "pactl set-sink-volume 2 +1%" bindsym XF86AudioLowerVolume exec "pactl set-sink-volume 2 -1%"
Using ALSA
This will change the volume of whatever output device is selected as default. I have found a slight glitch, if you adjust volume too fast, the left and right channels may imbalance. In this case, bring the volume down to 0, then back up.
bindsym XF86AudioRaiseVolume exec "amixer -q set Master 5%+ unmute" bindsym XF86AudioLowerVolume exec "amixer -q set Master 5%- unmute"
New method from Fedora config
I saw this on Fedora git, and it works better. Use this. It doesn't imbalance. It does sometimes get stuck on my Lenovo Thinkpad E495 and go up or down to infinity, but I think that's the laptop, not the config.
# Use pactl to adjust volume in PulseAudio. set $refresh_i3status killall -SIGUSR1 i3status bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +5% && $refresh_i3status bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -5% && $refresh_i3status bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle && $refresh_i3status bindsym $mod+XF86AudioMute exec --no-startup-id pactl set-source-mute @DEFAULT_SOURCE@ toggle && $refresh_i3status
Disable mouse acceleration
I don't like mouse acceleration usually, and prefer to use a linear model. On full DE's like KDE, there is always an option to set this.
In i3, we can set all mice to disable acceleration using libinput and xinput
exec_always for id in $(xinput list | grep "pointer" | cut -d '=' -f 2 | cut -f 1); do xinput --set-prop $id 'libinput Accel Profile Enabled' 0, 1; done
Emergency task end
Need to quickly shut off youtube videos?
bindsym Control+Mod1+q exec "killall mpv && killall vlc"
Audio player play/pause/skip/back controls
This is easy using playerctl
# media player bindsym XF86AudioPlay exec playerctl play-pause bindsym XF86AudioNext exec playerctl next bindsym XF86AudioPrev exec playerctl previous
Seeking with media player
bindsym $mod+XF86AudioNext exec playerctl position 20+ bindsym $mod+XF86AudioPrev exec playerctl position 10-
Change media player volume
bindsym $mod+XF86AudioRaiseVolume exec playerctl volume 0.05+ bindsym $mod+XF86AudioLowerVolume exec playerctl volume 0.05-
Lock computer
Using xscreensaver
bindsym Control+Mod1+l exec "xscreensaver-command -lock"
Using i3lock-fancy
bindsym Control+Mod1+l exec "i3lock-fancy -t 'Hello'"
Set desktop background color
Don't want to stare at your DM as your wallpaper?
exec --no-startup-id xsetroot -solid "#333333" &
Just pick the background color.
Notification support
Instead of each program using notifications, an easy solution is to use dunst. It supports notifications through notify-send as well as their own program. To launch on startup
exec dunst&
Pick which monitor gets the i3bar icons
Programs that stay in the tray on i3bar usually default to one of your monitors. To change this, just tell i3 which monitor to put the tray on.
bar { status_command i3status tray_output primary }
Where primary defaults to your primary monitor. This can be a single monitor as well.
Use rofi instead of dmenu
Rofi is a program launcher with some more features.
Just bind the key used to launch dmenu to rofi instead.
bindsym Mod1+d exec exec rofi -combi-modi window#drun#ssh -theme gruvbox-dark -font "hack 10" -show combi
Change monitor brightness (laptops)
On laptops, it is handy to have a way to change monitor brightness.
This can be done with a number of tools, I currently use light. -A is up, -U is down, don't ask me why.
bindsym XF86MonBrightnessUp exec light -A 5 bindsym XF86MonBrightnessDown exec light -U 5
On desktops, one can use ddcci to change the brightness of external displays.
Blue light filter
It can also be handy to have a bluelight filter. If on x11, you can use redshift. While there is also a gtk version, as well as configuration to have it auto-switch like flux, I just use the manual way.
redshift -O will set a desired color temperature, and -x cancels. I bound it to Mod+audio keys, but the choice is yours.
bindsym $mod+XF86AudioNext exec redshift -x bindsym $mod+XF86AudioPrev exec redshift -O 4000
Laptop display backlight
There are many tools for brightness and backlight control.
Light is simple and works.
bindsym XF86MonBrightnessUp exec light -A 5 bindsym XF86MonBrightnessDown exec light -U 5
Todo: use DDCCI to control backlight of external monitors.
Sharp font for i3bar
Use a bitmap font. So sharp on small size vs OpenType or TrueType. Try terminus or another bitmap.
font pango:Terminus 8
Discussion