From LinuxBBQ Wiki
Jump to: navigation, search

i3 is a tiling window manager. This article will help with some tips and tricks to get i3 up and running and help to give a solid starting point to getting the most out of this window manager.

i3wm on your BBQ

The LinuxBBQ release Threesome uses the i3 window manager.

Get the latest version and stay on the cutting edge

echo 'deb http://build.i3wm.org/debian/sid sid main' > /etc/apt/sources.list.d/i3-autobuild.list
apt-get update
apt-get --allow-unauthenticated install i3-autobuild-keyring
apt-get update
apt-get install i3

Config file

i3 is located in your home directory


Open the i3 config file

vi .i3/config


Using conky instead of i3status:

In the config file, find this section

bar {
status_command i3status

In case you want to utilize i3status it is located here:


Comment out the first line and replace with conky. It should look like this

bar {
#status_command i3status
status_command conky

If you use multiple window managers each with a different conkyrc, you can keep you i3 conkyrc in the .i3 directory to stay organized and link to that path.

bar {
#status_command i3status
status_command -c /home/username/.i3/conkyrc

In order to pass colors to your conky in the status bar we need to use JSON. Follow these steps

Create a script in ~/bin and name it conky_i3bar.sh.


# Send the header so that i3bar knows we want to use JSON:
echo '{ "version": 1 }'
echo '['
echo '[],'
exec conky -c $HOME/.i3/.conkyrc

Make executable

chmod +x bin/conky_i3bar.sh

Create the .conkyrc file. I place it in the .i3 directory to stay organized
This is a sample from what I use. Configuring to your tastes is up to you and the fun part.

out_to_x no
own_window no
out_to_console yes
background no
max_text_width 0
update_interval 2.0
total_run_times 0
short_units yes
cpu_avg_samples 4 


# JSON for i3bar

	{ "full_text" : "Mail: ${execpi 60 python ~/bin/gmail.py}  " , "color" : 
                 ${if_match ${execpi 60 python ~/bin/gmail.py}>1}"\#bf3f34"${else}"\#315858"${endif} },

	{ "full_text" : "  Up: ${uptime_short}  " , "color" : "\#315858" },

	{ "full_text" : "  CPU: ${cpu}%  " , "color" : 
		${if_match ${cpu}>10}"\#bf3f34"${else}"\#315858"${endif} },

	{ "full_text" : "  Home ${fs_free /home} Free  " , "color" : "\#315858" } ,

	{ "full_text" : "  TEMP: ${acpitemp}F  " , "color" :
		${if_match ${acpitemp}>43}"\#bf3f34"${else}"\#315858"${endif} },

 	{ "full_text" : "  RAM  ${memperc}%  " , "color" :
    		${if_match ${memperc}>25}"\#bf3f34"${else}"\#315858"${endif} } ,

	{ "full_text" : "  BATT:${battery_percent BAT0}%  " , "color" :
		${if_match ${battery_percent BAT0}<30}"\#bf3f34"${else}"\#315858"${endif} } ,

	{ "full_text" : "  WLAN:${wireless_link_qual_perc wlan0}% " , "color" : 
                ${if_match ${wireless_link_qual_perc wlan0}<65}"\#bf3f34"${else}"\#315858"${endif} } 


Link to the conky_i3bar.sh script in the config file

status_command $HOME/bin/conky-i3bar.sh

Status Bar Colors

Changing the colors of your status bar font color is also done in the same section

bar {
#	status_command i3status
	status_command conky -c /path/to/conky

  colors {
	statusline	#666666
# class            	       border 		backgrd 	text
        focused_workspace     #000000 		#000000 	#d70a53
        active_workspace      #000000 		#000000 	#696f89
        inactive_workspace    #000000 		#000000 	#696f89
        urgent_workspace      #d72f6b 		#d70a53 	#FFFF50

Window Border Colors

Changing the colors of your window borders find or create a section in you config file. You can obviously pick your own color options.

# colors
# class                         border  backgr.    text
client.focused			#424242 #424242	 #999999
client.unfocused		#424242 #424242  #666666
client.focused_inactive		#424242 #424242	 #666666
client.urgent			#424242 #424242  #ee0000


Adding your own keybindings

bindsym $MOD+SHIFT+Return exec urxvt 
bindsym $MOD+SHIFT+w exec iceweasel 

Setting keybindings for Volume Control:
Note that to use these keybindings I commented out others that were pre-configured that I did not use, to free up the arrow keys I wanted to use.

bindsym $MOD+SHIFT+Up exec amixer set Master 5.0%+
bindsym $MOD+SHIFT+Down exec amixer set Master 5.0%-

Window Border Style

Changing window border's width:

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

Window Manipulation

Control your windows. For example, I want Iceweasel to open in workspace 2 and change the border to 1pixel:

assign [class="Iceweasel"] 2
for_window [class="Iceweasel"] border 1pixel

You can also specify if the window should open in tiling mode or floating mode:

for_window [class="URxvt"] floating enable 

You can also specify to launch specific applications in a tabbed layout:

for_window [class="Iceweasel"] layout tabbed

Focusing specific applications when they are launched:

for_window [class="Iceweasel"] focus

Now you need not to make so many entries if you're going to use the same preference for more than one application:

for_window [class="Chromium|Iceweasel|Firefox|Navigator|Uzbl-core|Netsurf.elf"] border none, focus, layout tabbed

Toggling between Tiling and Floating mode:


Window Positioning

With its ability to run in tiling or floating mode, i3 has the ability to set applications as a floating window as mentioned above. By default, i3wm positions floating windows as centered. You can add options to the class assignment as follows:

for_window [class="Mousepad"] floating enable move right 332px,move up 213px

This will open up mousepad in the upper right portion of the screen.

For a terminal emulator such as urxvt, the above syntax will work, or it can be achieved by adding options to the terminal keybinding:

bindsym $MOD+Return exec urxvt -g 78x18+700+33

with x=700 and y=33, opening urxvt in the upper right portion of the screen.

Status Bar Configurations

If you want to move the status bar to the top of the screen. You can also specify if you want the status bar to autohide. In the same block you can specify to hide the tray as well.
Note, if you hide the dock, the MOD key is used to show it.

bar {
#	status_command i3status
	status_command conky -c /path/to/conky
	tray_output none
	position top
	mode dock        # (Default Behavior) i3bar is shown at all times
#	mode hide        # i3bar is only shown when you press the Modifier key
#	mode invisible   # For completely hiding the i3bar

You can bind all the i3bar modes to a keybind. For example I have this in my i3's config file:

# i3bar Modes

bindsym $mod+b bar mode invisible
bindsym $mod+n bar mode dock
#bindsym $mod+b bar mode toggle

Want to arrange Workspaces serially without the numbers being visible on the Workspace names ? Simply add the following to your i3 config (in the bar settings):

bar {
	mode dock
        strip_workspace_numbers yes # Don't show the numbers on Workspace names

Services - Autostart

Configuring i3 to autostart such items as nm-applet, or to set your wallpaper, or autostart the dropbox daemon. There are a couple options to use here. I'll go over both.

Option #1: Within the .i3 config file, at the end of the file, past the last curly brace, add the following. This is a sample of what could be added.

exec --no-startup-id i3-msg 'workspace 1; exec urxvt;'
exec ~/.dropbox-dist/dropboxd
#exec nitrogen --restore
exec xscreensaver -no-splash
exec --no-startup-id xfce4-volumed
exec feh --bg-scale /home/<user>/images/wallpapers/xyz.png

Option #2: create a script in /usr/local/bin/i3.sh:

#! /bin/bash
nm-applet &
nitrogen --restore &
(sleep 20s && ~/.dropbox-dist/dropboxd) &
sleep .2

Make it executable:

sudo chmod +x /usr/local/bin/i3.sh

Then in /usr/share/xsessions change the following lines in i3.desktop to:


See also