Richard Levitte - VMS Whacker on  wrote...
| In message <[EMAIL PROTECTED]> on Wed, 19 Jul 2006 14:08:44 +0200, Kai 
Grossjohann <[EMAIL PROTECTED]> said:
|
| kai.grossjohann> But perhaps the same applications that do not support
| kai.grossjohann> -geometry also do not support -xrm :-(
|
| Yeah, that's why I wondered if there was an environment kind of
| shortcut into XLib itself...
|

Actually I have been through this problem myself, with gnome
applications.

The solution is a small app called..  xwit
  xwit -- window interface tool: pop, resize, position, or iconify windows

I also use a standard X application called  "xwininfo"  to locate a
window.  This I wrapped a script around it I call  "xfind_win" to look
for (waiting if needed) a specific window to appear. (Included below)

For for example  firefox does not allow you to start it iconified
and I don't want TWM iconifing efect new firefox window, so I do the
following in my start up scripts...

=======8<--------
firefox -geometry 820x1000+530+70 &
if id=`xwin_find 240 ".* Mozilla Firefox"`; then
  xwit -iconify -id $id
fi &
=======8<--------

This starts firefox, then calls the "xfind_win" script below to
wait for the window to appear.  When it does, iconify it.

I use the same techniques to handle the start up of a gnome-panel
BUT without the nautilus background window!

=======8<--------
# ----- Launch the Gnome Side Panel -----
# Start the gnome settings daemon
# This is required to define the icon theme and filemanager icons used.
# Also to enable the use of Gnome keyboard Shortcuts (volume control)
# Problem: This destroys my own X resource settings!!  Restore them.
xrdb -query > /tmp/xrdb-anthony
for gsd in \
  FC:     /usr/libexec/gnome-settings-daemon \
  Ubuntu: /usr/lib/control-center/gnome-settings-daemon \
  SUSE:   /opt/gnome/lib/control-center-2.0/gnome-settings-daemon \
  FAIL
do [ -x $gsd ] && break; done
( [ -x $gsd ] && exec $gsd ) &

# Start the gnome panel
gnome-panel &

( id_panel1=`xwin_find 180 "(Top|Side).* Panel|gnome-panel"`
  sleep 4  # this first appearence may not be the right window
  id_panel=`xwin_find 180 "(Top|Side).* Panel|gnome-panel"`
  if [ "$id_panel" ]; then
    # This is done by CTwm automatically
    #xwit -move 0 0 -id $panel_id

    gaim &
    gaim_id=`xwin_find 60 "Buddy List"` &&
          xwit -unmap -id $gaim_id      # unmap gaim (in toolbar)
  else
    zenity --error --title="Xsession" --text="Gnome-panel not found"
  fi
) &

# Fix the resouces of the gnome settings daemon
# It adds a huge number of global xresources that stuffs up everything
( if xwin_find -q 60 "gnome-settings-daemon"; then
    sleep 60
    xrdb $HOME/.Xresources
    [ -f .xmodmap ] && xmodmap .xmodmap
  else
    error_popup "Gnome-Settings-Daemon not found"
  fi
) &
=======8<--------

That is the current state of my gnome handling outside CTwm and it is
working very well.

In my CTwm configuration I also have..

=======8<--------
#
# Gnome Panel and Application Handling  (Special addition)
#
# Note: if nautilus "desktop-window" is activated, then the root screen, and
# thus CTWM root menus will not be accessable.  However without a 'NoBorder{}'
# a window edge will be visible at the top of the screen for menu handling (if
# desired).  To delete a accidentaly activated desktop window, destroy()
# any nautilus window, to completely kiil nautilus (but not the panel).
#
define([PANELS],[dnl  The Panels only, not all of Gnome-panel applications
  "Top*Panel" "Left*Panel"  "Side*Panel"
  "Right*Panel"  "Bottom*Panel"
])dnl
NoTitle { PANELS "desktop_window" } # Do not add title bars
OccupyAll { # an have then occupy all workspaces
  "Gnome-panel" "Gaim"  # the panel is the gnome controls
}
ifelse( eval( CTWM_VERSION >= 352 ), 1, [dnl Only if CTWM  Version  >= 3.5.2
NoBorder { PANELS }
AutoRaise { "Gnome-panel" }      # Panel and popups are above everything
AutoLower { "desktop_window" }   # Gnome filemanager desktop (under all)
#NoBorder { "desktop_window" }   # DONT: leave a border at top for menus
])dnl
ifelse( eval( CTWM_VERSION >= 360 ), 1, [dnl Only if CTWM  Version  >= 3.6
IconMenuDontShow { "Gnome-panel" "desktop_window" }
WindowGeometries {
  "Top*Panel"  "+0+0"   "Left*Panel" "+0+0"    "Side*Panel" "+0+0"
  "Right*Panel" "-0+0"  "Bottom*Panel" "+0-0"
  "desktop_window" "+0+0"
}
#
# Setup dependant options
BorderLeft 48

])dnl
=======8<--------

I also have handlers to handle my home being shared on multiple
different Linux distributions, as gnome configuration for one linux
stuffs up the gnome on another. As such I have script blocks to use
different gnome directories for different linux distributions.


All Comments and suggestions welcome, especially how you handle Gnome
and extra ill-behaved modern application windows.

  Anthony Thyssen ( System Programmer )    <[EMAIL PROTECTED]>
 -----------------------------------------------------------------------------
    Man may come, and man may go, but the earth abides.  -- "The Earth Abides"
 -----------------------------------------------------------------------------
     Anthony's Home is his Castle     http://www.cit.gu.edu.au/~anthony/
#!/bin/sh
#
# xwin_find [-v|-q] [timeout] window_name_regex
#
# Look for a window of the windows full name given by a awk regular
# expression, and print the windows xwindow ID.
#
# If a timeout is given (in seconds)continue to look for the windows ID
# for this amount of time before returning.  (EG default a single search)
#
# If no such window is found output nothing, just exit
#
# OPTIONS
#    -v    verbose, print the full matching xwininfo line on stderr
#    -q    do not print windows ID on stdout
#
####
# Anthony Thyssen    September 2005
#
PROGNAME=`type $0 | awk '{print $3}'`  # search for executable on path
PROGDIR=`dirname $PROGNAME`            # extract directory of program
PROGNAME=`basename $PROGNAME`          # base name of program
Usage() {
  echo >&2 "$PROGNAME:" "$@"
  sed >&2 -n '/^###/q; s/^#$/# /; 3s/^#/# Usage:/;  3,$s/^# //p;' \
          "$PROGDIR/$PROGNAME"
  exit 10;
}

timeout=0

while [  $# -gt 0 ]; do
  case "$1" in
  [0-9]*) timeout=`date +%s`
          timeout=`expr $timeout + $1 + 1` || Usage
          ;;
  -q)     QUIET=true ;;   # don't print the final window ID, just status
  -v)     VERBOSE=true ;; # output the full xwininfo line on stderr

  --)     shift; break ;;    # end of user options
  -*)     Usage "Unknown option \"$1\"" ;;
  *)      break ;;           # end of user options
  esac
  shift   # next option
done

[ $# -lt 1 ] && Usage "Missing window search regex"
[ $# -gt 1 ] && Usage "Too many arguments."


find_win() {
  # nice added to let it give way to starting processes
  if [ "$VERBOSE" ]; then
    line=`nice xwininfo -root -tree | awk '/"'"$1"'":/ {print; exit}'`
    echo >&2 $line    # VERBOSE - xwininfo output
    echo "$line" |  sed 's/ .*//'
  else
    nice xwininfo -root -tree | awk '/"'"$1"'":/ {print $1; exit}'
  fi
}

while :; do
  id=`find_win "$1"`
  if [ "$id" ]; then
    [ -z "$QUIET" ] && echo $id  # the window ID found
    exit 0;
  fi
  [ `date +%s` -ge $timeout ] && break
done

exit 1  # window was not found


Reply via email to