6

I have a keybinding for ToggleShowDesktop. When I press Menu, all windows get minimized and I see my Desktop Wallpaper (as expected):

<keybind key="Menu">
  <action name="ToggleShowDesktop"/>
</keybind>

Now the problem is, I don't want to see my wallpaper. I am using terminator as my wallpaper, i.e. when I start terminator, it is placed on the layer below:

<application name="terminator">
  <focus>yes</focus>
  <layer>below</layer>
  <desktop>1</desktop>
  <position>
    <y>0</y>  
    <x>0</x>
  </position> 
  <skip_taskbar>yes</skip_taskbar>
  <maximized>true</maximized>
</application>

Is it possible to configure ToggleShowDesktop so that it leaves the "below" layer unaffected? i.e. I want only the normal windows to be minimized, but not terminator. In other words, I want terminator to behave as normal wallpaper would - be unaffected by ToggleShowDesktop.

I am using Debian Wheezy with LXDE.

UPDATE (using method suggested by @Suchipi):

I have left out few details from my original question, and now these details seem to be relevant after all:

My setup has 2 monitors and 4 virtual desktops. So I have "8 wallpapers" to fill with terminator. From what I have read previously, I assumed that these 8 windows will have to be distinguishable, so I have created 8 symliks to terminator, .i.e.:

/usr/bin/terminator-wallpaper-1a  -> terminator
/usr/bin/terminator-wallpaper-1b  -> terminator
/usr/bin/terminator-wallpaper-2a  -> terminator
...

In effect created 8 different applications (with different names).

Similarly, in .config/openbox/lxde-rc.xml I have not 1, but 8 definitions:

<application name="terminator-wallpaper-1a">
  <desktop>1</desktop>
  <position>
    <monitor>1</monitor>
  </position>
  ...
</application>

<application name="terminator-wallpaper-1b">
  <desktop>1</desktop>
  <position> 
    <monitor>2</monitor>
  </position>
  ...
</application>

<application name="terminator-wallpaper-2a">
  <desktop>2</desktop>  
  <position> 
    <monitor>1</monitor>
  </position>
  ...
</application>

And lastly, in /.config/autostart I have 8 *.desktop files, to be started automatically after login:

/.config/autostar/terminator-wallpaper-1a.desktop
/.config/autostar/terminator-wallpaper-1b.desktop
/.config/autostar/terminator-wallpaper-2a.desktop

This seems to me quiete overcomplicated and inelegant, but I didn't see any better way to do it.

Now, when I follow the instructions from @Suchipi, the following happens:

1) the part with devilspie works OK. It turns out, I need only one definition which covers all my 8 windows (substituting matches for is):

$ cat .devilspie/terminator.ds 
(if
(matches (application_name) "terminator-wallpaper")
(begin
(wintype "desktop")
)
)

And I can see with obxprop that it works as expected.

$ obxprop | egrep '(_OB_APP|_NET_WM_WINDOW_TYPE)'
_OB_APP_TYPE(UTF8_STRING) = "normal"
_OB_APP_TITLE(UTF8_STRING) = "None"
_OB_APP_CLASS(UTF8_STRING) = "Terminator-wallpaper-1"
_OB_APP_NAME(UTF8_STRING) = "terminator-wallpaper-1"
_OB_APP_ROLE(UTF8_STRING) = 
_NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_DESKTOP

