Thursday, 14 May 2015

i3 with Gnome underpinnings on Debian 8.0 (Jessie)

I've been running i3 as my window manager on Debian 7.0 (Wheezy) for a while. I meant to get round to writing a blog posting about how I set it up to work somewhat sanely with Gnome, GDM and gnome-session but never got round to it. The upgrade to Jessie brought some new problems as Gnome rolls more core functionality into gnome-shell. So, here's what I've done to create a Gnome+i3 session in GDM.

Create /usr/share/xsessions/i3-gnome.desktop containing:

[Desktop Entry]
Name=i3 Gnome
Comment=improved dynamic tiling window manager with Gnome
Create /usr/local/bin/gnome-session-i3 containing:
exec gnome-session --session=i3-gnome --debug "$@"
and ensure it is executable with:
chmod +x /usr/local/bin/gnome-session-i3
Create /usr/share/gnome-session/sessions/i3-gnome.session containing:
[GNOME Session]
Name=i3 Gnome session
Create /usr/share/applications/i3-gnome.desktop containing:
[Desktop Entry]
Comment=improved dynamic tiling window manager with Gnome underpinnings
X-GNOME-WMName=i3 Gnome
Create /usr/local/bin/i3-gnome containing:
if [ -n "$DESKTOP_AUTOSTART_ID" ]; then
   dbus-send --session --print-reply --dest=org.gnome.SessionManager "/org/gnome/SessionManager" org.gnome.SessionManager.RegisterClient "string:i3-gnome" "string:$DESKTOP_AUTOSTART_ID"
exec i3
and ensure it is executable with:
chmod +x /usr/local/bin/i3-gnome
That should give you enough to have an "i3 Gnome" entry in your GDM menu. But, if you launch it you'll find there are a few problems that need solving: To make the mouse cursor appear (credit):
dconf write /org/gnome/settings-daemon/plugins/cursor/active false
In order to log out you need to tell the session manager to finish the session. I do that with a script that provides the behaviour that gnome-session-quit used to in earlier Gnome versions:

# gnome-session-quit talks DBus to gnome-session which now tries to
# talk to gnome-shell in order to bring up a dialog box to confirm
# whether we should quit. Since we're not running gnome-shell this
# doesn't work. So, let's bring up our own box and then tell
# gnome-session to quit without prompting.

case "$1" in
 text="Do you wish to log out?"
 text="Do you wish to power off?"
 text="Do you wish to reboot?"
 echo "Unknown option: $1" 1>&2
 exit 1

if zenity --question --text="${text}"; then
    exec gnome-session-quit --no-prompt "$@"

and then bind it in ~/.i3/config:

bindsym $mod+Shift+E exec /home/mac/bin/scripts/gnome-session-quit-ask --logout
In order to lock the session using gnome-screensaver you can add a binding like this to your .i3/config:
bindsym Ctrl+Mod1+L exec --no-startup-id dbus-send --print-reply --session --dest=org.gnome.ScreenSaver /org/gnome/ScreenSaver org.gnome.ScreenSaver.Lock
Fast user switching works with this but when switching back to i3 you'll unfortunately need to enter your password twice. I use udisks-glue to automatically mount storage devices.