Using i3 window manager in Linux

Published:
Last modified:

Overview

Notes to start using i3 lightweight window manager in Linux for developers.

Reasons

After using some popular desktop environments you realize that you don’t need all the fancy stuff they provide and that waster a lot of memory.

To use a lightweight window manager like i3 you need to feel comfortable with command line.

This is why a Window Manager is a great solution instead a Desktop Environment.

Unix philosophy

Be compliant with Unix/Linux philosophy:

This is the Unix philosophy: Write programs that do one thing and do it well. Write programs to work together.

That means it is better to use a Window Manager and other small dedicated programs that play nicely together instead of a full Desktop Environment.

Memory

Have the right amount of running processes you need, i.e.: optimize memory usage

Keyboard navigation

Have full control with keyboard navigation, this is the kind of VIm or Emacs users really appreciate.

Minimalistic

Minimalistic design, no window decorations or nonsense icons floating around.

Install

We will begin installing i3 with: sudo apt install i3

Basic commands

  • To start a new console: $meta+.
  • To start any GTK-based program: $meta+d .
  • To move through different workspaces we use: $meta + .

Workspaces

After we switch our session to i3, we will arrange our screens in three groups, in i3 terminology these are three different workspaces (group windows together).

  1. $meta+1. First for a browser
    • To start the Firefox for example, $meta+d and then write the firefox command, Enter
  2. $meta+2. Second for communication programs (irssi, mutt, etc)
  3. $meta+3. Rest of programs like text editors (hopefully Emacs ;) and consoles.

Additional commands

  • Moving a window to the third workspace, $mod+Shift+3
  • Close i3 session: $mod+Shift+e
  • Making a window float: $mod+Shift+Space

Additional configuration

The configuration file ~/.config/i3/config is the main place to tweak our settings and look for (or customize) key shortcuts.

i3status

i3status is a small program for generating a status bar for i3bar.

i3status configuration file possible locations:

  • ~/.config/i3status/config (or $XDG_CONFIG_HOME/i3status/config if set)
  • /etc/xdg/i3status/config (or $XDG_CONFIG_DIRS/i3status/config if set)
  • ~/.i3status.conf
  • /etc/i3status.conf

The idea of the i3 status configuration file is to specify which modules should be used and then configure each module in its own section.

After changing anything, $mod+Shift+r to reload i3 in place and reflect any changes.

dmenu

When trying to execute a command with the built in menu $meta+d, by default i3 runs: dmenu_run which shows a list of all available commands at console.

It would make more sense to only show the ones with a GTK visual interface, this can be done with the command i3-dmenu-desktop which shows the .desktop files with dmenu.

In the config file ~/.config/i3/config, comment the dmenu_run line and uncomment the new i3-dmenu-desktop line:

# start dmenu (a program launcher)
## bindsym $mod+d exec dmenu_run
# There also is the (new) i3-dmenu-desktop which only displays applications
# shipping a .desktop file. It is a wrapper around dmenu, so you need that
# installed.
bindsym $mod+d exec --no-startup-id i3-dmenu-desktop

i3lock

Similar to xscreensaver, lets lock the screen with $mod+z.

Add this to your config and reload to apply changes:

# Lock screen
bindsym $mod+z exec i3lock

Then $mod+Shift+r and $mod+z will lock the screen until you enter your user’s password.

Screen brightness

Download and install xbacklight:


$ sudo apt install xbacklight

Now configure keystrokes, in config file ~/.config/i3/config:

# Screen 
# increase screen brightness
bindsym XF86MonBrightnessUp exec --no-startup-id  "xbacklight -inc 5"
# decrease screen brightness
bindsym XF86MonBrightnessDown exec --no-startup-id "xbacklight -dec 5"
bindsym XF86MonBrightnessDown exec --no-startup-id "light -U 10"

There is also an alternative to xbacklight: light which can be used with the command light -U 10.

Volume keys

We have to configure volume keys to increase, decrease and mute using the Pulse Audio server, pactl command.


$ sudo apt install pavucontrol

And in config:

# Sound
# increase sound level
bindsym XF86AudioRaiseVolume exec --no-startup-id "pactl set-sink-volume @DEFAULT_SINK@ +5%"
# decrease sound level
bindsym XF86AudioLowerVolume exec --no-startup-id "pactl set-sink-volume @DEFAULT_SINK@ -5%"
# mute sound
bindsym XF86AudioMute exec --no-startup-id "pactl set-sink-mute 0 toggle"

Utilities

Some utilities that are useful to keep in mind, specially at console.

Image viewers

sxiv

Simple X Image Viewer. The primary goal of sxiv is to create an image viewer, which only has the most basic features required for fast image viewing

sudo apt install sxiv sxiv

feh

There is a lightweight image viewer for the terminal: feh.

sudo apt install feh feh

Also useful for setting up a wallpaper, in i3 config:

exec --no-startup-id feh --bg-fill /path/to/wallpaper.jpg

Live USB creator

Creating usb disk from iso files:

  • usb-creator-gtk
  • unetbootin

PDF viewer

qpdfview is a tabbed document viewer.

It uses Poppler for PDF support, libspectre for PS support, DjVuLibre for DjVu support, CUPS for printing support and the Qt toolkit for its interface.

To install it: sudo apt install qpdfview

Printing

See which printers are available: lpstat -p -d

To configure CUPS printers using a graphical interface: system-config-printers

Print files from command line: lpr command: lpr < file >

TODO

Add resources monitor like conky.

References

Uruguay
Marcelo Canina
I'm Marcelo Canina, a developer from Uruguay. I build websites and web-based applications from the ground up and share what I learn here.
comments powered by Disqus

Notes on how to be more productive in Linux using a window manager instead of desktop environments.

Clutter-free software concepts.
Translations English Español

Except as otherwise noted, the content of this page is licensed under CC BY-NC-ND 4.0 . Terms and Policy.

Powered by SimpleIT Hugo Theme

·