summaryrefslogtreecommitdiff
path: root/capplets/default-applications/mate-at-commandline.in.in
blob: f9d93b164153c26e6cc0ae6c9d19695b8f92d5e1 (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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/bin/sh
#
#  Copyright 2006 IBM Corp.
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of version 2 of the GNU General Public License
#  as published by the Free Software Foundation
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
#
###############################################################################
#
#  NOTE: This script is intended to be run from the command line,
#  MATE menu, or from the desktop autostart.
#
#  /usr/bin/mate-at-visual
#  /usr/bin/mate-at-mobility
#
#  If the "-s" flag is used then it is assumed to have been invoked
#  from /usr/share/mate/autostart/, and the first AT flagged
#  to "startup" from MATECONF_ALL will be executed.
#

USAGE="$0 [-s]"
MATECONF_PATH=/desktop/mate/applications/at
MATECONF_VISUAL="visual"
MATECONF_MOBILITY="mobility"
MATECONF_ALL="$MATECONF_VISUAL $MATECONF_MOBILITY"

run_at() {
	CMDLINE=`mateconftool-2 --get $MATECONF_PATH/$1/exec`
	if [ $? -ne 0 ]; then
		exit $?
	fi

	if [ -z "$CMDLINE" ]; then
		exit 2
	fi

	STARTUP=`mateconftool-2 --get $MATECONF_PATH/$1/startup`
	if [ $? -ne 0 ]; then
		exit $?
	fi

	if [ ! -z "$AUTOSTART" ]; then
		# assuming ran from /usr/share/mate/autostart
		if [ "x$STARTUP" = "xtrue" ]; then
			# mateconf indicated requested autostart
			($CMDLINE &)
		fi
	else
		# run from command line or desktop menu
		($CMDLINE &)
	fi
}

case `basename $0` in
	mate-at-visual )
		AT=$MATECONF_VISUAL
		;;
	mate-at-mobility )
		AT=$MATECONF_MOBILITY
		;;
	mate-at-session | * )
		AUTOSTART="yes"
		AT=$MATECONF_ALL
		;;
esac

while getopts "s" options; do
	case $options in
		s )	AUTOSTART="yes"
			AT=$MATECONF_ALL
			shift
			;;
		\? )	echo $USAGE
			exit 1
			;;
		* )	echo $USAGE
			exit 1
			;;
	esac
done

if [ $# -ne 0 ]; then
	echo $USAGE
	exit 1
fi

for I in $AT ; do
	run_at $I
done

#EOF