2) now the part with xdotool is more tricky: first of all, using 100% for the resolution does not work, i.e. the window disappears (I don't see it). When using static:

xdotool search --class "Terminator-wallpaper-1a" windowunmap --sync windowmap windowsize %1 1920 1056

this works for desktop 1 monitor 1. But when I run it for other desktops, it has no effect, i.e.:

xdotool search --class "Terminator-wallpaper-2a" windowunmap --sync windowmap windowsize %1 1920 1056

UPDATE2:

Actually, it works for other desktops as well, but only if I run the xdotool command on the specific desktop, which I want to affect. i.e. I have to switch to desktop 2 and run xdotool search --class "Terminator-wallpaper-2a" and then it works.

Also, I was wondering whether the windowsize %1 plays any role here.

  • The Openbox wiki Action Page says that ToggleShowDesktop "Hides all windows so that the desktop is visible, and gives focus to the desktop window if one exists (such as in GNOME and KDE)." If you can find out what desktop windows GNOME and KDE have and make terminator have the same properties, I imagine it'd give you the functionality you're looking for. – Suchipi Jun 28 '14 at 1:44
  • The %1 in windowsize is referring to the last selected window, in this case the one that we got with search --class "terminator". See the xdotool documentation for more information. – Suchipi Jun 28 '14 at 17:05
  • Also, devilspie can set the workspace and viewport of a window, as well as controlling maximization. You may want to experiment using devilspie to remaximize the window instead of xdotool. – Suchipi Jun 28 '14 at 17:13
  • @Suchipi - the window resolution is not the main problem, I can use fixed size. But as I described in my UPDATE, xdotool only works for windows which are on the same virtual desktop as the terminal from which I run xdotool. Running xdotool from a script does not work. But I need to create a script which will autostart and execute xdotool upon login. How can I do it? – Martin Vegter Jun 28 '14 at 17:29
  • xdotool can emulate keyboard and mouse input, so maybe you could set it to cycle through your workspaces using keyboard shortcuts and unmap/map the windows as it does so. Refer to the xdotool documentation I linked to above for detailed instructions on how to do this (you'll be using xdotool key). – Suchipi Jun 28 '14 at 18:22
7
+300

Openbox will give the functionality you are looking for to windows whose _OB_APP_TYPE property is set to "desktop" (You can use obxprop to check the properties of a window). So we need to set the _OB_APP_TYPE for your terminator window to "desktop" so that this will happen.

Reading through the openbox source code, in client.c I could see that _OB_APP_TYPE is inherited from _NET_WM_WINDOW_TYPE. So I looked for an application that could change _NET_WM_WINDOW_TYPE. The application I found is called devilspie.

First, install it:

sudo apt-get install devilspie

Next, we'll create the folder for devilspie configuration files:

mkdir ~/.devilspie

Now we will add a config file that tells devilspie to look for applications named terminator and set the window type of them to desktop. Put the following into ~/.devilspie/terminator.ds:

(if
(is (application_name) "terminator")
(begin
(wintype "desktop")
)
)

Now, if you run devilspie (or devilspie -a to affect existing windows instead of just newly created ones) you'll notice if you use obxprop on terminator that _NET_WM_WINDOW_TYPE has changed, but _OB_APP_TYPE has not yet. Let's use xdotool to unmap and remap the window (in X11 terminology this means we will stop drawing and begin drawing the window), which should force openbox to notice the value.

Install xdotool:

sudo apt-get install xdotool

Then we run the following script to find the terminator window, unmap it, wait until it has been unmapped, then remap it. We also resize the window because when it was unmapped and remapped it lost its maximization:

xdotool search --class "terminator" windowunmap --sync windowmap windowsize %1 1024 768

Replace 1024 768 with your resolution. Also note that newer versions of xdotool than those found in Debian's apt repo support using 100% 100% instead of a static resolution. You can find .deb packages for newer versions of xdotool at xdotool's googlecode page.

The terminator window will immediately become undecorated, and if you now use obxprop, you will see that both values have been set properly. If you now press the key you bound ToggleShowDesktop to a few times, the terminator window will always stay active.

To make this persistent, you'll want to run these commands on login. The LXDE Wiki Page for LXSession shows several different ways to do this (global, per-user, per-profile, etc). Assuming you want these settings just for your user and under the LXDE profile (the default), you'll want to edit ~/.config/lxsession/LXDE/autostart and add the commands we ran, keeping in mind that the xdotool command needs to be run after terminator's window has been rendered, so do something like (sleep 1s & xdotool ...). You could also set these commands up as keybinds in openbox if you wish.

  • thanks for the detailed instructions. Please see my update. – Martin Vegter Jun 28 '14 at 8:11
2

I came up with the following script which looks like it solves your problems.

#!/bin/sh

make_wid_desktop_app() {
    # set the type of the window to 
    xprop -id $1 -f _NET_WM_WINDOW_TYPE 32a -set _NET_WM_WINDOW_TYPE _NET_WM_WINDOW_TYPE_DESKTOP
    xprop -id $1 -f _MOTIF_WM_HINTS 32c -set _MOTIF_WM_HINTS 0
    xprop -id $1 -remove _MOTIF_WM_HINTS
}

get_wids() {
    xdotool search --class $1
}

for id in $(get_wids $1); do
    make_wid_desktop_app $id;
done

You can use it like this.

desktop_terminal terminator-wallpaper

It searches for all windows that have the class terminator-wallpaper with xdotools and change there _NET_WM_WINDOW_TYPE to _NET_WM_WINDOW_TYPE_DESKTOP with xprop.

Since Openbox does not check if this type was changed after a window was created we need to trick Openbox into doing this. This gets done by setting the _MOTIF_WM_HINTS and removing them.

The same thing can be achieved with devilspie when you add

(if
   (matches (application_name) "terminator-wallpaper")
   (begin
       (wintype "desktop")
       (undecorate)
   )
)

since setting the window to (undecorate) is also using the _MOTIF_WM_HINTS trick.

  • 1
    Looks like we've gotten the last piece of the puzzle! :D – Suchipi Jun 30 '14 at 18:52
0

If I get the question correctly then your question is like this: whenever you click on ToggleShowDesktop then you want all open application to get minimized except terminator.

If this is so then you can achieve this by writing a wrapper script, which will internally call two commands

#!/bin/sh
xdotool key "super+d" 
wmctrl -a "terminator"

Replace the actual ToggleShowDesktop binary/script by above mentioned wrapper script

It may seem dirty hack but it work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.