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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
|
#!/bin/sh
#---------------------------------------------
# xdg-desktop-icon
#
# Utility script to install desktop items on a Linux desktop.
#
# Refer to the usage() function below for usage.
#
# Copyright 2009-2010, Fathi Boudra <fabo@freedesktop.org>
# Copyright 2009-2010, Rex Dieter <rdieter@fedoraproject.org>
# Copyright 2006, Kevin Krammer <kevin.krammer@gmx.at>
# Copyright 2006, Jeremy White <jwhite@codeweavers.com>
#
# LICENSE:
#
#---------------------------------------------
usage()
{
cat << _USAGE
_USAGE
}
manualpage()
{
cat << _MANUALPAGE
_MANUALPAGE
}
#@xdg-utils-common@
[ x"$1" != x"" ] || exit_failure_syntax
action=
desktop_file=
case $1 in
install)
action=install
;;
uninstall)
action=uninstall
;;
*)
exit_failure_syntax "unknown command '$1'"
;;
esac
shift
vendor=true
while [ $# -gt 0 ] ; do
parm=$1
shift
case $parm in
--novendor)
vendor=false
;;
-*)
exit_failure_syntax "unexpected option '$parm'"
;;
*)
if [ -n "$desktop_file" ] ; then
exit_failure_syntax "unexpected argument '$parm'"
fi
if [ "$action" = "install" ] ; then
check_input_file "$parm"
fi
desktop_file=$parm
;;
esac
done
# Shouldn't happen
if [ -z "$action" ] ; then
exit_failure_syntax "command argument missing"
fi
if [ -z "$desktop_file" ] ; then
exit_failure_syntax "FILE argument missing"
fi
filetype=
case "$desktop_file" in
*.desktop)
filetype=desktop
if [ "$vendor" = "true" -a "$action" = "install" ] ; then
check_vendor_prefix "$desktop_file"
fi
;;
*)
filetype=other
;;
esac
my_umask=077
desktop_dir="$HOME/Desktop"
if xdg-user-dir 2>/dev/null 1>&2; then
desktop_dir=`xdg-user-dir DESKTOP`
fi
desktop_dir_kde=`kde${KDE_SESSION_VERSION}-config --userpath desktop 2> /dev/null`
if gconftool-2 -g /apps/nautilus/preferences/desktop_is_home_dir 2> /dev/null | grep true > /dev/null; then
desktop_dir_gnome="$HOME"
# Don't create $HOME/Desktop if it doesn't exist
[ -w "$desktop_dir" ] || desktop_dir=
fi
if [ -n "$desktop_dir_kde" ]; then
if [ ! -d "$desktop_dir_kde" ]; then
save_umask=`umask`
umask $my_umask
mkdir -p "$desktop_dir_kde"
umask $save_umask
fi
# Is the KDE desktop dir != $HOME/Desktop ?
if [ "x`readlink -f "$desktop_dir"`" != "x`readlink -f "$desktop_dir_kde"`" ]; then
# If so, don't create $HOME/Desktop if it doesn't exist
[ -w "$desktop_dir" ] || desktop_dir=
else
desktop_dir_kde=
fi
fi
basefile=`basename "$desktop_file"`
DEBUG 1 "$action $desktop_file in $desktop_dir $desktop_dir_kde $desktop_dir_gnome"
case $action in
install)
save_umask=`umask`
umask $my_umask
for x in "$desktop_dir" "$desktop_dir_kde" "$desktop_dir_gnome" ; do
if [ -n "$x" ]; then
mkdir -p "$x"
eval 'cp "$desktop_file" "$x/$basefile"'$xdg_redirect_output
chmod u+x "$x/$basefile"
fi
done
umask $save_umask
;;
uninstall)
for x in "$desktop_dir" "$desktop_dir_kde" "$desktop_dir_gnome" ; do
if [ -n "$x" ]; then
rm -f "$x/$basefile"
fi
done
;;
esac
exit_success
|