Modern desktop environments like GNOME and KDE involving a lot of mousing around and I much prefer using the keyboard where I can. This is why I switched to the Ion tiling window manager back when I interned at Net Integration Technologies and kept using it until I noticed it had been removed from Debian.

After experimenting with awesome for 2 years and briefly considering xmonad , I finally found a replacement I like in i3. Here is how I customized it and made it play nice with the GNOME and KDE applications I use every day.

Startup script

As soon as I log into my desktop, my startup script starts a few programs, including:

Because of a bug in gnome-settings-daemon which makes the mouse cursor disappear as soon as gnome-settings-daemon is started, I had to run the following to disable the offending gnome-settings-daemon plugin:

dconf write /org/gnome/settings-daemon/plugins/cursor/active false

Screensaver

In addition, gnome-screensaver didn't automatically lock my screen, so I installed xautolock and added it to my startup script:

xautolock -time 30 -locker "gnome-screensaver-command --lock" &

to lock the screen using gnome-screensaver after 30 minutes of inactivity.

I can also trigger it manually using the following shortcut defined in my ~/.i3/config:

bindsym Ctrl+Mod1+l exec xautolock -locknow

Keyboard shortcuts

While keyboard shortcuts can be configured in GNOME, they don't work within i3, so I added a few more bindings to my ~/.i3/config:

# volume control
bindsym XF86AudioLowerVolume exec /usr/bin/pactl set-sink-volume @DEFAULT_SINK@ -- '-5%'
bindsym XF86AudioRaiseVolume exec /usr/bin/pactl set-sink-volume @DEFAULT_SINK@ -- '+5%'

# brightness control
bindsym XF86MonBrightnessDown exec xbacklight -steps 1 -time 0 -dec 5
bindsym XF86MonBrightnessUp exec xbacklight -steps 1 -time 0 -inc 5
bindsym XF86AudioMute exec /usr/bin/pactl set-sink-mute @DEFAULT_SINK@ toggle

# show battery stats
bindsym XF86Battery exec gnome-power-statistics

to make volume control, screen brightness and battery status buttons work as expected on my laptop.

These bindings require the following packages:

Keyboard layout switcher

Another thing that used to work with GNOME and had to re-create in i3 is the ability to quickly toggle between two keyboard layouts using the keyboard.

To make it work, I wrote a simple shell script and assigned a keyboard shortcut to it in ~/.i3/config:

bindsym $mod+u exec /home/francois/bin/toggle-xkbmap

Suspend script

Since I run lots of things in the background, I have set my laptop to avoid suspending when the lid is closed by putting the following in /etc/systemd/login.conf:

HandleLidSwitch=lock

Instead, when I want to suspend to ram, I use the following keyboard shortcut:

bindsym Ctrl+Mod1+s exec /home/francois/bin/s2ram

which executes a custom suspend script to clear the clipboards (using xsel), flush writes to disk and lock the screen before going to sleep.

To avoid having to type my sudo password every time pm-suspend is invoked, I added the following line to /etc/sudoers:

francois  ALL=(ALL)  NOPASSWD:  /usr/sbin/pm-suspend

Window and workspace placement hacks

While tiling window managers promise to manage windows for you so that you can focus on more important things, you will most likely want to customize window placement to fit your needs better.

Working around misbehaving applications

A few applications make too many assumptions about window placement and are just plain broken in tiling mode. Here's how to automatically switch them to floating mode:

for_window [class="VidyoDesktop"] floating enable

You can get the Xorg class of the offending application by running this command:

xprop | grep WM_CLASS

before clicking on the window.

Keeping IM windows on the first workspace

I run Pidgin on my first workspace and I have the following rule to keep any new window that pops up (e.g. in response to a new incoming message) on the same workspace:

assign [class="Pidgin"] 1

Automatically moving workspaces when docking

Here's a neat configuration blurb which automatically moves my workspaces (and their contents) from the laptop screen (eDP1) to the external monitor (DP2) when I dock my laptop:

# bind workspaces to the right monitors
workspace 1 output DP2
workspace 2 output DP2
workspace 3 output DP2
workspace 4 output DP2
workspace 5 output DP2
workspace 6 output eDP1

You can get these output names by running:

xrandr --display :0 | grep " connected"

Finally, because X sometimes fail to detect my external monitor when docking/undocking, I also wrote a script to set the displays properly and bound it to the appropriate key on my laptop:

bindsym XF86Display exec /home/francois/bin/external-monitor
git-annex

Hi Micha,

quite an off-topic. How do you use git-annex? Do you have a central server to distribute changes around your machines? How do you set up git-annex? What do you do about /etc/? What files are important for you?

foobar

Comment by foobar
Random comments

Hi!

gnome-screensaver does not work as expected because idleness is detected by gnome-session. You could run i3 through gnome-session (you need an hand-crafted desktop file).

