Finishing the Linux desktop for geeks. Improved i3 and dmenu, pass password manager, surf browser, slock blocker, hotkey translator. Installed window manager i3 Window manager i3

i3WM logo

In modern graphical shells, the concept of tiling is greatly underestimated; primitive tiling exists in Windows and in shells such as KDE, Gnome, XFce. But all this is only partial support for tiling. Truly tiling is perfectly implemented in such window managers as Awesome, DWM, i3WM. And today we’ll just talk about the latter.

One of the easiest, most convenient and flexible Linux window managers to configure is undoubtedly i3WM. It gained the lion's share of its popularity thanks to its very simple setup, and in this guide we will analyze the i3wm config with examples of window manager configuration.

I think many readers of this post already know what it is dynamic window manager- which is what i3WM is. And for those who don’t know, I inform you that window managers (an integral part of any DE) are divided into two types, stack-based (floating windows) and frame-based (windows are arranged in a mosaic). And if you mix all this, you get a hybrid in the form of dynamic window managers, in which windows can switch from floating to frame mode.

It doesn’t matter why you chose i3wm among many other dynamic window managers... Whether it’s ease of setup (as you’ll see below), its ease compared to others, or simply on the advice of a more experienced Linux user. To begin with, I propose to consider what we will have out of the box after installing i3wm:

  • i3- The window manager itself
  • i3bar- The “native” panel in i3wm all that can do is display desktops and a terminal line
  • i3status- Display some information with a terminal line
  • i3lock- Computer unlock screen

Now let's deal with everything in order.

Setting up i3WM

After launch, we will be greeted with a window for selecting a mod key. There will be two options: Meta (windows button) and Alt. After launching, in front of us we will see only i3bar with i3status running in it and nothing else.

Mod key selection window

The default terminal is xterm - launched with the combination Mod+Enter. Let’s not get hung up on the controls for now, let’s just understand that to close the window you need to press Mod+Shift+q, and to restart i3 - Mod+Shift+r.

Now let's clarify for ourselves what we need

  • Wallpaper - For this we will use Nitrogen
  • Application launcher - There are many options here, we will consider only the most popular ones
  • Animations and VSync - For this we will need a composer, I suggest Compton because it is lightweight and stable


Memo for standard i3WM hotkeys

Config device in i3WM

By default, the i3WM config is located in the folder ~/.config/i3

In general, in order to masterfully work with the i3wm config, you just need to know that everything that comes after # is a comment, and three more things:
1) Programs are launched using exec; in order for our window manager to launch something, we use the following template

exec<команда>

  1. Example
    exec compton
    When you start i3, compton composer will also start
  2. Example
    exec ~/script.sh
    When you start i3, the script will run which is in your home folder under the name script.sh
  3. Example
    exec nitrogen - -restore
    When starting i3, run nitrogen with the restore option

2) Setting variables. In i3wm you can create variables, it all works like define in C++. The variable will be replaced by the string given to it. Variables can be set using set.

set $<имя переменной> <значение>

  1. Example
    set $color #023537
    Variable $color set to value #023537
  2. Example
    set $fileManager pcmanfm-qt
    Variable $fileManager pcmanfm-qt set value

It is convenient to use variables when creating a settings block, so that later you do not have to run through the i3wm config and search for the desired item.

3) Key combinations are set using bindsym, the syntax is extremely simple

bindsym<комбинация> <действие>

  1. Example
    bindsym $mod+1 workspace 1
    When we press the mod key and the number 1, we will go to desktop 1.
  2. Example
    bindsym XF86Tools exec firefox
    When you click the Tools button, FireFox will start
  3. Example
    set $press XF86Search
    set $search dmenu
    bindsym $press $search
    When you press the button specified in the variable, the program specified in another variable will be executed.

At the beginning of the config you should adjust a couple of lines to your taste:

set $mod Mod4 # Set mod key

font pango:xos4 Terminus 8 # Set the font for the window frames

Now let's dig deeper into creating hotkeys.
Most likely, you will have a 6th row of keys on your keyboard that you want to use to the fullest. To find out the name of the key I use xev.
Run xev, and pointing at the white window, press the desired key to find out its name. For the convenience of analyzing the 6th row, run it like this

This would be enough if not for a couple of problems that I encountered when trying to configure some keys.

