How to launch an application on a specific desktop from command line?
The title says it all. I usually have a console window on my Desktop 1; I would like to be able to launch from there any application specifying on which Desktop the application window should appear. For example, from my console window on Desktop 1. I would like to launch thunderbird
in such a way that its window opens on Desktop 2. Is this possible? (I'm running kubuntu 9.04)
Solution 1:
Here are a few options.
Devil's Pie
Here's an old tutorial.
wmctrl
You can make a script to move to the desired workspace and then launch your app (source):
#!/bin/bash
wmctrl -s 1
firefox --new-tab $@ &
Or you could launch your app and then move it. I think something like this would work:
#!/bin/bash
thunderbird &
wmctrl -r :ACTIVE: -t 1
# if thunderbird takes a while to launch, you may need to find the window yourself:
#wmctrl -r `wmctrl -l | grep [t]hunderbird | cut -f1` -t 1
Compiz Place plugin
You can enable and configure this if you install compizconfig-settings-manager .
Allows you to set fixed positions for windows with specific titles.
FYI, previously I used wmctrl
in Gnome. Some of its features don't work for me in 11.04 w/ Unity, but should be good in 9.04. Not sure about KDE though.
Solution 2:
Install wmctrl
sudo apt install wmctrl
And create a script (in this example thunderbird on the second workspace (-t 1
)):
#!/bin/sh
thunderbird
wmctrl -i -r `wmctrl -l | grep Thunderbird` -t 1
To know your application name on wmctrl you can view it by taping on your terminal :
wmctrl -l
And replace it with the correct name in the script.
Be carrefull with the capital letter ("Thunderbird" not "thunderbird") !!
Other example with firefox on the 3d workspace (-t 2
):
#!/bin/sh
firefox
wmctrl -i -r `wmctrl -l | grep Firefox` -t 2
Work on Debain 10 with Cinnamon. But should work for all