Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to autostart firefox and thunderbird on e.g. 2 and 3-rd workspaces when login. If I add them to autostart in gnome-shell they both open on the first workspace. Is there a way to autostart application on the certain workspace, or at least on the "next" workspace(similar to dash middle-click). I'd like to avoid using auto-move-windows extension.

share|improve this question

The following is a program that will start another application and move it to a specified work space.

You should copy this into a file named, mark it executable, and put it somewhere in your home directory (i would suggest putting it in the ~/.local folder, but you can put it in your ~/bin or some other place if you prefer, just remember where you put it and what you named it). (pastebin link)


# invocation 
# <desktop> <prog> <prog args>

if [ $# -lt 2 ]; then
    echo "invocation: <desktop> <prog> <prog args>"
    exit 1


while (( "$#" )); do
    args="$args ""$1"

$prog $args

windows=$(wmctrl -lp | grep -E "($(echo $(ps -C "$prog" -o pid,user | grep "`whoami`" | sed -E "s/^\ *//" | cut -d\  -f 1) | sed "s/\ /|/g"))" | cut -d\  -f 1)

for w in $windows; do
    wmctrl -i -r $w -t $desk

exit 0

Once you have done that go to ~/.config/autostart in either your shell or Nautilus.

In this folder you will find some files with names like app-name.desktop find the ones corresponding to the applications you want to launch (most likely <name>.desktop) and open them in your favorite text editor.

For each file find the line that starts exec=<some command and args> and change it to exec=</path/to/above/script>/ <desktop number> <some command and args>.

The next time you log in the app should be started and moved to the specified desktop.

Notes: Desktops are numbered starting from 0 so the first desktop is 0, the third is 2, etc.

Notes: If the desktop specified does not exist the window will remain in the original desktop.

share|improve this answer
Is it possible to modify this script to make all windows open in a new workspace? Or since gnome-shell seems to always have one extra empty workspace - in the last workspace? Similar to middle-clicking on an item in the application overview? – Robin Winslow Apr 28 '13 at 22:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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