banner
Previous Page
PCLinuxOS Magazine
PCLinuxOS
Article List
Disclaimer
Next Page

Downsizing: Moving From KDE To Mate


by Peter Kelly (critter)

In last month's magazine I wrote about changing from KDE to the Mate desktop environment. This involved my efforts to apply some of the more useful features of KDE to Mate using a utility called xdotool. One of the features in KDE that I particularly liked was the ability to have an application open at a pre-determined location and of a particular size, maybe also on a particular workspace.

Mate is a desktop environment of which the window manager is only one element. It is possible to use a different, more powerful window manager than the default Marco, but the 'up-market' managers tend to be less economical on resources, which would defeat the object of my moving to Mate. Anyway, Marco is a good, lightweight window manager, with a very respectable heritage from Gnome's Metacity, around which Mate has been designed. Little Marco just needs a little help, is all.

I had achieved my goal of getting this particular feature to work by using xdotool. However, the results were less than satisfactory, briefly displaying the window before moving and resizing it to the desired parameters. I thought that there must be a better way to do this and so, once again, I turned to the internet.

What I was looking for was something that would work with the Marco window manager (Wikipedia tells me that marco is Spanish for frame, which I suppose makes sense for a window manager**). Whichever tool I used should also be available from the PCLinuxOS repositories.

**For those Mate users who may have wondered about the strange names used for some of the Mate applications:

When the Gnome desktop moved from version 2 to 3, many users, including Linus Torvalds, did not like the direction taken by the new system and started to look for alternatives. One of these disgruntled users, an Argentinian Arch user named Perberos, decided to take a different approach and forked Gnome 2 to a new desktop environment (DE) he named Mate, after the popular South American beverage.

The Mate utilities that he forked from Gnome had to be re-named and for this he chose to use names from his native Spanish. Wikipedia translates them thus:

Caja (box) -- File manager (from Nautilus)

Pluma (quill) -- Text editor (from Gedit)

Eye of MATE -- Image viewer (from Eye of GNOME)

Atril (lectern) -- Document viewer (from Evince)

Engrampa (staple) -- Archive manager (from File Roller)

Mate Terminal -- Terminal emulator (from GNOME Terminal)

Marco (frame) -- Window manager (from Metacity)

Mozo (waiter) -- Menu item editor (from Alacarte)


wmctrl

The first tool I looked at was wmctrl, which can be a useful utility. But, it steadfastly refused to recognize some applications, most notably LibreOffice and Firefox. Perhaps this is related to the fact that the version in the PCLinuxOS repositories is 1.07 and a visit to the applications website showed this to have been released in 2005. A version 1.08 was mentioned, but since this was also released in 2005, there is still ten years of window management development not addressed. This inability to recognize all windows rendered it unsuitable for the particular task at hand.


devilspie


The next little gem that I stumbled upon carries the unlikely name of devilspie. This is another tool that seems to be no longer maintained, 2007 as near as I can tell, so again quite old. There is a more recent fork from this named devilspie2, but that is not in the repositories and so that one is off the list. From the website of the developer, Ross Burton, comes this quote:

"A window-matching utility, inspired by Sawfish's "Matched Windows" option and the lack of the functionality in Metacity"

This looks more promising, despite its age.

