source: trunk/debathena/debathena/dotfiles/xkill-mozilla.sh @ 21926

Revision 21926, 1.5 KB checked in by rbasch, 19 years ago (diff)
Kill all mozilla applications (mozilla, firefox, thunderbird) found running on the display.
Line 
1#!/bin/sh
2
3# $Id: xkill-mozilla.sh,v 1.2 2005-05-07 16:12:55 rbasch Exp $
4
5# Kill all mozilla.org applications running on this X display.
6
7moz_libdir=/usr/athena/lib/mozilla
8
9# See if any mozilla program is running.
10ping_mozilla () {
11  LD_LIBRARY_PATH=$moz_libdir${LD_LIBRARY_PATH:+":$LD_LIBRARY_PATH"} \
12    $moz_libdir/mozilla-xremote-client "ping()" > /dev/null 2>&1
13  return $?
14}
15
16killed=
17timeout=3
18i=0
19while ping_mozilla ; do
20  # Find all windows which plausibly belong to a mozilla application.
21  for win in `xwininfo -root -tree | \
22    awk '/Mozilla|Firefox|Thunderbird/ { print $1; }'` ; do
23    # Skip any window we have already tried to kill.
24    case $killed in
25    *" $win "*)
26      continue
27      ;;
28    esac
29    # See if the window has the _MOZILLA_PROGRAM property set.
30    moz_program="`xprop -id $win _MOZILLA_PROGRAM 2>/dev/null | \
31      sed -n -e 's/.*"\(.*\)"/\1/p'`"
32    case $moz_program in
33    mozilla|firefox|thunderbird)
34      # Found one.  Kill it, add it to the list of killed windows, and
35      # go back to the top of the outer loop to check against the new
36      # set of windows.
37      xkill -id $win > /dev/null 2>&1
38      killed=" $killed $win "
39      continue 2
40      ;;
41    esac
42  done
43  # If we get here, the ping found a running mozilla, but we were unable
44  # to find a window which had not already been killed.  Wait one second
45  # and try again, up to our timeout limit.
46  if [ `expr $i \>= $timeout` -eq 1 ]; then
47    echo "Unable to kill Mozilla" 1>&2
48    exit 1
49  fi
50  sleep 1
51  i=`expr $i + 1`
52done
53
54exit 0
Note: See TracBrowser for help on using the repository browser.