Ubuntu – How to open specific applications on specific workspaces in Lubuntu 13.04

lubuntulxdeworkspaces

I'm running Lubuntu 13,04 and have four workspaces set up. I want certain programs to open in a specfic workspace every time (like BOINC in workspace 4, an application for writing books in Workspace 2, etc). I've looked at a few other posts on the subject–but they're all for Ubuntu and Unity.

I tried devilspie, but it wouldn't open (technically it was gdevilspie that wouldn't open). I don't have compiz, as I'm on LXDE, so the CCSM options are out.

Any suggestions are greatly appreciated.

Have a great day.:)
Patrick.

Best Answer

Let's assume you have four desktops. And you want to always launch leafpad on Desktop 1, chromium-browser on Desktop 2, lxterminal on Desktop 3, and Document Viewer on Desktop 4.

First you need to run a program called xprop for each application this way as illustrated with leafpad. On any desktop, open lxterminal (not maximized) and open leafpad (not maximized). Then, in lxterminal, run xprop | grep "^_OB_APP". Nothing happens but the mouse cursor is now a cross-hairs. Now, click anywhere within the leafpad window. Then look back in the terminal window. You should see output like this:

[08:39 PM] ~ $ obxprop | grep "^_OB_APP"
_OB_APP_TYPE(UTF8_STRING) = "normal"
_OB_APP_TITLE(UTF8_STRING) = "(Untitled)"
_OB_APP_CLASS(UTF8_STRING) = "Leafpad"
_OB_APP_NAME(UTF8_STRING) = "leafpad"
_OB_APP_ROLE(UTF8_STRING) = 

Then, do this for the other programs.

_OB_APP_TYPE(UTF8_STRING) = "normal"
_OB_APP_TITLE(UTF8_STRING) = "Untitled - Chromium"
_OB_APP_CLASS(UTF8_STRING) = "Chromium-browser"
_OB_APP_NAME(UTF8_STRING) = "chromium-browser"
_OB_APP_ROLE(UTF8_STRING) = "browser"

_OB_APP_TYPE(UTF8_STRING) = "normal"
_OB_APP_TITLE(UTF8_STRING) = "LXTerminal"
_OB_APP_CLASS(UTF8_STRING) = "Lxterminal"
_OB_APP_NAME(UTF8_STRING) = "lxterminal"
_OB_APP_ROLE(UTF8_STRING) = 

_OB_APP_TYPE(UTF8_STRING) = "normal"
_OB_APP_TITLE(UTF8_STRING) = "Document Viewer"
_OB_APP_CLASS(UTF8_STRING) = "Evince"
_OB_APP_NAME(UTF8_STRING) = "evince"
_OB_APP_ROLE(UTF8_STRING) = 

With this information, we can proceed. Make a backup of ~/.config/openbox/lubuntu-rc.xml. Use a text editor, preferably one providing syntax highlighting, to edit lubuntu-rc.xml as described below.

Lubuntu-rc.xml has several sections and we're interested in the last section that starts with <applications> and ends with </applications>. You'll notice that the content in between these tags is commented out by the use of <!-- and -->.

Move to the end of this section and just above the line that has </applications>, paste in the following (as an illustrative example):

<application name="leafpad" class="Leafpad">
<desktop>1</desktop>
</application>

<application name="chromium-browser" class="Chromium-browser">
<desktop>2</desktop>
</application>

<application name="lxterminal" class="Lxterminal">
<desktop>3</desktop>
</application>

<application name="evince" class="Evince">
<desktop>4</desktop>
</application>

(Please note everything is case-sensitive. Use regular double quotes not smart quotes --- smart quotes may confuse the syntax highlighting in some editors.)

Save and close lubuntu-rc.xml. In a terminal, run openbox --reconfigure to register the changes. If you've done everything correctly, you'll just get the command prompt back. If you've messed up the tags, you'll get a pop-up!

Now, whenever you launch the programs you've specified above, they'll open on the assigned desktops.

I've found Openbox - Edit rc.xml to Gain Control very helpful in understanding lubuntu-rc.xml even though it's not written for Lubuntu.

Please note that you can also specify how (most) windows open. In other words, you can specify if they are to open maximized or, if not maximized, you maybe able to specify their size and position on the respective desktop.