If you want to resize the firefox window that has the keyboard focus:
#! /bin/sh
fw=`xdotool getwindowfocus`
for nw in `xdotool search --classname Navigator`; do
test "$fw" = "$nw" && xdotool windowsize "$fw" 800 600
done
Notice that this will not work if you're typing the script in a terminal; in that case it's the terminal that has the focus. You can use getactivewindow
instead of getwindowfocus
if your window manager supports _NET_ACTIVE_WINDOW
.
If instead you want to resize the top-first firefox window:
nw=`xdotool search --classname Navigator | tail -1`
test "$nw" && xdotool windowsize "$nw" 800 600
Note
If you're using dwm
, then please consider this (from the dwm's homepage):
dwm is customized through editing its source code, which makes it
extremely fast and secure - it does not process any input data which
isn’t known at compile time, except window titles and status text read
from the root window’s name. You don’t have to learn Lua/sh/ruby or
some weird configuration file format (like X resource files), beside
C, to customize it for your needs: you only have to learn C (at least
in order to edit the header file).
Because dwm is customized through
editing its source code, it’s pointless to make binary packages of it.
This keeps its userbase small and elitist. No novices asking stupid
questions.
This means that calling an external script is simply not going to work.
You're supposed to resize windows, check their class, etc from C
, by modifying dwm
's source code.
xdotool
command in a terminal would not work, because it's the terminal which has the focus. If you want to resize all firefox windows:xdotool search --classname Navigator windowsize %@ 800 600
; replace%@
with%1
to resize just the first from the list.