Tutorial: How to use the KWin Window Manager with Xfce
Article posted 06/02/2014
Is Xfce's default window manager (Xfwm4) getting you down? Not enough effects for your fancy? Or perhaps it's giving you that infamous screen tearing with the lack of OpenGL VSync? There's plenty of alternatives out there, but had you considered KDE's compositing window manager, KWin? It can be done!
That's right, KWin can actually be used with other desktop environments besides KDE and despite what perceptions you may have about KDE's "bloat" or resource usage, is actually a very good performer despite sounding like this will be some sort of Frankenstein desktop. Xfce + KWin is currently the setup I personally use every day and this combination has been somewhat of a trend lately, because the combination does seem to work very well. So let's see what to do!
First things first, you need to actually get the KWin Window Manager.
Note: If you have some aversion to having KDE libraries (etc) on your system, you might as well stop now.
To actually get KWin, it will depend on your Linux distribution somewhat, but you will most likely have to install a package called "kde-workspace", which contains some base KDE libraries and programs, including KWin itself.
If you're on Arch Linux, like me, there is an option in the AUR called "kwin-standalone-git", which is an even more stripped down package. However as I test KDE from time to time, I actually have most of KDE installed on my system including, obviously, kde-workspace.
Preparing the Frankenstein
Once you have acquired KWin, you can test it with a simple command (either run it in a terminal or with the Run Command dialog which is typically Alt-F2):
You'll most likely get a second or two of flicker, but if all works well, you should see your original Xfce window borders get replaced with the standard KDE Oxygen style and that distinctive light blue shadow under your windows. Yay, you have KWin running in all it's glory!
Now, this is all well and good, but you may find it annoying to run that command everytime you reboot your computer. So, next, we'll look at two options to autostart KWin when you boot into Xfce.
Option 1: Xfce Application Autostart (the easy way)
This is also probably the safest and recommended way, because while it does mean you will see a slight flicker as KWin replaces Xfwm4 when you log in (as opposed to Xfwm4 never starting in the first place), all you'll have to do to go back to the original Xfwm4 setup is uncheck a box and perhaps log out and log back in again, instead of editing a text file as you will see in the second alternative option and potentially having no window borders at all (more on that later).
So, first, go ahead and open up Xfce Settings Manager. Then go to "Session and Startup".
Then click on the Application Autostart tab. Then click on the "Add" (plus sign) button to add a new program to the autostart list.
In the dialog that comes up, you'll have these options to fill in:
- Name: You can put any name here. Eg. Kwin Autostart
- Description: Again, anything you like.
- Command: Okay, this is important. You have to put the command we used earlier: "kwin --replace".
Then click the OK button once you have completed that task. There - KWin will now be autostarted when you log in to Xfce! Too easy.
See the screenshot for an example.
If you wish to reverse this, all you have to do is uncheck the KWin option you added in the Application Autostart or delete it, if you so wish.
Option 2: Editing xfce4-session.xml (advanced method, may not work!!!)
Warning: This method is only recommended for the advanced user and truthfully may not work anyway. It seems to work for some and yet not others (I'm sadly in the latter camp).
Nevertheless, if you wish to try it then follow on with these instructions. Otherwise, skip this section and move onto "Customizing KWin".
Alright, for this method we are going to edit an XML file that Xfce uses at startup which stores a bunch of default commands and options.
Begin by opening the file, located at "/etc/xdg/xfce4/xfconf/xfce-perchannel-xml/xfce4-session.xml", in your favourite text editor with root privileges. I'd also recommend to backup the file to be safe.
sudo nano /etc/xdg/xfce4/xfconf/xfce-perchannel-xml/xfce4-session.xml
Once you have the file open, find a line that looks like this:
<value type="string" value="xfwm4"/>
Change the "xfwm4" part (and only that part) so it's more like this:
<value type="string" value="kwin"/>
Save the file and that's it. All that would be left would be to log out and log back in again.
The benefit of this method would be that Xfwm4 would never start when you log in to Xfce, making the starting of KWin seem more seamless. On the flip side, if this method fails to start KWin (which can very likely happen), Xfwm4 won't be started either. So... you'll have no window borders at all, which isn't pleasant, although can be reversed if you manage to navigate back to that file and change it back to how it was or restore a saved copy.
So please keep that in mind.
Alright, so you have a working and autostarting KWin!
Now if you want to tweak the good stuff, like effects or even the myriad of other options that KWin gives you, you could find and open the KDE System Settings... or, even easier (and more suited to a non-KDE environment), right click on the window border of any opened application and navigate in the popup context menu to "More Actions" -> "Window Manager Settings...". See the screenshot below for an example.
Ta-daa. Here, you can enable/disable cool effects as well as many other configuration options, like changing the window decorations or configuring screen edges.
Also, compositing/desktop effects can be toggled on and off instantly using the "Shift-Alt-F12" keyboard combination. This is handy if, for example, you are about to play a video game that doesn't play nicely with compositing and 3D effects...
So now you should have your existing Xfce desktop, but with the power and extra features of the KWin Window Manager.
I'll end this article showing off with the obligatory "desktop 3D cube" screenshot, from my Xfce + KWin desktop.
UPDATE 09/05/2014: For anyone who may have an issue with KWin being autostarted in Xfce, one of our readers "Goe Gol" left a comment detailing the fix:
"Since this morning however XFCE no longer starts. I get the desktop background but no panels. When I remove kwin from autostart, it works fine. I can then start it manually from a terminal with kwin --replace but via autostart it won't work anymore. Any ideas why this might be?
Solved my own problem. I enabled and disabled automatically save session, but it still remembered a saved session. I had to clear all saved sessions."