Note

The Funtoo Linux project has transitioned to "Hobby Mode" and this wiki is now read-only.

Package:I3 (Window Manager)

From Funtoo
Revision as of 00:51, September 8, 2014 by Drobbins (talk | contribs)
Jump to navigation Jump to search

I3 (Window Manager)

   Tip

We welcome improvements to this page. To edit this page, Create a Funtoo account. Then log in and then click here to edit this page. See our editing guidelines to becoming a wiki-editing pro.


Introduction

i3 is a tiling window manager that is based upon experiences the developers shared while attempting to fix/hack wmii. i3 has the ability for either floating windows, which you can resize and move, and tiling windows. i3 uses a tree as a data structure to allow for more flexibility. i3 defaults with home-row key-bindings which are quick and easy to get beginners off the ground.

   Note

This wiki is made following the steps produced to get a working i3 using xrandr instead of xinerama, ATI proprietary drivers instead of Radeon drivers, a dual-monitor setup, and no login manager. For NVIDIA and Twinview users, a link is supplied in X11 and xrandr. Xinerama was initially used and worked in the dual-monitor setup so it possible to substitute xinerama for xrandr with minimal changes.

Installation

Portage

The easiest and quickest way:

root # emerge -avt x11-wm/i3

Manual

Tarball

Download the latest version from the i3 website. i3-4.8

root # cd /PATH/TO/TARBALL
root # make
root # sudo make install

Git

root # git clone git://code.i3wm.org/i3
root # cd i3
root # make
root # sudo make install

Setup

xinitrc

Edit ~/.xinitrc:

exec i3


For i3 logging, edit ~/.xinitrc:

exec i3 -V -d all >~/.i3/i3log-$(date +'%F-%k-%M-%S') 2>&1

If you are using Nvidia or for some reason don't use xrandr, edit ~/.xinitrc

exec i3 --force-xinerama

and nvidia with logging:

exec i3 --force-xinerama -V -d all >~/.i3/i3log-$(date +'%F-%k-%M-%S') 2>&1

Example ~/.xinitrc that uses consolekit and dbus in launch and also logs on exit.

#!/bin/zsh
xrdb -merge ~/.Xresources
xcompmgr &

if [[ $1 == "i3" ]]; then
    exec ck-launch-session dbus-launch --sh-syntax --exit-with-session i3 -V -d all > ~/.i3/i3log-$(date +'%F-%k-%M-%S') 2>&1
elif [[ $1 == "razor" ]]; then
    exec ck-launch-session dbus-launch startrazor
elif [[ $1 == "awesome" ]]; then
    exec ck-launch-session dbus-launch awesome
elif [[ $1 == "qtile" ]]; then
    exec ck-launch-session dbus-launch ~/.qtile-session
else
    echo "Choose a window manager"
fi

X11 and xrandr

X and RandR

NOTE: RandR and Xinerama do not play together. Use one or the other.

I use an AMD HD 6870 with 3 monitors (2 DVI and 1 with an AMD validated Mini DisplayPort™ to DVI dongle).

Install No results:

root # emerge x11-apps/xrandr

and if you want a GUI with xrandr:

root # emerge x11-misc/arandr

If you do not have X configured yet, follow the link on the Gentoo Wiki

My xorg.conf.d folder for example: 30-screen.conf

Since the names of the monitors are already known in xrandr, I just use those names in my 30-screen.conf configuration. It doesn't matter what you use in your X configuration however.

Once you have X configured however you like, start qtile with either:

root # startx

or, in a case similar to mine:

root # xinit qtile

i3 config

The i3 configuration file can be found in /etc/i3/config, but I suggest that you copy the file into a local ~/.i3 directory.

# mkdir -p ~/.i3 && cp /etc/i3/config ~/.i3/config

Open up ~/i3/config in your editor of choice. set $mod Mod1 assigns the variable $mod to be Mod1. In i3, Mod1 is the Alt key. If you wish to use the Windows key then use set $mod Mod4 In the keybinding section, $mod is used in place of Mod1 in the case that you do wish to change the modifier. In the workspace key, the keybindings are set with Mod1 instead of the variable, so remember to change those bindings manually if you are replacing the Mod1 modifier. Else you can change Mod1 in those sections to $mod and change all the keybindings at the same time by setting the $mod variable.

set $mod Mod1

To have programs start automatically in i3, use the command exec APPLICATION. This is the section that the xrandr screen layout bash file created earlier will be placed. The i3bar is a tray and status bar combination. If you have applications that run in the system tray that you want to autostart, call those applications with exec.

