23 Nov 2016
$mod + Enter
- Opens Terminal$mod + Shift + Space
- Makes current window floating$mod + [1,2,3,..,10]
- Switch workspaces from 1 .. 10$mod + Shift + [1,2,3,..,10]
- Moves current window to workspace 1 .. 10$mod + Shift + R
- Restart i3$mod + Shift + E
- Exits i3For a complete list visit the refcard page.
i3 config file
When we first log in to i3, a wizard pops up asking which $mod
key, we want to use. Every action, be it moving windows,
resizing them, opening applications etc.. use keybindings (keyboard shortcuts). And every keybinding is modelled
using a specific $mod
key. i3 gives you the choice of the Alt key and the Super (Win) key to be that specific $mod
key.
All of i3wm's configuration is done in a file located at $HOME/.config/i3/
called config
.
This file is generated by the i3 wizard when we first login to i3. We make changes to that file and then restart i3.
That'll reload i3 with the new config. Sometimes, we'll need to logout and log back in to see the changes.
In some distros the config might be generated at $HOME/.i3
.
Installed apps
A sudo apt install i3
installs some additional applications like i3status
, dmenu
from the
suckless-tools
package and dunst
(a minimal notification tool).
i3status
i3status
is a tool that i3 runs to display system info in the i3bar.
To configure it bring the default config file to our $HOME
$ mkdir ~/.config/i3status
$ cp /etc/i3status.conf ~/.config/i3status/config
man pages
Everything and anything we need to know about a particular tool we'd use, has a manual page.
We access the man page with the man
command. But by default, the man page formatting is not that pretty.
Let's add some color. Install a pager called most
with sudo apt install most
and then open $HOME/.bashrc
.
Add a section to the end of the file.
# colored man pages
export PAGER="most"
Now if we bring in a terminal and do a man i3status
, we have colored headings in the page
and the search is a bit more nicer. To search in the man page type /search-term
and press Enter
.
compton
A pretty sweet composite manager. I like some shadows and fading effects on my windows and menus.
Install it with sudo apt install compton
.
parcellite
A simple, lightweight clipboard manager. Install it with sudo apt install parcellite
.
pnmixer
Volume control tray icon. Install it with sudo apt install pnmixer
.
nitrogen
Sets our wallpaper. Install it with sudo apt install nitrogen
. Run nitrogen
and choose a
directory of our wallpapers. Then choose an image and click Apply.
Fire up i3's config
file in an editor of our liking, and let's get cracking.
Startup applications
i3 has a very straight forward system tray. Let's use it. If we execute nm-applet
in a terminal,
we'll see our familiar network icon in i3's system tray.
The same can be done for pnmixer
and parcellite
.
To run them or any other app on i3's startup add them to the end of i3's config file like so,
## start up
# clipboard manager
exec --no-startup-id parcellite
# network tray
exec --no-startup-id nm-applet
# volume applet
exec --no-startup-id pnmixer
# fancy window shadows and fading effects
exec --no-startup-id compton -cCGb --backend glx --vsync opengl
# wallpaper
exec --no-startup-id nitrogen --restore
the --no-startup-id
helps with this.
To tile or not to tile
Some app windows are better viewed in floating mode. A personal favourite of mine, is the
tool called lxappearance
which helps in changing gtk-themes. We make a rule in i3's config
to
allow windows having the class "lxappearance" to open in floating mode.
To find the class of a window, execute xprop
in a terminal and click on the window we want
info about. The line WM_CLASS(STRING)
is what we're after.
Add the rules to i3 config
for all the applications we want in floating mode like so
# open certain windows in floating mode
for_window [class="(?i)lxappearance"] floating enable
for_window [class="(?i)xcalc"] floating enable
for_window [class="(?i)xfontsel"] floating enable
for_window [window_role="(?i)pop-up"] floating enable #pop-up windows as floats
Window decorations
i3 by default has title bars for windows. I'd rather have no titlebars but I love some fat borders. Add the following to our config to get that
# no window borders
new_window pixel 2
new_float pixel 2
Custom shortcuts
i3 allows us to open up apps or do actions with keyboard shortcuts. To make a
keyboard shortcut for an application, say google-chrome
, we add to the config file,
# keybinds for applications
bindsym $mod+Shift+w exec --no-startup-id google-chrome
Care should be taken to find whether the new keybind is already being used. In that case, assign something else for the existing action and then add the new keybind.
Rofi
Pressing $mod + d
brings an app called dmenu
, with which we can launch other applications.
Just type in the name of application and press Enter
.
Rofi is a replacement for dmenu. Let's just say it's a bit more pretty and has a little more "oomph" than dmenu.
rofi's colors can be set via the universal .Xresources
file in our $HOME
. Open it and add the following
# monochromatic colors for rofi
rofi.color-enabled: true
rofi.separator-style: none
rofi.color-window: #000000, #aaaaaa, #000000
rofi.color-normal: #000000, #aaaaaa, #000000, #aaaaaa, #000000
rofi.color-active: #000000, #aaaaaa, #000000, #aaaaaa, #000000
rofi.color-urgent: #000000, #aaaaaa, #000000, #aaaaaa, #000000
Apply the changes by executing in a terminal xrdb ~/.Xresources
. If in a terminal,
we execute rofi like rofi -show run -width 30 -lines 5 -font "Liberation Mono 15"
,
we'll see a run dialog like dmenu. BTW I'm a big fan of the
Liberation series of fonts.
The package is fonts-liberation
in ubuntu. If we execute a
rofi -show window -width 60 -font "Liberation Mono 15"
, we'll see a list of open apps.
Call them with keybinds by editing the config
like so,
#bindsym $mod+d exec dmenu_run
bindsym $mod+d exec rofi -show run -width 30 -lines 5 -font "Liberation Mono 15"
bindsym $mod+Tab exec rofi -show window -width 60 -font "Liberation Mono 15"
Since dmenu
was using $mod + d
, I commented out that line and replaced it with an entry for rofi
.
GTK-theming
gnome-look is a great resource for gtk themes. Find one that strikes your fancy and
extract it's archive to either $HOME/.themes
(local install) or /usr/share/themes
(global install).
Then open up lxappearance
and apply the new theme.
Some themes require newer versions of gtk installed. To find version of gtk
we're using, run in a terminal dpkg -l libgtk* | grep -e '^i' | grep -e 'libgtk-*[0-9]'
.
We get something like
ii libgtk-3-0:amd64 3.20.9-1ubuntu2 amd64
ii libgtk-3-common 3.20.9-1ubuntu2 all
...
ii libgtk2.0-0:amd64 2.24.30-4ubuntu2 amd64
ii libgtk2.0-common 2.24.30-4ubuntu2 all
3.20
is our gtk-3 version and 2.24
is our gtk-2 version. Always use themes from authors
that make use of a gtk-version <= our-gtk-version
.
Exit menu
To get an exit dialog on a keypress, we need to get somethings up and running.
In our $HOME/.config/.i3/
, create a directory called bin
. In that create 2 files
called poweroff.sh
and reboot.sh
. The contents of them are
$ cat ~/.config/.i3/bin/reboot.sh
#!/bin/sh
sudo /sbin/reboot
exit 0
$ cat ~/.config/i3/bin/poweroff.sh
#!/bin/sh
sudo /sbin/poweroff
exit 0
We may place these files anywhere, but this way it's organized. Make sure these files / scripts are executable.
$ chmod +x ~/.config/.i3/bin/*.sh
Now we give ourselves permission to execute these scripts with sudo
,
without the need for providing a password. Execute sudo visudo
in a terminal and
add the following at the end
# shutdown, reboot for i3
akts ALL=(ALL) NOPASSWD: /home/akts/.config/i3/bin/poweroff.sh
akts ALL=(ALL) NOPASSWD: /home/akts/.config/i3/bin/reboot.sh
Next, we make an exit dialog in i3bar, by adding the following to our i3 config.
# exit dialogue
set $conf_dir "/home/akts/.config/i3"
set $mode_system System (e) xit, (r) eboot, (p) oweroff
mode "$mode_system" {
bindsym e exec --no-startup-id i3-msg exit, mode "default"
bindsym r exec --no-startup-id sudo $conf_dir/bin/reboot.sh, mode "default"
bindsym p exec --no-startup-id sudo $conf_dir/bin/poweroff.sh, mode "default"
# back to normal: Enter or Escape
bindsym Return mode "default"
bindsym Escape mode "default"
}
bindsym $mod+Shift+x mode "$mode_system"
Press e
to exit i3, p
to power down and r
to reboot.
Screen lock
Install i3lock
and go here for a good
sceenlock script.
Multimedia keyboard keys
Adding the following to i3 config solved this for me.
bindsym XF86AudioLowerVolume exec --no-startup-id /usr/local/bin/vlow.sh
bindsym XF86AudioRaiseVolume exec --no-startup-id /usr/local/bin/vhigh.sh
bindsym XF86AudioMute exec --no-startup-id /usr/local/bin/vmute.sh
The contents of these scripts are as follows. Make sure these are executables.
$ cat /usr/local/bin/vlow.sh
#!/bin/sh
/usr/bin/pactl set-sink-volume @DEFAULT_SINK@ '-5%'
exit 0
$ cat /usr/local/bin/vhigh.sh
#!/bin/sh
/usr/bin/pactl set-sink-volume @DEFAULT_SINK@ '-5%'
exit 0
$ cat /usr/local/bin/vmute.sh
#!/bin/sh
/usr/bin/pactl set-sink-volume @DEFAULT_SINK@ 0
exit 0
This little writing is by no means, a complete guide, but it'll serve as a starting point. Users of i3 are encouraged to read the excellent i3 user's guide.
Have a great day!