Devilspie works by looking at the windows managed by the window manager, and if they match criteria listed in a pre-written rule, then the actions described in the rule are applied to that window. The rules are text files that end with the extension '.ds' and are stored in a folder in your home directory named '.devilspie' which you will have to create (don't forget the leading dot). The rules follow a format known as 's-expressions' developed for the lisp programming language, but that is nothing to be alarmed about. The format is quite straight forward.

Documentation is rather poor, but a good reference to the available functions, commands etc. can be found here http://www.foosel.org/linux/devilspie. This website also provides more links for information.

To force my pluma text editor to always open on the second virtual desktop, in the top-left corner of the screen and 700 pixels wide by 500 pixels high, I have to create a file containing a rule to apply to pluma windows with the following text:

(if
      (is (application_name) "Pluma")
      (begin
          (set_workspace 2)
          (geometry "700x500+0+0")
      )
)

The filename is unimportant, but must end in .ds, and must be saved to a directory in your home directory named .devilspie.

So

/home/me/.devilspie/pluma.ds

is how I saved my file. The file first looks for a window that has the name "Pluma" and if found it applies the two rules following the begin statement. Workspaces are numbered from one here, in contrast to xdotool which begins numbering from zero. This method works better than my previous attempt, but does still flash briefly on the screen before the rules are applied. So, for this use, the search goes on. But for now, I am content.

Looking a little deeper into the abilities of devilspie I can see several ways to utilize this tool. I use LibreOffice quite frequently, and when I launch the word processor, I like to have just the text across the window, no distracting side bars, but the height maximised to display as much of the text as possible. On the other hand, the spreadsheet is always maximised and on a separate virtual desktop. Here the Application Name is 'LibreOffice 4.4' for both applications (4.4 is the current version on my system). However, the window class though differs between applications, being 'libreoffice-writer' or 'libreoffice-calc' as appropriate. Knowing this I can now write a different set of rules for each application (See below for how to get this information).

writer.ds

(if
      (is (window_class) "libreoffice-writer")
      (begin
          (geometry "1100x800+290")
          (maximize_vertically)
      )
)



The window is first resized horizontally to the desired size and vertically to an arbitrary value. It is then maximized in the vertical direction only. The geometry statement needs a little explanation. The values I have shown are used because I use two monitors, side by side, with resolutions of 1680x1050 and 1920x1080 respectively which gives an effective resolution of 3600x1080. As I want the word processor to be 1100 pixels wide and placed centrally on the first monitor, I need an x value of (1680 -- 1100)/2 = 290.

If I was using only one monitor, then I could ignore the calculation, omit the +290 offset, and simply add a center statement, which would calculate the correct position for me. Using the center statement with multiple monitors is, at best, unpredictable.

The spreadsheet, being maximized in both directions, is more straight forward.

calc.ds

(if
      (is (window_class) "libreoffice-calc")
      (begin
          (set_workspace 2)
          (maximize)
      ) )


An easy way to get the information to write your rules is to open the relevant applications, and then run devilspie debug in a terminal. Alternatively, you can put a file named debug.ds into the .devilspie folder containing just the single word debug. Rename the file to just debug when you no longer need the information. With this in place, issuing the command

devilspie debug *nbsp; *nbsp; Press Control + c to regain control.

Will print out the following information for each window:

Window Title, Application Name, Class and Geometry. The first three are matched by the strings window_name, application_name and window_class respectively.

When trying to match windows you have quite a lot of flexibility. Instead of using the test is

( is string_a string_b )

which is a test of equality as used in the above examples, you can use contains

( contains string_a string_b )

which looks for string_b within string_a (string_b is a substring of string_a).

Alternatively there is the test matches

( matches string_a pattern )

Where pattern is a regular expression. This greatly increases the flexibility of the search, and allows groups of windows to be matched. It is also possible to combine multiple tests using the so called boolean operators: and, or & not. The way to use these is quite simple, but may not be immediately obvious. The general format looks like this.



Just make sure that the parentheses are correctly closed out, and use indentation for readability. The link provided earlier will give you more information and describes the following actions that can be performed by devilspie:

debug, print, println, str, hex, geometry, fullscreen, focus, center, maximize, maximize_vertically, maximize_horizontally, unmaximize, minimize, unminimize, shade, unshade, close, pin, unpin, stick, unstick, set_workspace, set_viewport, skip_pager, skip_tasklist, above, below, undecorate, wintype, opacity, spawn_sync and spawn_async.

This is quite a comprehensive list that should enable me to fill in more of the gaps left by my move from KDE.


The dconf editor



Also in last month's article I briefly mentioned the dconf editor. This tool is not specific to Mate, and is used by other desktops, such as Xfce. It is a graphical front end used to access and adjust some of the lower level system settings. Unlike most Linux configuration settings, these are not stored in a simple text file intended to be edited with a text editor. Instead, they are stored in a database as key -- value pairs, and the dconf editor enables you to more easily change these values. The command line tool for doing this is gsettings. The command line tool is not very easy to use, but the graphical editor is most welcome, albeit being a little quirky.

As these settings are critical to how your desktop appears and behaves, it would be prudent to make a backup of the current settings before you begin to change things that you later regret. The file to back up is ~/.config/dconf/user.



There is no menu as such where you usually find items like open and save, but if you click on Dconf Editor in the top-left, you will be presented with a three item drop down list containing Find, About and Quit options.



Selecting the "Find" option opens a small text entry box bottom-left where you can search for an item, which it may or may not decide to find for you. Alternatively, you can navigate through the tree on the left expanding sub-sections as required by clicking on the little triangles.

I entered the word button in to the find box and got lucky. It found what I was looking for fairly quickly. These buttons are the ones incorporated in the window title bar, where you can, for example, maximize or close the window. The dconf editor gives some helpful information about what the values for this key may be, the effect this will have and what the default value is. This button-layout key appears in several places, but the one that worked for me using Mate was under marco > general > button-layout.



I like to have the close button separated slightly from the minimize and maximize buttons to avoid accidental closures. To incorporate this feature I have inserted the value 'spacer' in the comma separated list. You can see the effect of this in the image above. You may have to log out or even reboot to see the effects of your changes.

If your desktop environment uses the dconf editor, then it is worth taking a look at. There are many settings here that are difficult or almost impossible to adjust in any other way, and there are some that you almost certainly didn't know about. While I was exploring the org>mate>marco sections I discovered several keyboard shortcuts had been enabled that I was not aware of, and many more ready to be assigned for those who may find them useful.

One more thing that I missed from KDE was the ability to open man pages in konqueror via a kioslave. This just means that I got a much more civilized presentation of the man pages content which, in its usual terminal style output, is pretty dire.

Mate has a help file browser called yelp which, according to the documentation, can also be used to display man and info files. Unfortunately, this feature does not seem to be available in the current PCLinuxOS Mate installation.

To work around this, I called on a little bash function I discovered way back when and created an alias to it in my ~/.bashrc file. This will also accept section numbers as in man 8 lsblk.

This is the function as I implemented it in my ~/.bashrc file:

# found this on reddit a while back
# Posted by sledgespread - thanks sledgespread
pdfman()
{
    TMPFILE=$(mktemp atril-$USER.XXXXXXX --tmpdir)
    man -t "$@" | ps2pdf - "$TMPFILE"
    atril "$TMPFILE"
    bash -c "sleep 2; rm $TMPFILE" &
}

And, of course, the alias.

alias man=pdfman

In this function, a temporary file is created and the ps2pdf utility is used to convert the man output to PDF format, which is then displayed on screen. The conversion is surprisingly quick, hardly any noticeable delay. Here, I'm using Mate's Atril PDF display utility to show the PDF files, but this can be substituted for your own favorite PDF reader.

If the manual page does not exist, then you get a blank PDF displayed and the message "No manual entry for..." is displayed in the terminal. While this can be considered a bug, I considered it not worth fixing, as the blank file tells the story. The temporary PDF file is destroyed on exiting the function.

While this is not a the most efficient process, it works well and resource usage is low and only temporary. I may investigate expanding this to view info files. Well, maybe one day I will, but I really don't use info files much, since I can usually get clearer information from the internet.



The ps2pdf utility is part of the ghostscript-common package which, if not already installed, is available in the PCLinuxOS repositories.

So now I have Mate mostly set up that I can use it in the way that I used KDE. Whatever features are still missing, I now have a good idea how to set them up. Plus, I have access to some features that I never knew in KDE. My Mate setup is snappy and responsive, while demanding less from my hardware. As a bonus, should I ever decide to switch to another desktop environment, I now know how to get the most out of it.

Linux has always been extremely configurable, enabling users to more precisely adjust it to their needs and preferences. These few tools that I have explored can give you access to even more of these features.



Previous Page              Top              Next Page