1) Volume adjustment. I use pactl for these purposes, and to operate the +\- buttons and switch the state of the microphone and sound, I use these binds

bindsym XF86AudioRaiseVolume exec pactl set-sink-volume 0 +5%

bindsym XF86AudioLowerVolume exec pactl set-sink-volume 0 -5%

bindsym XF86AudioMute exec pactl set-sink-mute 0 toggle

bindsym XF86AudioMicMute exec pactl set-source-mute alsa_input.pci-0000_00_1b.0.analog-stereo toggle

2) Brightness adjustment. In general, this is unlikely to be a problem, but in order to more or less save you from googling, I’ll just show you how it’s done

bindsym XF86MonBrightnessUp exec xbacklight -inc 6
bindsym XF86MonBrightnessDown exec xbacklight -dec 6

Appearance

Window frames

Window control buttons in i3wm have been replaced with hotkeys

You can change the default window frame size using new_window pixel<Размер рамки в пикселях>- I set it to 1, just to see the borders of the windows.

The color of the window frames can be set using a template
<Класс окна> <Цвет границы> <Цвет фона> <Цвет текста> <Цвет индикатора>

Window classes:
client.focused- window in focus
client.unfocused- window out of focus
client.focused_inactive- the window is in focus but not active
client.urgent- the window requires attention (pop-up notification for example)

Example of color settings;

# class border backgr. text indicator child_border client.focused #4c7899 #285577 #ffffff #2e9ef4 #285577 client.focused_inactive #333333 #5f676a #ffffff #484e50 #5f676a client.unfocused #333333 #222222 #888888 #292d2e #222222 client.urgent #2 f343a #900000 # ffffff #900000 #900000 client.background #ffffff

Well, I think it’s worth giving an example of setting up i3bar colors - everything follows the same scheme, just slightly different tags.

Desktop indicator classes:

  • focused_workspace- Desktop in focus;
  • active_workspace- Active desktop;
  • inactive_workspace- Inactive desktop;
  • urgent_workspace- There is an application on the desktop that requires attention;

Example of color settings for i3bar:

