[PLUG] Trying to change gnome-terminal command behavior

Rogan Creswick creswick at gmail.com
Wed Feb 2 19:14:19 UTC 2011


Similarly to Chris, I"m having a hard time brushing the fact that your
script is running gnome-terminal under the rug... but ok. I'll try to
ignore that :)

On Wed, Feb 2, 2011 at 10:33 AM, website reader
<website.reader3 at gmail.com> wrote:
> However if I am running on a different desktop and have a background
> program which issues the "gnome-terminal" command in a different
> desktop area, gnome-terminal brings up the active window in my desktop
> area, not the one of the issuing program running the script file.

This sort of behavior is controlled by your window manager, by
default, so finding an option may be difficult. Depending on your WM,
you might be able to tell it to always load certain windows in a
certain place, but that's likely to be fickle, since you may not
always start the script from the same desktop).  You might be able to
force the terminals to run minimized with the WM, but you will have to
find a way to uniquely identify those terminals (possible through a
certain title bar format.)

There are some other options though, that hinge on gnome-terminal's
comand line flags.  If you can update your script to invoke
gnome-terminal with certain flags, you can probably make it work:

--class=CLASS              Program class as used by the window manager
--name=NAME               Program name as used by the window manager
-t, --title=TITLE               Set the terminal title
    All three of these are useful for giving all the terminals that
the script launches a unique name.

--display=DISPLAY               X display to use
--screen=SCREEN                 X screen to use
    Force terminals to always show up on a specific X screen/display
(exactly what these mean for you is hard to say -- you'll have to
experiment).  Figuring out which is the right one, for a given
invocation of the script is tricky, but possible. (see below).

--geometry=GEOMETRY             Set the window size; for example:
80x24, or 80x24+200+200 (ROWSxCOLS+X+Y)
   This is just good to know of, but probably won't help much.

--maximize
   Not at all useful, really, but it indicates that there *might* be
an undocumented --minimize flag, which *could* help.

Figuring out where the script is running -- this also depends heavily
on your window manager, and honestly I don't know enough about the
tools to say for sure how to do it.  I have some ideas...

You almost certainly need the window ID for the window you're
launching the script from.  I use this little hack:

winIDHex=`xprop -root _NET_ACTIVE_WINDOW | awk '{print $5}'`

That assumes that the window is active -- so you *must* do this very
early in the script (the first thing, ideally).  If you move focus out
side of the window before getting the window id, you will probably get
the wrong result.

Once you have the window id, you can use tools like xwininfo to get
the geometry of that window, WM hints, etc... I don't know if that is
enough -- probably not, so you may need to find a WM-specific tool
that can take a window id and return a screen.  Then you can use that
with the --screen option to gnome-terminal later in the script.

Good luck!
Rogan

>
> This is quite annoying, as it grabs the mouse and keyboard entries,
> right in the middle of my work and leads to problems.
>
> How can I force gnome-terminal to not jump over desktops but stay
> rooted in the desktop of the shell script file that issued the
> command?
>
> The script files issues multiple gnome-terminal commands, since a work
> file is being processed, so I don't need this constant popping up and
> grabbing the focus behavior.  I want gnome-terminal to stay in the
> original desktop where the script file resides and let me work in
> peace.
>
> Any ideas?
>
> p.s. I am surprised that the command doesn't have an option to control
> this behavior.
> _______________________________________________
> PLUG mailing list
> PLUG at lists.pdxlinux.org
> http://lists.pdxlinux.org/mailman/listinfo/plug
>



More information about the PLUG mailing list