LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Always open a window at the same position in GNOME (https://www.linuxquestions.org/questions/linux-software-2/always-open-a-window-at-the-same-position-in-gnome-884726/)

Lolwhut 06-05-2011 08:49 PM

Always open a window at the same position in GNOME
 
For something I'm working on, it would be incredibly useful to open a program (qemu, specifically), and have the window by default reside at a set position (in this instance, on the second monitor in the upper left corner). I can do this with gnome-terminal, but that seems to be the only application to have a feature like this this.

Is it possible to do this independent of the application itself, so that it would work with any application?

(GNOME 3 on Fedora 15)

macemoneta 06-05-2011 09:25 PM

Yes, you can do this with the wmctrl command in a script. You can install wmctrl from the standard repositories (yum install wmctrl). For example:

Code:

#!/bin/bash
someprogram &
WINDOW=`/usr/bin/wmctrl -l |/bin/grep "someprogram" | /usr/bin/awk '{print $1}'`
COUNT=0
while [ "$WINDOW" == "" ]; do
  /bin/sleep .1
  WINDOW=`/usr/bin/wmctrl -l |/bin/grep "someprogram" | /usr/bin/awk '{print $1}'`
  if [ $((COUNT++)) -ge 100 ]; then exit ; fi
done
/usr/bin/wmctrl -i -r $WINDOW -e 0,0,0,1800,1020

This runs 'someprogram', waits up to 10 seconds for the window to appear, then sets its position to the top left and resizes the window to 1800x1020.

Update: If you have trouble finding wmctrl, you can get the latest Fedora 15 version from the Fedora build system (Koji) here.


All times are GMT -5. The time now is 03:06 PM.