summaryrefslogtreecommitdiff
path: root/nautilus-clean.sh
blob: 050e80185f7c8dc16ca826c70ed0ca357f5d4b5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/sh

# This is a quick hack to check if any nautilus auxiliary processes
# are running, and if so, list them and kill them.  It is not
# portable, and should be be expected to be used in any kind of
# production capacity.

quiet=no
extreme=no

if [ $# -gt 0 ]
then
    arg=$1

    if [ "$arg" = "-q" ]
    then
	quiet=yes
    elif [ "$arg" = "-x" ]
    then
	extreme=yes
    fi
fi

if [ $# -gt 1 ]
then
    arg=$2

    if [ "$arg" = "-q" ]
    then
	quiet=yes
    elif [ "$arg" = "-x" ]
    then
	extreme=yes
    fi
fi


hack_echo ()
{
    if [ "$quiet" != "yes" ]
    then
	echo "$*"
    fi
}

# Add any new auxiliary programs here.
AUX_PROGS="hyperbola ntl-history-view ntl-notes ntl-web-search ntl-web-browser nautilus-sample-content-view nautilus-hardware-view
bonobo-text-plain bonobo-image-generic gnome-vfs-slave nautilus-rpm-view nautilus-service-startup-view nautilus-mozilla-content-view bonobo-application-x-pdf nautilus-sidebar-loser nautilus-content-loser"

if [ "$extreme" = "yes" ]
then
    AUX_PROGS="oafd gconfd $AUX_PROGS"
fi

unset FOUND_ANY

for NAME in $AUX_PROGS; do

    EGREP_PATTERN=`echo $NAME | sed -e 's/\(.\)\(.*\)/[\1]\2/' | sed -e 's/\[\\\^\]/\[\\^\]/'`

    COUNT=`ps auxww | egrep $EGREP_PATTERN | grep -v emacs | wc -l`

    if [ $COUNT -gt 0 ]; then
	if [ -z $FOUND_ANY ]; then
	    hack_echo "Stale Processes Found"
	    FOUND_ANY=true
	fi
	hack_echo "$NAME: $COUNT"

	if [ "$quiet" != "yes" ]
	then
	    killall "$NAME"
	else
	    killall "$NAME" > /dev/null 2>&1
	fi
    fi
done


if [ -z $FOUND_ANY ]; then
    hack_echo "No Stale Processes Found"
    exit 0
fi

exit 0