For switching between keyboard bindings, this is something that X can handle itself. For example, look at setxkbmap us,fr '' grp:rctrl_rshift_toggle will switch between US and FR layouts.

I had tried to keep those gnome stuff in the past, but the interaction between all those parts is under-documented and can change quite often. I would stay far from gnome-settings-daemon which does a lot of things. You could look at xsettingsd which will do exactly what you describe without hidden features.

Comment by Vincent Bernat
Screensaver

Have you considered trying if xscreensaver works without the hacks needed for gnome-screensaver?

Thanks for the tips, I am going to use (a variant of) your suspend script.

Comment by Adam
comment 4
The ion3 has a fork Notion (http://notion.sourceforge.net/) which not only is actively mantained (and has a fair progress since forking, like new kludges and xrandr/xinerama-no-restart support) but also is properly licensed and is a part of Debian (at least testing, which I'm on). I use it on a daily basis. There's hardly an need for ion-addicts to reinvent the wheel...
Comment by Wojtek
Re: Screensaver
xscreensaver might work. I admit I didn't look too deeply into it once I found a way to make gnome-screensaver work because that one looks more "modern" :)
Comment by fmarier
Re: git-annex

I should probably blog about my use of git-annex at some point :)

Setting it up is not hard if you use the assistant (git annex webapp). I use my own ssh server as the intermediate transfer server and I set up an XMPP server on there too.

For /etc however, I use the etckeeper package instead.

Comment by fmarier
Re: Random comments

Thanks for your comments Vincent, it's good to hear from someone who seems to know what's going on :)

I've tried your setxkbmap line and the toggle doesn't work. I suspect these issues on jessie/sid are the same as what these other users have found on Ubuntu 14.04:

It would also explain why the toggle doesn't work in the GNOME settings (since it's probably just calling setxkbmap for us).

Comment by fmarier
Alternatives

Seems like you've solved a lot of the same things I have in different ways after switching to i3 :)

My i3 config is up on github - I use this along with a fairly trivial ~/.xsession to set up my ~/.i3/config and start i3. I also have some python scripts (i3companion) here to handle some of the more advanced things:

https://github.com/DarkStarSword/junk/tree/master/config/home/.i3

Some differences between our setups:

gnome-settings-daemon - Sounds like you need this for a different reason to me. I used to run this as a quick hack to get backlight + keyboard backlight controls to work without needing root, but it always caused issues and was hard to configure without Gnome, so I now talk to the appropriate daemons over dbus/xcb to do this myself (upower for keyboard backlight, X11 RANDR for LCD backlight). More on this later.

gnome-keyring-daemon - What's wrong with ssh-add (part of ssh-agent)?

gnome-screensaver - I use i3lock with xautolock. I like the fact that i3lock actually saves power by turning off the screen and keeping it off until you start to unlock it (with the --dpms flag). Back when I used wmii I did basically the same thing as i3lock with xtrlock and a python script to keep the screen off.

nm-applet - I use wicd-curses, which is bound to mod+n for quick access (N for networks)

volume/brightness key bindings - I use my own python script (i3companion) for these instead of execing a binary each time, which significantly reduces the latency (especially on the first press after Linux has discarded the binary from the page cache). My script uses python-xpyb and python-xlib to grab the keybindings directly, so this does not strictly go through i3 any more.

In addition to the XF86 keys, I also bind other common keys for these so I don't have to think about the different locations these keys are on every brand's keyboard (I typically switch between machines several times a day). I use mod+up/down for the LCD backlight, mod+shift+up/down for the keyboard backlight, mod+square brackets for volume up/down, mod+backslash for mute and mod+shift+backslash for pavucontrol (for when I need to do something more advanced, such as rerouting an audio stream to my bluetooth headphones).

Suspend script - On one laptop I just use the laptop's Fn+F4 to do this through the standard acpi scripts, on another laptop I catch the power button (it's a Mac Air, so the power button is in the stupidest place they could possibly have conceived and not catching it is a recipe for disaster, because OF COURSE you would put the power button as a normal key just above backspace, I mean where else would you put a dangerous key like that?) and display a menu asking what to do (suspend, hibernate, shut down, reboot, log out, switch user) and invoke a suitable dbus interface to do the correct action - all without requiring root or sudo. To lock the screen on suspend I bind XF86ScreenSaver, XF86Sleep and XF86Suspend to run i3lock.

I've got a few other neat tricks as well in my config - one of these days I should really blog about it, but the meantime, feel free to check it out on github :)

Comment by Ian
Want to make life a little easier?

This sets most of that for you, the rest should be able to be done with xdg-autostart entries: https://github.com/yrro/gnome-i3

Also, you may prefer light-locker to gnome-screensaver.

Comment by Cameron
Toggle
It works for me in Sid. I would speculate this is the kind of things that gnome-settings-deamon would interfere with but since it doesn't work either with Gnome itself, well, I don't know. :)
Comment by Vincent Bernat