Kde support

My first pull request of two months ago (mis-spelled as "kdm-support") was a total mess, so please, ignore that one. 
In this one I collected all the changes I had to do to make for the KDE desktop while not changing the functionality for the gnome/mate desktop.