Ubuntu/ Gnome : Open an application in a specific workspace

23,045

Solution 1

You could use devilspie to set rules for which windows go on which workspace.

See the docs for an example of exactly that.

But MrStatic has a good suggestion too. Try that one first, you might not even need your shell script.

If you need it to be a command you can use in a shell script, have a look at wmctrl.

Solution 2

I have tried the wmctrl tool and found that the easiest solution that worked for me is to move window with the following command:

wmctrl -r <WindowName> -t <WorkspaceNumber>

Note that the workspace numbers starts from 0. Last you can move to your preferred workspace with the command:

wmctrl -s <WorkspaceNumber>

Solution 3

I use this basic structure in scripts to open a specific set of applications in specific workspaces..the example opens my terminal and moves it to workspace 1...

cd
gnome-terminal
until wmctrl -l | grep -q "me@mypc ~"; 
do
    sleep 0.1
done
wmctrl -r "me@mypc ~" -t 1
Share:
23,045

Related videos on Youtube

bguiz
Author by

bguiz

Writes Javascript, Java, Python &amp; C++

Updated on September 17, 2022

Comments

  • bguiz
    bguiz over 1 year

    How do tell an application to open in a specific workspace?


    More info:

    I like to have my C++ IDE in workspace 2, my Java IDE in workspace 3, and my email, browser and miscellaneous in workspace four. I also use a shell script that executes upon log in:

    #!/bin/bash
    gnome-terminal & # WS 1
    netbeans-6-9-1 & # WS2
    qtcreator-2-0-1 & # WS 3
    firefox & # WS 4
    thunderbird & # WS 4
    

    Of course currently it all opens in the current workspace... Is there a way for me to specify which workspace each command should start in?

    Thanks in advance!

  • bguiz
    bguiz over 13 years
    thanks for the suggestion, will check it out - I would still consider a CLI-only solution to be a superior solution though, so if you have any ideas for one, let me know!
  • Nethan
    Nethan over 13 years
    Try wmctrl. I added a link in my answer above.
  • Nethan
    Nethan over 9 years
    The OP said the browser goes on workspace four. If it needed to be possible to open browsers on other workspaces after the session startup script runs, the last command in that script could be sleep; pkill devilspie.
  • wranvaud
    wranvaud about 5 years
    A little explanation about this code would be welcome. Why does it start with cd? what are you expecting in the until? is "me@myspc ~" a window name??