Bar ( colors ( background #000000 statusline #ffffff separator #666666 focused_workspace #4c7899 #285577 #ffffff active_workspace #333333 #5f676a #ffffff inactive_workspace #333333 #222222 #888888 urgent_workspace #2f343a #900000 #ffffff ) )

Application Appearance

Qt logo

To customize the appearance of applications, you will need to work hard.
Let's start with something simple - GTK+ settings
All we need is just a program lxappearance,In it you can customize icons, GTK theme and cursor.

Now it’s more difficult - setting up Qt.
To configure Qt we will need only two applications qt4config And qt5ct.
Let's launch qt4config- choose a theme, font, etc. - that's it.
But if we run qt5ct then we will see a message about the absence of an environment variable. To fix it we will need to edit the file Xsession, because I use sddm- then I have it at /usr/share/sddm/scripts/Xsession. We need to add the line export QT_QPA_PLATFORMTHEME="qt5ct" to it - after which we’ll log in and we can easily launch qt5ct and configure there

In addition to standard themes for Qt, you can choose a theme engine. I advise you to pay attention to Quantum is an SVG based engine for Qt. Easy to set up, there are few themes yet, but what is available looks very cool and futuristic.

Animations and VSync

CompizFusion logo

We have already agreed that to ensure beautiful animation we will use a composer compton, now I won’t write about how to configure it, because the post is about i3WM and not about compton, I’ll just show you where to start.

Add exec compton -f --vsync drm to the config
And after the restart we get beautiful transitions, transparency and most importantly vertical synchronization, everything is very simple!

Wallpaper

Nitrogen interface

We also agreed about the wallpaper that we would use nitrogen. We launch it, select the wallpaper and rejoice, all that remains is to add exec nitrogen --restore to the config

Conky

Conky is a fairly popular widget in the Linux world.

This is an optional item, but I thought it was worth mentioning, here I’ll just show you how to run skates in i3wm
exec conky -c ~/.config/i3/conky_c
There is a lot of information on setting up skates on the Internet, I will only add that it is worth excluding them from processing shadows in compton.

Application Launcher

In general, there are a lot of different launchers for Linux, let’s look at the most popular ones.

  • Dmenu is a canonical launcher, in fact it is a drop-down terminal line with auto-completion. Minimalistic and lightweight.
  • Xfce AppFinder is an application launcher from the XFace environment, based on GTK+, not to say that it is a convenient solution, but it is simple and straightforward.
  • Rofi is a fairly flexible launcher, in addition to simply launching applications, it can navigate through windows and an ssh client.

Conclusion

After reading this guide, you will definitely be able to customize the i3WM window manager for yourself and have a unique desktop environment. Personally, I can add that it was thanks to my acquaintance with i3WM that I realized how flexible Linux is, and that you can work with exactly those tools that are convenient for you. In this regard, i3WM does not limit you, you just need to sit at the config.

Well, since this is the case, I think the ShowMyDesktop thread in the comments will not be out of place.
Thank you for your attention!

Unlike awesome, its settings are written in a regular text file.

Features of i3wm for the user: correct support for multiple monitors (see screenshot at the end), simple text config file, no need to rebuild wm after changing settings, three window layout modes, dmenu application launch menu, creates desktops as needed and deletes empty ones, out of the box it has an excellent information panel showing the Wi-Fi network level, battery charge and much more.

Demonstration from the author i3

Installation

i3wm is available in the Debian, Arch, Gentoo, Ubunto, FreeBSD, NetBSD, OpenBSD, OpenSUSE, Mageia, Fedora and Exerbo repositories. I will tell you using Ubuntu 12.04 as an example.

The package you need is called i3, so:

# apt-get install i3

You can now select “i3” as the window manager on the user and password screen.

Settings

When you first start, you will be asked to select a modifier key. I chose win for compatibility with most applications.

Let's add switching to the Russian layout using Alt+Shift, autoloading dropbox, switching between desktops using mod+Control+Left/Right, locking the screen using mod+Control+l and sleep mode with locking the screen when exiting using mod+Control+s .

Keyboard layout switching is configured using setxkbmap. For this purpose it is used

$ setxkbmap "us,ru" ",winkeys" "grp:alt_shift_toggle"

In order not to enter it every time after a reboot, let's create a .xsessionrc file in the user's root folder, make it executable and bring it to the form:

#!/bin/sh exec setxkbmap "us,ru" ",winkeys" "grp:alt_shift_toggle"

For Dropbox autoload, the .xsessionrc will look like this:

#!/bin/sh exec setxkbmap "us,ru" ",winkeys" "grp:alt_shift_toggle" & dropbox start &

Now the next time you log into i3wm, Russian and English keyboards will be available.

Setting up i3 is usually done using a user config. Let's create a folder ~/.i3 and copy the configuration template into it:

$ cp /etc/i3/config ~/.i3/config

Usage

Some standard hotkeys that work by default:

mod+Enter opens terminal
mod+d launches dmenu (a menu at the top of the screen that, as you type the name of the application from the keyboard, offers options for launching)
mod+Shift+Q closes the active window

mod+v enables vertical tiling mode (the screen will be divided horizontally)
mod+h enables horizontal tiling mode (the screen will be divided vertically)

mod+w enables tab mode (each window on the desktop occupies the entire screen, with tabs visible at the top)
mod+s enables stacked mode (window titles one below the other, each window occupies the entire screen)
mod+e returns standard mode
mod+Shift+Space switches the window to floating mode and back

mod+Left/Right/Up/Down moves focus within the desktop
mod+Shift+Left/Right/Up/Down moves the current window within the desktop

mod+1 etc. switches to the desktop with the specified number

mod+Shift+C reads settings from a configuration file
mod+Shift+E exits i3wm to the username and password entry screen

Full options for setting up and using i3wm are described in the documentation.

Bonus

If you have two monitors, or a netbook's built-in screen and an external monitor like I do, then i3wm will work great on them. The most important thing is that this does not require any additional settings.

List of available monitors:

$xrandr -q

Let's set them up to work in pairs:

$ xrandr --output LVDS1 --mode 1366x768 --pos 0x0 --output VGA1 --mode 1280x1024 --pos 1366x0

where LVD1 is the monitor built into the netbook, its resolution is 1366x768 and it is pressed to the upper left corner, VGA1 is an external monitor, its resolution is 1280x1024 and it is shifted 1366 pixels to the right relative to the upper left corner.

As you may remember, my first tile-based window manager was Xmonad. It suits me quite well on a desktop computer, but, unfortunately, on EeePC There is a lot of fuss with it - you need to finish the battery indicator, display the Wi-Fi signal level somewhere, etc. After a little consultation with people on Twitter, I decided to try the i3 window manager.

The i3 is installed something like this (oh, Bubunta):

sudo apt-get install i3 i3status i3lock dmenu

We finish working in the current window manager, enter the username and password, select the i3 window manager. When you first start i3 it will ask you whether to create a default config (yes, it goes without saying) and what to use as a Mod key (Win, because it's not needed for anything anyway).

That's it, we are working on i3. The basic keyboard shortcuts are as follows:

  • Mod + Enter - open a new terminal;
  • Mod + D - run any program via dmenu;
  • Mod + 0..9 - switching between workspaces;
  • Mod + Shift + 0..9 — moving windows to the specified workspace;
  • Mod + Shift + Q - close the current window;
  • Mod + Arrows - move between windows; instead of arrows, the keys “J” (left), “K” (down), “L” (up) and “;” can also be used. (right);
  • Mod + Shift + Arrows - moving windows within the workspace; letters and semicolons can also be used instead of arrows;
  • Mod + V - use vertical splitting;
  • Mod + H - use horizontal splitting;
  • Mod + E - default window placement (default layout);
  • Mod + S - stacking layout;
  • Mod + W - placement with tabs (tabbed layout);
  • Mod + F - expand the window to full screen or minimize it back;
  • Mod + Shift + Space - allow free movement of the window (floating mode) or return it to the mosaic;
  • Mod + Shift + R - restart i3 (for example, after updating the config);
  • Mod + Shift + E - exit i3;

You can resize windows by dragging their borders with the mouse. You can also switch to window resizing mode by pressing Mod + R. In this mode, using arrows or letters, you select the border of the window from which the window should be reduced or, if Shift is pressed, enlarged. Return to normal mode by pressing Enter or Escape.

Now consider the following screenshot (clickable):

To achieve this window arrangement, I first switched to vertical splitting (Mod + V) and created three windows (Mod + Enter). Then I selected each of the three windows in turn (Mod + Arrows), for each of them

switched to horizontal splitting (Mod + H) and created two more windows. In the top row I left the default layout, in the middle I switched to tabbed layout (Mod + W), and in the bottom row I switched to stacked layout (Mod + S).

The important point here is that windows in i3 form a tree structure (with parents and children). Changing the partitioning method (Mod + H/V) creates a new container (subtree), and switching the layout affects only the current container. Thanks to this approach, i3 allows you to achieve a much more complex window arrangement than Xmonad.

The main i3 configuration files are ~/.i3/config and ~/.i3status.conf.

In ~/.i3/config I added:

bindsym $mod+t border toggle
Exec dropbox start
exec wicd-client -t

exec gxneur &
Bar (
position top
}

status_command i3status

The next three lines add some programs to autorun. With Dropbox everything is clear. The wicd utility is a thing that hangs in the tray and allows you to manage connections to wired and wireless networks. It is installed as follows:

sudo apt-get install wicd
sudo /etc/init.d/wicd start

To prevent NetworkManager from interfering with wicd, we say:

sudo stop network manager

Also pay attention to the console analogue of wicd, the wicd-curses utility.

Addition: Everything turned out to be much simpler:

exec nm-applet &
exec blueman-applet &

Xneur, I think, needs no introduction. I used it simply as an indicator of the current keyboard layout (which, however, can be done without). xneur is installed as follows:

sudo apt-get install xneur gxneur

At the end of the config (bar block), I say to display the panel with the clock, tray, and so on at the top of the screen, and not at the bottom, as is done by default.

I took the file /etc/i3status.conf as a basis for ~/.i3status.conf. In it, I corrected the format for displaying the current date, changed the names of network interfaces, and removed unnecessary information about IPv6, DHCP and VPN. I see no point in presenting the result here. What pleases us about i3 is its intuitive config format and good documentation.

Well, the final touch is to add the following line to ~/.bashrc:

alias lockscreen="i3lock -c 000000"

The i3lock utility is designed to lock the screen. Unlike many similar utilities, it nothing at all does not show to the user. That is, the screen stupidly remains black (the color can be changed) until the current user's password is entered. In addition to a specific color, you can also use a PNG image.