From 5ab1541c3fe8f8cc284a038632bb451f8e3d79de Mon Sep 17 00:00:00 2001 From: Michael Hanson Date: Tue, 9 Aug 2011 23:32:52 +0000 Subject: linhes-scripts: fix my boo-boo --- abs/core/linhes-scripts/PKGBUILD | 4 +- abs/core/linhes-scripts/xwin_find.sh | 488 +++++------------------------------ 2 files changed, 73 insertions(+), 419 deletions(-) diff --git a/abs/core/linhes-scripts/PKGBUILD b/abs/core/linhes-scripts/PKGBUILD index 9ebe47c..9c35ee3 100644 --- a/abs/core/linhes-scripts/PKGBUILD +++ b/abs/core/linhes-scripts/PKGBUILD @@ -3,7 +3,7 @@ pkgname=linhes-scripts pkgver=7 -pkgrel=7 +pkgrel=8 pkgdesc="Various scripts that help to make LinHES, LinHES." arch=('i686' 'x86_64') license=('GPL2') @@ -91,4 +91,4 @@ md5sums=('f56985b2d602e11dc1e10d3e7848b2a5' 'df727c98350a64e2171c950bbefc9c5d' '7b890e7044db38e8d439f67e398af206' '35693f50939d5827aeabfce8c5dce589' - 'e93ef4eb6dae27c872c80b22b3356432') + 'a94fe6d980f4b810f2e2ae5352084b39') diff --git a/abs/core/linhes-scripts/xwin_find.sh b/abs/core/linhes-scripts/xwin_find.sh index 1720c96..35309dd 100644 --- a/abs/core/linhes-scripts/xwin_find.sh +++ b/abs/core/linhes-scripts/xwin_find.sh @@ -1,418 +1,72 @@ - - - - -LinHES - xwin_find.sh - LinHES - - - - - - +#!/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 - - - - - - - - - - - - -
-
- - - - -
- - -
- -

xwin_find.sh

- -
-

xwin_find utility required by idle.sh - - chael, 01/30/2011 09:57 am

-

Download (2 kB)

- -
-  -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1
#!/bin/sh
-
2
#
-
3
# xwin_find [-v|-q] [timeout] window_name_regex
-
4
#
-
5
# Look for a window of the windows full name given by a awk regular
-
6
# expression, and print the windows xwindow ID.
-
7
#
-
8
# If a timeout is given (in seconds)continue to look for the windows ID
-
9
# for this amount of time before returning.  (EG default a single search)
-
10
#
-
11
# If no such window is found output nothing, just exit
-
12
#
-
13
# OPTIONS
-
14
#    -v    verbose, print the full matching xwininfo line on stderr
-
15
#    -q    do not print windows ID on stdout
-
16
#
-
17
####
-
18
# Anthony Thyssen    September 2005
-
19
#
-
20
PROGNAME=`type $0 | awk '{print $3}'`  # search for executable on path
-
21
PROGDIR=`dirname $PROGNAME`            # extract directory of program
-
22
PROGNAME=`basename $PROGNAME`          # base name of program
-
23
Usage() {
-
24
  echo >&2 "$PROGNAME:" "$@"
-
25
  sed >&2 -n '/^###/q; s/^#$/# /; 3s/^#/# Usage:/;  3,$s/^# //p;' \
-
26
          "$PROGDIR/$PROGNAME"
-
27
  exit 10;
-
28
}
-
29
-
30
timeout=0
-
31
-
32
while [  $# -gt 0 ]; do
-
33
  case "$1" in
-
34
  [0-9]*) timeout=`date +%s`
-
35
          timeout=`expr $timeout + $1 + 1` || Usage
-
36
          ;;
-
37
  -q)     QUIET=true ;;   # don't print the final window ID, just status
-
38
  -v)     VERBOSE=true ;; # output the full xwininfo line on stderr
-
39
-
40
  --)     shift; break ;;    # end of user options
-
41
  -*)     Usage "Unknown option \"$1\"" ;;
-
42
  *)      break ;;           # end of user options
-
43
  esac
-
44
  shift   # next option
-
45
done
-
46
-
47
[ $# -lt 1 ] && Usage "Missing window search regex"
-
48
[ $# -gt 1 ] && Usage "Too many arguments."
-
49
-
50
-
51
find_win() {
-
52
  # nice added to let it give way to starting processes
-
53
  if [ "$VERBOSE" ]; then
-
54
    line=`nice xwininfo -root -tree | awk '/"'"$1"'":/ {print; exit}'`
-
55
    echo >&2 $line    # VERBOSE - xwininfo output
-
56
    echo "$line" |  sed 's/ .*//'
-
57
  else
-
58
    nice xwininfo -root -tree | awk '/"'"$1"'":/ {print $1; exit}'
-
59
  fi
-
60
}
-
61
-
62
while :; do
-
63
  id=`find_win "$1"`
-
64
  if [ "$id" ]; then
-
65
    [ -z "$QUIET" ] && echo $id  # the window ID found
-
66
    exit 0;
-
67
  fi
-
68
  [ `date +%s` -ge $timeout ] && break
-
69
done
-
70
-
71
exit 1  # window was not found
-
72
-
-
- - - - - - -
-
-
- - - - -
-
- - - -- cgit v0.12