tags:

views:

57

answers:

2

Hi dear stackers,

given I'm a lazy bastard, I tried to write a Bash script that opens at once some daily apps in different desktops. I've written that so far:

#!/bin/bash
firefox &
thunderbird &
/usr/bin/netbeans --locale en &
amsn &
gnome-terminal &
sleep 2
wmctrl -r firefox -t 0 && wmctrl -r netbeans -t 1 && wmctrl -r gnome-terminal -t 2 && wmctrl -r amsn -t 6 && wmctrl -r thunderbird -t 7

But, it doesn't work. My apps open, but they won't be assigned to the desktops I specify :(.

Any ideas ? Thanks in advance !

Rolf

P.S.: I use Gnome

EDIT: I changed the value of sleep to 15... only firefox & netbeans are assigned correctly, the rest opens in the workspace where I execute the script from...

SOLVED: thanks to Akira comment, I finally succeeded at making it work (the script runs at startup like a charm) Here is the new code:

#!/bin/bash
wmctrl -n 8

firefox &
thunderbird &
/usr/bin/netbeans --locale en &
amsn &
gnome-terminal &
sleep 15

wmctrl -r firefox -t 0
wmctrl -r netbeans -t 1 
wmctrl -r terminal -t 2 
wmctrl -r amsn -t 6 
wmctrl -r thunderbird -t 7

#focus on terminal
wmctrl -a terminal 
A: 

what graphical frontend do you use? for example when you use ubuntu with gnome and compiz you can set the window placement in

System>Preferences>CompizConfig Settings Manager>Window Management>Place windows

Mies
Hi, I don't use Compiz...
Rolf
A: 

checkout DevilsPie, it watches creation of windows and act accordingly.

Devil's Pie can be configured to detect windows as they are created, and match the window to a set of rules. If the window matches the rules, it can perform a series of actions on that window. For example, I can make all windows created by X-Chat appear on all workspaces, and the main Gkrellm1 window does not appear in the pager or task list.

Or you can use a window manager which is able to do the same in-house, eg. fluxbox.

akira
hi, if there is no satisfactory solution with wmctrl, I'm gonna check that, thanks :)
Rolf
the reason why wmctrl does not work in your example is this: the firefox window is not yet there while you already trigger the wmctrl command. the sleep is not enough.
akira
Rolf
akira
thanks it works :)I've added the script to the first message...
Rolf