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!

5 comments:

  1. Hi, Prashanth,

    Just wanted to say that, coincidentally, I've also been toying with these things past week.

    Normally a KDE user, I tried to give Xfce a spin on my better machines. Of the two main desktops running Mageia KDE, one is able to use Compiz perfectly and on the other it just doesn't work. I seem to recall a problem with a gtkrc file, but I'm not really sure; maybe it has something to do with gconf (there's a lot of messages when I try compiz --replace), because I don't use Gnome.

    Anyway, an easy trick I found is to install and use the "Compiz Fusion Icon" which becomes an icon in Xfce's "Notification Area". I suppose Mate would work likewise.
    Right-clicking on that icon it's easy to switch among some WM options -- ate least in Mageia... toggling between Kwin or Xfwm4 becomes easy.

    Now, what I'd like to say is about a point on which I'd rather have XFwm4 than KDE. It's about automatic tiling, that action of dragging a window to the border and having the WM change its size. Normal Windows-like working is to maximize when dragged to the top of the screen and tile it to half-screen when moving sideways.

    Very well. Kde does better and has quarter-screen tiling when on drags the window to each one of the four corners (Kwin does that, as I understood). Even better, it allows one to drag the window to the next workspace after a delay. This is very convenient.
    Xfwm4 does 2 things: one good, one bad.

    The good one is tiling half-screen to the top (the window becomes half-screen in height and full-width). The same happens to the bottom of the screen. I've wishing that Kwin did that, but it maximises the window instead. A workaround would be using quarter-screen tiling and then right-clicking on the titlebar's maximise button. These things are important e.g. when comparing spreadsheets. And I can live with maximising windows by double-clicking in their titlebar.

    Xfwm4 doesn't do quarter-screen tiling but I'm betting this is rather an infrequent need.
    The bad thing is that Xfwm4 does not allow dragging windows to the next workspace if auto-tiling is activated. For the moment, I'm using the "workspace switcher"/pager to move windows among workspaces. It's not very easy because it's small. I'm using the linear workspace configuration instead of the traditional 2x2 matrix, but the idea of having a "B I G" pager has ocurred to me -- inside a second auto-hiding panel. Let us see.

    Good article as always, btw!

    Neko Nata


    PS: Mate was an option, too, but I found difficult to find some settings -- specially single-click (maybe it's a Mageia omission, I don't know). I found it in dconf-editor, but there were some warnings about how things would never work again in my life, so I got back to Xfce. 8-P

    ReplyDelete
    Replies
    1. Just want to add that:

      1) after that pager idea (btw the second auto-hiding panel worked), I tried and saw Kwin "show all windows" function (usually Ctrl+F8) can be used to move windows, just as well and

      2) there is an equivalent third-party utility for Xfce, it seems, called Skippy-XD. Must try some day.

      Also, Xfce is a little "whimsical"... if a maximised window is dragged off-border, it restores to normal size, but when dragged to top it fully maximises. To get half-screen zoom, it seems necessary to release the window for a brief moment.

      Finally, I realize you're after all the nifty desktop effects Kwin has; I agree it's beautiful, but I'm just trying the speed of things on my 2GB RAM machines. For the 64-bit versions, it seems Xfce really makes everything go faster.

      Surely, given more RAM, KDE would probably would be as fast... and more featureful.

      Neko Nata

      Delete
    2. @Anonymous: It's great that Xfwm4 has worked so well for you. There are a few points of which I'd like you to be aware. The first is that in Ubuntu-based distributions, the Compiz Fusion Icon no longer works, even though it is installable, so it is no longer a viable way of switching between Compiz and another WM; in any case, for any use outside of Unity, Compiz is essentially broken. Of course, many other distributions have chosen to freeze Compiz and its related packages at version 0.8.x, so these aren't issues for those distributions. Also, regarding window tiling, I actually find side-by-side tiling or quarter tiling to be more useful than top-to-bottom tiling; again these are all likely personal preferences more than anything else. Finally, indeed I am after the shininess of KWin to a degree, and I do say in the article that for a laptop where I would care about hardware temperatures and things like that, I would use Xfce or MATE with a simple WM extension like Devilspie. That said, KWin gives you an unbelievable amount of control over window management, and only Compiz is close to comparable among traditional WMs; I would encourage you to look more into KWin, especially as there are ways to install KWin and use it well even on machines with limited resources. Thanks for the comment!

      Delete
    3. Thanks for the explanation, I've read your article but only got the reference about Compiz no longer being as active as it once was. Indeed, as you say, I'm also having problems with Compiz: it works on my desktop but not on my laptop/notebook. Your suspects might be on spot, I'll check later the version number. But I'm OK with "wm --replace &". Alas, things started months ago when I tried Ubuntu (to see what happened after some 3 years of not using it) and noticed it was more nimble than KDE. Upon trying it instead of Kwin, things seemed a tad more agile.

      I have used Kwin extensively in the last years. Actually, I "endured" KDE 4.0 8-P and developed a lot of specialized tweaks to make it work according to my distorted view of reality (for instance, I like single-click and windows without "raise on click").

      Regarding making Kwin more lightweight, I have a problem similar to yours: I like how "shiny" one can configure it (though it's also a matter of taste). I like compositing, too, and already ditched Nepomuk/Akonadi. But I will look further into it.

      It's interesting to separate, by running another WM, what comes from Kwin and what pertains to KDE itself. For instance, Ctrl+F12 (which I remapped to Alt+Space) still works while Ctrl+F8 (I use Win+Space) went away with Kwin.

      Oh, well...

      Thanks for the well-thought answer.

      Delete
    4. @Anonymous: Thanks for the comment!

      Delete