exec /PATH/TO/XRANDR-BASH-FILE
exec NAME OF BROWSER
exec NAME OF EDITOR
exec volumeicon
exec dropbox

In the workspace section, you have the opportunity to name the workspaces by setting either the number of the workspace, the name of the workspace, or the number and name of the workspace. bindsym KEYBIND workspace NAME/NUMBER OF WORKSPACE. Remember to use quotes when naming a workspace.

bindsym Mod1+1 workspace 1
bindsym Mod1+1 workspace "my first workspace"
bindsym Mod1+1 workspace "1: my first workspace"

To assign a workspace to a certain output you will need the output from running xrandr again if you do not remember which connections are being used. In the example from [#X11 and xrandr|X11 and xrandr], the connected outputs are DFP3 and DFP4. To assign the workspace, you need to add workspace NAME OF WORKSPACE or NUMBER output CONNECTED OUTPUT. There are several types of outputs so make sure that you are using the connected outputs from xrandr when assigning workspaces, else the workspace will not show up.

workspace 1 output DFP3
workspace "my first workspace" output DFP3
workspace "1: my first workspace" output DFP3
workspace "2: my second workspace" output DFP4

To assign a program to a certain workspace, you will need to run xprop. If you do not have xprop, emerge it.

# emerge -avt x11-apps/xprop
To run xprop, open a terminal and run
# xprop
Your mouse cursor should become a crosshair and you will want to mouse over the window that contains the running application. Click on that window and xprop will then output the window information. The easiest way to assign a program is to look for
WM_CLASS(STRING) = "INSTANCE", "CLASS"
Be sure to note that the window INSTANCE is before the window CLASS. In the config file, add assign [class="^INSTANCE$" instance="^CLASS$] NAME OF WORKSPACE. For aesthetic purposes, you can add → before NAME OF WORKSPACE, but mind that the → is a UTF-8 character and not ->. For the assignments, do not put the workspace name within quotes as you do when naming them and setting their output.
assign [class="^Chromium-browser$" instance="^chromium-browser$"] 1
assign [class="^Chromium-browser$" instance="^chromium-browser$"] web
assign [class="^Chromium-browser$" instance="^chromium-browser$"] 1: web
assign [class="^Chromium-browser$" instance="^chromium-browser$"] → 1
assign [class="^Chromium-browser$" instance="^chromium-browser$"] → web
assign [class="^Chromium-browser$" instance="^chromium-browser$"] → 1: web

For aesthetic purposes, their are three types of borders for the windows. This can be set by adding new_window <normal|1pixel|none>. There are also keybindings that allow you to switch between the 3 border styles.

new_window 1pixel
bindsym $mod+t border normal
bindsym $mod+y border 1pixel
bindsym $mod+u border none

The orientation for new workspaces can be set by adding default_orientation <horizontal|vertical|auto>

default_orientation horizontal

A sample ~/.i3/config:

set $mod Mod1

########################################################
########		Autostart		########
########################################################
exec ~/.screenlayout/dualdtop.sh			
exec chromium-browser					
exec gvim						
exec volumeicon							
exec parcellite
exec dropbox

########################################################
########		Workspaces		########
########################################################
# switch to workspace
bindsym Mod1+1 workspace "1: web"
bindsym Mod1+2 workspace "2: irc"
bindsym Mod1+3 workspace "3: gvim"
bindsym Mod1+4 workspace "4: ranger"
bindsym Mod1+5 workspace "5: terms"
bindsym Mod1+6 workspace "6: mplayer"
bindsym Mod1+7 workspace "7: mail"
bindsym Mod1+8 workspace "8: firefox"
bindsym Mod1+9 workspace "9: music"
bindsym Mod1+0 workspace "10: office"

## Output certain workspaces
workspace "1: web" output DFP3
workspace "2: irc" output DFP4
workspace "3: gvim" output DFP4
workspace "4: ranger" output DFP3
workspace "5: terms" output DFP4
workspace "6: mplayer" output DFP3
workspace "7: mail" output DFP3
workspace "8: firefox" output DFP3
workspace "9: music" output DFP3
workspace "10: office" output DFP4

## Assign workspaces to programs
assign [class="^Chromium-browser$" instance="^chromium-browser$"] → 1: web
assign [class="^Gvim$" instance="^gvim$"] → 3: gvim
assign [class="^MPlayer$" instance="^gl$"] → 6: mplayer
assign [class="^Firefox$" instance="^Navigator$"] → 8: firefox
assign [class="^Emacs$" instance="^emacs$"] → 9: emacs
assign [class="^libreoffice-startcenter$" instance="^VCLSalFrame.DocumentWindow$"] 10: office

# move focused container to workspace
bindsym Mod1+Shift+1 move workspace 1
bindsym Mod1+Shift+2 move workspace 2
bindsym Mod1+Shift+3 move workspace 3
bindsym Mod1+Shift+4 move workspace 4
bindsym Mod1+Shift+5 move workspace 5
bindsym Mod1+Shift+6 move workspace 6
bindsym Mod1+Shift+7 move workspace 7
bindsym Mod1+Shift+8 move workspace 8
bindsym Mod1+Shift+9 move workspace 9
bindsym Mod1+Shift+0 move workspace 10

########################################################
########		Aesthetics		########
########################################################
# Window border style: normal: border normal, with window title bar;
# none: no border or window title bar; 1pixel: 1 pixel border.
new_window 1pixel
bindsym $mod+t border normal
bindsym $mod+y border 1pixel
bindsym $mod+u border none

# font for window titles. ISO 10646 = Unicode
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1

# Orientation for new workspaces
# Can be set <horizontal|vertical|auto>
default_orientation horizontal

# Layout for new containers
# Can be set <default|stacking|tabbed>
workspace_layout default

# Use Mouse+$mod to drag floating windows to their wanted position
floating_modifier $mod

########################################################
########		Keybindings		########
########################################################

# start a terminal
bindsym $mod+Return exec i3-sensible-terminal

# kill focused window
bindsym $mod+Shift+Q kill

# start dmenu (a program launcher)
bindsym $mod+d exec dmenu_run

# change focus
bindsym $mod+j focus left
bindsym $mod+k focus down
bindsym $mod+l focus up
bindsym $mod+semicolon focus right

# alternatively, you can use the cursor keys:
bindsym $mod+Left focus left
bindsym $mod+Down focus down
bindsym $mod+Up focus up
bindsym $mod+Right focus right

# move focused window
bindsym $mod+Shift+J move left
bindsym $mod+Shift+K move down
bindsym $mod+Shift+L move up
bindsym $mod+Shift+colon move right

# alternatively, you can use the cursor keys:
bindsym $mod+Shift+Left move left
bindsym $mod+Shift+Down move down
bindsym $mod+Shift+Up move up
bindsym $mod+Shift+Right move right

# split in horizontal orientation
bindsym $mod+h split h

# split in vertical orientation
bindsym $mod+v split v

# enter fullscreen mode for the focused container
bindsym $mod+f fullscreen

# change container layout (stacked, tabbed, default)
bindsym $mod+s layout stacking
bindsym $mod+w layout tabbed
bindsym $mod+e layout default

# toggle tiling / floating
bindsym $mod+Shift+space floating toggle

# change focus between tiling / floating windows
bindsym $mod+space focus mode_toggle

# focus the parent container
bindsym $mod+a focus parent

# focus the child container
#bindcode $mod+d focus child

# reload the configuration file
bindsym $mod+Shift+C reload
# restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
bindsym $mod+Shift+R restart
# exit i3 (logs you out of your X session)
bindsym $mod+Shift+E exit

# resize window (you can also use the mouse for that)
mode "resize" {
        # These bindings trigger as soon as you enter the resize mode
        # They resize the border in the direction you pressed, e.g.
        # when pressing left, the window is resized so that it has
        # more space on its left

bindsym j resize shrink left 10 px or 10 ppt
bindsym Shift+J resize grow left 10 px or 10 ppt

bindsym k resize shrink down 10 px or 10 ppt
bindsym Shift+K resize grow down 10 px or 10 ppt

bindsym l resize shrink up 10 px or 10 ppt
bindsym Shift+L resize grow up 10 px or 10 ppt

bindsym semicolon resize shrink right 10 px or 10 ppt
bindsym Shift+colon resize grow right 10 px or 10 ppt

        # same bindings, but for the arrow keys
bindsym Left resize shrink left 10 px or 10 ppt
bindsym Shift+Left resize grow left 10 px or 10 ppt

bindsym Down resize shrink down 10 px or 10 ppt
bindsym Shift+Down resize grow down 10 px or 10 ppt

bindsym Up resize shrink up 10 px or 10 ppt
bindsym Shift+Up resize grow up 10 px or 10 ppt

bindsym Right resize shrink right 10 px or 10 ppt
bindsym Shift+Right resize grow right 10 px or 10 ppt

        # back to normal: Enter or Escape
bindsym Return mode "default"
bindsym Escape mode "default"
}

bindsym $mod+r mode "resize"

########################################################
########		i3bar			########
########################################################

# Start i3bar to display a workspace bar (plus the system information i3status
# finds out, if available)
bar {
    output            DFP3
    output	      DFP4
    status_command    i3status -c ~/.i3status.conf
    position          top
    mode              dock
    workspace_buttons yes
    tray_output       DFP3
    
    font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1

    colors {
        background #000000
        statusline #FFFFFF

        focused_workspace  #ffffff #9932CC
        active_workspace   #ffffff #DA70D6
        inactive_workspace #888888 #242424
        urgent_workspace   #ffffff #32CD32
    }
} 

These scripts can be found in /usr/bin/

i3nagbar

The i3nagbar is the error bar that pops up on top of the screen when there is an error in the i3 configuration.

i3-sensible-editor

i3-sensible-editor is callen when the user presses the edit button on the i3nagbar. If $EDITOR is set, that editor will be used, else i3-sensible-editor will open the first editor that is installed according to the order in i3-sensible-editor. If the user has a preference, he will set $EDITOR.

i3-sensible-terminal

i3-sensible-terminal is called when the user opens a terminal. If $TERMINAL is set, that terminal will be used, else i3-sensible-terminal will open the first terminal that is installed according to the order in i3-sensible-terminal. If the user has a preference, he will set $TERMINAL.

i3-sensible-pager

i3-sensible-pager is called when the user presses the view button on the i3nagbar. If $PAGER is set, that pager will be used, else i3-sensible-pager will open the first pager that is installed accordding to the order in i3-sensible-pager. If the user has a preference, he will set $PAGER.

i3status

i3status generates a status bar similar to conky in i3. i3status replaces dzen2, xmobar, and other similar applications used in older versions of i3. It is suggested to create an ~/.i3status.conf file to configure the i3status bar locally. A sample ~/.i3status.conf:

general {
        colors = true
        interval = 5
}

order = "disk /"
order += "disk /home"
order += "ethernet eth0"
order += "cpu_temperature 0"
order += "cpu_temperature 1"
order += "cpu_temperature 2"
order += "cpu_temperature 3"
order += "load"
order += "time"

ethernet eth0 {
        # if you use %speed, i3status requires the cap_net_admin capability
        format_up = "Eth0: %ip (%speed)"
        format_down = "Eth0: down"
}

time {
        format = "%a:%d-%b-%Y %I:%M:%S %p"
}

load {
        format = "Load: %5min"
}

cpu_temperature 0 {
	format = "T1: %degrees °C"
	path = "/sys/devices/platform/coretemp.0/temp2_input"
}

cpu_temperature 1 {
	format = "T2: %degrees °C"
	path = "/sys/devices/platform/coretemp.0/temp3_input"
}

cpu_temperature 2 {
	format = "T3: %degrees °C"
	path = "/sys/devices/platform/coretemp.0/temp4_input"
}

cpu_temperature 3 {
	format = "T4: %degrees °C"
	path = "/sys/devices/platform/coretemp.0/temp5_input"
}

disk "/" {
        format = "/: %free"
}

disk "/home" {
	format = "/home: %free"
} 

dmenu

i3 uses No results as the application launcher. To install it, run the following:

root # emerge dmenu
   Note
The default key-binding for dmenu is Mod1+d.

Default Keybindings

Alt + Enter Open terminal
Alt + A Focus Parent
Alt + S Stacked Layout
Alt + W Tabbed Layout
Alt + E Default Layout
Alt + SpaceBar Focus tiling/floating
Alt + D dmenu
Alt + H Split Horizontal
Alt + V Split Vertically
Alt + J Left
Alt + K Down
Alt + J Up
Alt + ; Right
Alt + Shift + Q Kill window
Alt + Shift + E Exit i3
Alt + Shift + C Reload i3config without restarting
Alt + Shift + R Restart i3 (reloads i3config without exiting i3)
Alt + Shift + J Move left
Alt + Shift + K Move down
Alt + Shift + L Move up
Alt + Shift + : Move right
Alt + Shift + SpaceBar Toggle tiling/floating

Troubleshooting

i3status

   Note
i3status may not work out of box
The permissions may be set to: -r-xr-x---: when run as non-root, sh would return with "permission denied".

If i3status does not work for you, this can be easily corrected by changing the permissions.

root # sudo chmod 755 /usr/bin/i3status

Documentation

Websites

i3

User Guide

More Documentation

Man pages

  • i3
  • i3-config-wizard
  • i3-input
  • i3-migrate-config-to-v4
  • i3-msg
  • i3-nagbar
  • i3-sensible-editor
  • i3-sensible-pager
  • i3-sensible-terminal
  • i3-wsbar
  • i3bar
  • i3lock
  • i3status