OK couple of points:
- You don't need the
/usr/bin
added. Shell will find wmctrl by itself. That's for very specific cases that may involve portability. - Add ampersand at the end of
firefox
command. The script will proceed only if the previous command exits. Since firefox doesn't exit, the script waits for it. - As Oli pointed out, better way is to use class name. I've done multiple scripts with
wmctrl
where i find hex id of the window by referencing class name.
Personally I'd do it this way:
#!/bin/bash
firefox http://www.google.de &
sleep 3
WM_ID=$(wmctrl -lx | awk '$3~/Navigator.Firefox/ {print $1}')
wmctrl -i -r $WM_ID -e 0,0,0,500,800
Here we open firefox , let it run in background, then we extract hex id of the window that matches class Navigator.Firefox
. In wmctrl -lx
field 3 is wm_class, and field 1 is hex id. awk helps us to extract field 1 here. Finally we reference that numeric id, inside the final wmctrl statement