2014-08-14

How-To: Use KWin in MATE

KWin in MATE
If you've read any of my reviews over the last several months, you'll know that I've bemoaned the effective death of Compiz. (I guess it's more like in a vegetative state: technically it still exists, but it doesn't actually work.) Since then, I've accepted the fact that for my next distribution upgrade, unless I come to the point of being comfortable with KDE and all of its applications, I will likely stick with MATE or Xfce in conjunction with Devilspie or a similar program for improved window management. That said, out of curiosity, I wanted to see if it would be possible to use KWin with MATE or Xfce, because KWin is even more powerful than Compiz in actual window management, and it comes with the same level of eye candy. Plus, KWin, being an integral part of KDE, is likely to be maintained and developed well for the foreseeable future. Indeed, I found several tutorials explaining how to combine Xfce with KWin. However, there were none for MATE, so that's what this article is. This was tested on a Linux Mint 17 "Qiana" MATE live USB made with UnetBootin. Follow the jump to see how it's done (in this distribution — other distributions may name their packages differently).

The first step is to open the Synaptic Package Manager and install the "kde-window-manager", "system-settings", and "dconf-tools" packages. These KDE packages do add a lot of libraries, along with the "Oxygen" icon and window themes, but I'm OK with that because even in a MATE or Xfce installation, I would also install Okular and KolourPaint anyway. Plus, no other applications are installed. The "dconf-tools" package is for a little later.

The second step is to start KWin by opening a terminal and issuing the command "kwin --replace &". Of course the "kwin" part starts KWin, the "--replace" part ensures that the instance of Marco (the WM for MATE) is cleanly replaced by KWin, and the ampersand sends the command to the background.

The third step is to search in the Linux Mint Menu for the KDE System Settings application and make whatever customizations are desired. The small warning I would give is that I found some of the options, such as "Virtual Desktops" (being way at the bottom), to be easier to miss. Plus, because KDE is not fully installed, some of the options you would expect to see are not present. That's fine, because there are usually equivalents in the configuration tools for MATE anyway. Another way to access some (but not all) of these KDE configuration settings is to right-click on a window titlebar and hover over "More Actions" followed by clicking on "Window Manager Settings".

The fourth step is to make KWin the default WM in two ways (both of which may be necessary). The first of these is to find the MATE startup applications tool and add KWin as a startup application. The command to be issued is "kwin --replace"; no ampersand is needed here because all the startup applications listed are sent to the background anyway. The second of these is to open DConf-Editor (which is why the "dconf-tools" package needed to be installed) and navigate to "org > mate > desktop > session > required-components". Here, the flag for "windowmanager" needs to be changed from "marco" to "kwin". This ensures that Marco is cleanly replaced by KWin as the default WM in MATE. These changes are effected by logging out and logging back in.

That's basically all it takes. There were some further changes I had to make. For example, pressing the PRTSC key on my keyboard no longer called the screenshot utility. I had to add that as a custom keyboard shortcut. Additionally, although I enabled automatic window tabbing, I didn't want windows like Caja to be automatically resized down to tabbed small dialog windows (e.g. the dialog window to connect to a remote server). I had to add a window rule against that, and thankfully KWin at least gives me the flexibility to do that — such is its power. Related to that, there are two small issues. One is that if I open two instances of normal Caja windows, they won't tab together; I can't force normal Caja windows to stay separate only from their dialog windows. The other is that for some reason, two terminal windows that are opened separately do not tab together automatically.

Otherwise, KWin in MATE works like a charm. It's super-stable (much more so than Compiz nowadays), doesn't make my laptop run hot or anything like that, and uses 430 MB of RAM at idle with all of my desired desktop effects turned on; the RAM usage is comparable to my current setup of Xfce with Compiz, which is good. Interestingly, I tried this two years ago (also on a live USB) just for fun, and that attempt crashed and burned, because while KWin was reasonably stable in KDE, it was nowhere near stable outside of it; it's nice to see things change so much for the better. Anyway, to reiterate, I probably wouldn't do this on a future installation on my laptop (current or future) out of consideration for battery life, hardware temperatures, and things like that; on a laptop, I would keep it light with MATE or Xfce with Devilspie. However, on a desktop, I would be more than willing to do this, getting the benefits of MATE along with a powerful compositing WM through KWin. Hooray for flexibility!