Using i3 with KDE Plasma

💣 A recent upgrade broke this setup for me.

If this is your first time seeing this guide, carry on—I’ve adjusted the instructions so that everything works again.

But if you’ve previously followed this guide and are now having trouble logging in, check out the addendum for the fix.

Have you seen /r/unixporn? It’s a techie neckbeard’s wet dream in there, and I honestly can’t get enough. The subreddit is dedicated to customizing the GUI on Linux/Mac/etc.1 and posting screenshots of the results:

by /u/theblahblahmachine

by /u/GoldUtop

by /u/addy-fe

To achieve this effect, you have to tinker with all the little parts that make up the desktop environment: the window manager, the system panel, the lock screen, the display manager, and on and on and on. At this point, anyone who’s struggled with Linux before will be anticipating the avalanche of research required to grasp how the system is composed and where to even begin when all you want is to just make one simple, off-the-menu modification.

Well, I’ve done just enough research to know I don’t want to do any more, but I did manage to make my one simple, off-the-menu modification, so here it is.

Objective

Use a tiling window manager in KDE Plasma.

What is a tiling window manager?

A window manager governs how application windows are displayed on your screen. You know how you can drag a window by the title bar, maximize it, minimize it, restore it, pull up another window on top of it, and all that? A tiling window manager says “No thank you!” to all that. “Let’s make it impossible for your friends to ever use your computer without you dictating a bunch of obscure keyboard commands to them; I bet that’ll impress ’em!”

Tiling window managers are very popular on /r/unixporn. Probably the most popular one out there is i3. We’re using a variant called i3-gaps because it’s prettier.

What is KDE Plasma?

KDE Plasma is one of the two most popular desktop environments for Linux and friends (the other is Gnome). It’s clean and well-designed, with great defaults for people coming to Linux from Windows or macOS. I chose it on a whim and ended up liking it so much, I wish it were the default on major distros.

KDE comes with a window manager called KWin. This is the component we’re replacing with i3. Everything else remains the same, including:

  • system panel (for WiFi/Bluetooth/volume settings, calendar, etc.)
  • system settings app (for system-wide keyboard shortcuts, display settings, etc.)
  • notifications
  • login screen (a.k.a. display manager)
  • lock screen
  • omnisearch

Procedure

Assumptions

  1. You’re on Debian.
  2. You’re already using KDE Plasma.
    (Confirm with dpkg -s plasma-workspace.)
  3. Your default display manager (login screen) is sddm.
    (Confirm with cat /etc/X11/default-display-manager.)

If your situation is different, adjust accordingly.

Step 1: Installation

$ git clone https://github.com/maestrogerardo/i3-gaps-deb
$ cd i3-gaps-deb
$ ./i3-gaps-deb

(Non-Debian users: hopefully, you’re on one of i3-gaps’ officially supported distros.)

Step 2: i3 configuration for Plasma

Add the following lines to ~/.config/i3/config:

# Don’t treat Plasma pop-ups as full-sized windows
for_window [class="plasmashell"] floating enable

# Don’t spawn an empty window for the Plasma Desktop
for_window [title="Desktop — Plasma"] kill, floating enable, border none

# Don’t let notifications and non-interactive pop-up windows steal focus
no_focus [class="plasmashell" window_type="notification"]
no_focus [class="plasmashell" window_type="on_screen_display"]

Step 3: Login screen configuration

⚠️ Caution: Earlier versions of KDE use the executable startkde, not startplasma-x11.

Now, all you need to do is add an option in the display manager (login screen) to startplasma-x11 with a modified $KDEWM environment variable:

# Create a plasma + i3 launcher script
$ echo -e '#!/bin/sh\n\nKDEWM=/usr/bin/i3 startplasma-x11' > /usr/local/bin/startplasma-x11-i3
$ sudo chown root.staff /usr/local/bin/startplasma-x11-i3
$ sudo chmod 755 /usr/local/bin/startplasma-x11-i3

# Create a custom desktop sessions directory
$ sudo cp -a /usr/share/xsessions /usr/local/share/xsessions

# Create a new desktop session file for plasma + i3
$ cp /usr/local/share/xsessions/plasma.desktop /usr/local/share/xsessions/plasma-i3.desktop
$ sudo sed -i 's|/usr/bin/startplasma-x11|/usr/local/bin/startplasma-x11-i3|' /usr/local/share/xsessions/plasma-i3.desktop
$ sudo sed -i '/Name.*=/ s/$/-i3/' /usr/local/share/xsessions/plasma-i3.desktop

# Configure sddm (the login screen) to use our new desktop sessions directory
$ echo -e '\n\n[X11]\nSessionDir=/usr/local/share/xsessions' | sudo tee -a /etc/sddm.conf

Log out, and you should now be able to select “Plasma-i3” as your desktop session in the login screen. Then, head over to the official i3 user’s guide to learn the ropes.

Addendum

As mentioned above, a KDE update that was rolled out to Debian recently left me unable to log in. The reason is that this new version of KDE changed the launcher command from startkde to startplasma-x11.

If you’re in the same boat, use Ctrl-Alt-F1 to log into a tty, and then do the following:

# In your plasma + i3 launcher script, change `startkde` to `startplasma-x11`.
$ sudo sed -i 's/startkde/startplasma-x11/' /usr/local/bin/startkde-i3

# Rename your launcher script to match
$ sudo mv /usr/local/bin/start{kde,plasma-x11}-i3

# Edit your custom desktop session file to use the new launcher script
$ sudo sed -i 's/startkde/startplasma-x11/' /usr/local/share/xsessions/plasma-i3.desktop

# Copy the vanilla Plasma desktop session file to your custom desktop sessions directory
# (just for good measure)
$ sudo cp -a /usr/share/xsessions/plasma.desktop /usr/local/share/xsessions/

Log out, use Alt-F7 to switch back to the graphical login screen, and you should be good to go!


  1. The community affectionately refers to this practice as ricing in a nod to the pejorative rice rocket in automotive culture (because it’s souped up, but only on the outside—get it?).