Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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
add comment

1 Answer

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 move-at-start.sh, 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)

#!/bin/bash

# invocation 
# move-at-start.sh <desktop> <prog> <prog args>

if [ $# -lt 2 ]; then
    echo "invocation: move-at-start.sh <desktop> <prog> <prog args>"
    exit 1
fi

desk=$1
prog=$2
args=""
shift
shift

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

$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
done

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>/move-at-start.sh <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
add comment

Your Answer

 
discard

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.