From 631f3dc4b6c2de23cbdf151aad88cbbb824039be Mon Sep 17 00:00:00 2001 From: Michael Hanson Date: Tue, 9 Aug 2011 23:21:55 +0000 Subject: linhes-scripts: Add the window check to idle.sh. Closes #755 --- abs/core/linhes-scripts/PKGBUILD | 8 +- abs/core/linhes-scripts/idle.sh | 8 +- abs/core/linhes-scripts/xwin_find.sh | 418 +++++++++++++++++++++++++++++++++++ 3 files changed, 430 insertions(+), 4 deletions(-) create mode 100644 abs/core/linhes-scripts/xwin_find.sh diff --git a/abs/core/linhes-scripts/PKGBUILD b/abs/core/linhes-scripts/PKGBUILD index 0b5c2a9..9ebe47c 100644 --- a/abs/core/linhes-scripts/PKGBUILD +++ b/abs/core/linhes-scripts/PKGBUILD @@ -3,7 +3,7 @@ pkgname=linhes-scripts pkgver=7 -pkgrel=6 +pkgrel=7 pkgdesc="Various scripts that help to make LinHES, LinHES." arch=('i686' 'x86_64') license=('GPL2') @@ -44,6 +44,7 @@ myth2fuze dct700-cc.sh qip7100-cc.sh dtheme.sh +xwin_find.sh ) build() { @@ -74,7 +75,7 @@ md5sums=('f56985b2d602e11dc1e10d3e7848b2a5' '3b776bbff68906ddc2f62b7e0dde3fe4' '15f3143d2b1369da431e4268029aba40' '3d0adf26280cde55a0c47188fff34826' - '7ffe9cea9c5604b696a2a1d274c21ac3' + '25dd5b8ec0482d561b481bfce051d648' 'b2c3dd48a4abb976eda2d5fbf22a173a' 'b527b01d119d3bc33b8fa69bdf1082bb' 'c537c44156d8404016cc4b405b092d45' @@ -89,4 +90,5 @@ md5sums=('f56985b2d602e11dc1e10d3e7848b2a5' 'd2a29444ab9036fb385bbf044daf1ff5' 'df727c98350a64e2171c950bbefc9c5d' '7b890e7044db38e8d439f67e398af206' - '35693f50939d5827aeabfce8c5dce589') + '35693f50939d5827aeabfce8c5dce589' + 'e93ef4eb6dae27c872c80b22b3356432') diff --git a/abs/core/linhes-scripts/idle.sh b/abs/core/linhes-scripts/idle.sh index 13fdb89..70db6f0 100755 --- a/abs/core/linhes-scripts/idle.sh +++ b/abs/core/linhes-scripts/idle.sh @@ -106,7 +106,13 @@ if [ "$LOGINS" -ge 1 ] ; then fi fi -activities=$(($BUSY + $SCHEMALOCK + $JOBS + $INUSE + $UPCOMING + $LOGINS)) +# Check for open windows +/usr/LH/bin/xwin_find.sh -q '.*(mythtv@|xterm|Firefox|Namoroka|Opera).*' +WINDOWS="$?" +WINDOWS=$(($WINDOWS == 0)) +msg "windows $WINDOWS" + +activities=$(($BUSY + $SCHEMALOCK + $JOBS + $INUSE + $UPCOMING + $LOGINS + $WINDOWS)) msg if [ "$activities" -eq 0 ] ; then msg "System is idle" diff --git a/abs/core/linhes-scripts/xwin_find.sh b/abs/core/linhes-scripts/xwin_find.sh new file mode 100644 index 0000000..1720c96 --- /dev/null +++ b/abs/core/linhes-scripts/xwin_find.sh @@ -0,0 +1,418 @@ + + + + +LinHES - xwin_find.sh - LinHES + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ + +
+ +

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