On Monday 2013-11-18, richard lucassen wrote:
> On Mon, 18 Nov 2013 14:28:04 +0100
>
> richard lucassen <[email protected]> wrote:
> > Ok, that's an option, I'll cook something with pidof and awk/sed/grep.
>
> For googlers who find this interesting: this is an extremely quick and
> dirty shell script for evince:
>
> #!/bin/dash
>
> HPOS=64
> VPOS=64
> HSIZE=1280
> VSIZE=960
> PID=$$
>
> exec /usr/bin/evince $1 &
> sleep 1
> WNAME=`wmctrl -lp \
>
> | awk '/ '${PID}' / {for (n=5; n<=NF; n++) printf $n" "; print ""}'`
>
> wmctrl -r "${WNAME}" -e "0,${HPOS},${VPOS},${HSIZE},${VSIZE}"
>
> YMMV ;-)
Richard, I have just checked the script above and I don't think it
would work as expected. For example $$ would return the PID of the
current shell and not the PID of your evince process.
However there is a special parameter $! which would expand to the PID
of the most recently executed background command and then you could
write something like this:
#!/bin/dash
HPOS=64
VPOS=64
HSIZE=1280
VSIZE=960
/usr/bin/evince "$1" &
sleep 1
PID=$!
WNAME=$(wmctrl -lp | awk '/'${PID}'/ {print $1}')
wmctrl -ir ${WNAME} -e "0,${HPOS},${VPOS},${HSIZE},${VSIZE}"
As you can see I have also used window window ID related to the evince
PID instead of the window name. This makes it somewhat easier to target
the window.
--
Josip Deanovic
--
To unsubscribe, send mail to [email protected].