~saiarcot895/ubuntu/wily/xdg-utils/fix-multiple-execs

« back to all changes in this revision

Viewing changes to scripts/xdg-desktop-icon.in

  • Committer: Package Import Robot
  • Author(s): Per Olofsson
  • Date: 2011-12-12 12:04:25 UTC
  • mfrom: (1.2.8)
  • mto: This revision was merged to the branch mainline in revision 34.
  • Revision ID: package-import@ubuntu.com-20111212120425-0rdnrl8tn45vz171
Tags: 1.1.0~rc1+git20111210-1
* New upstream git snapshot b961235b197647d6649ef3d48d7cc2cecafe3d47.
* Drop patches applied upstream:
  - xdg-mime-follow-symlinks.diff
  - x-www-browser.diff
  - xdg-mime-generic-use-mimetype.diff
  - bashisms.diff
  - xdg-screensaver-check-gnome.diff
* Modify patches to make changes to scripts/xdg-*.in, instead of the
  generated scripts.
* Also check for ~/.mutt/muttrc when deciding whether to use mutt as
  MUA or not. Thanks to martin f krafft. Closes: #648733.
* Build scripts/xdg-* from *.in files.
* Build-depend on xmlto and awk, as they are needed when building the
  scripts.
* Also build the manual pages.
* Bump Standards-Version to 3.9.2. No changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
#---------------------------------------------
 
3
#   xdg-desktop-icon
 
4
#
 
5
#   Utility script to install desktop items on a Linux desktop.
 
6
#
 
7
#   Refer to the usage() function below for usage.
 
8
#
 
9
#   Copyright 2009-2010, Fathi Boudra <fabo@freedesktop.org>
 
10
#   Copyright 2009-2010, Rex Dieter <rdieter@fedoraproject.org>
 
11
#   Copyright 2006, Kevin Krammer <kevin.krammer@gmx.at>
 
12
#   Copyright 2006, Jeremy White <jwhite@codeweavers.com>
 
13
#
 
14
#   LICENSE:
 
15
#
 
16
#---------------------------------------------
 
17
 
 
18
usage()
 
19
{
 
20
cat << _USAGE
 
21
_USAGE
 
22
}
 
23
 
 
24
manualpage()
 
25
{
 
26
cat << _MANUALPAGE
 
27
_MANUALPAGE
 
28
}
 
29
 
 
30
#@xdg-utils-common@
 
31
 
 
32
[ x"$1" != x"" ] || exit_failure_syntax
 
33
 
 
34
action=
 
35
desktop_file=
 
36
 
 
37
case $1 in
 
38
  install)
 
39
    action=install
 
40
    ;;
 
41
 
 
42
  uninstall)
 
43
    action=uninstall
 
44
    ;;
 
45
 
 
46
  *)
 
47
    exit_failure_syntax "unknown command '$1'"
 
48
    ;;
 
49
esac
 
50
 
 
51
shift
 
52
 
 
53
vendor=true
 
54
while [ $# -gt 0 ] ; do
 
55
    parm=$1
 
56
    shift
 
57
 
 
58
    case $parm in
 
59
      --novendor)
 
60
        vendor=false
 
61
        ;;
 
62
 
 
63
      -*)
 
64
        exit_failure_syntax "unexpected option '$parm'"
 
65
        ;;
 
66
 
 
67
      *)
 
68
        if [ -n "$desktop_file" ] ; then
 
69
            exit_failure_syntax "unexpected argument '$parm'"
 
70
        fi
 
71
        if [ "$action" = "install" ] ; then
 
72
            check_input_file "$parm"
 
73
        fi
 
74
        desktop_file=$parm
 
75
        ;;
 
76
    esac
 
77
done
 
78
 
 
79
# Shouldn't happen
 
80
if [ -z "$action" ] ; then
 
81
    exit_failure_syntax "command argument missing"
 
82
fi
 
83
 
 
84
if [ -z "$desktop_file" ] ; then
 
85
    exit_failure_syntax "FILE argument missing"
 
86
fi
 
87
 
 
88
filetype=
 
89
case "$desktop_file" in
 
90
  *.desktop)
 
91
     filetype=desktop
 
92
     if [ "$vendor" = "true" -a "$action" = "install" ] ; then
 
93
        check_vendor_prefix "$desktop_file"
 
94
     fi
 
95
     ;;
 
96
  *)
 
97
     filetype=other
 
98
     ;;
 
99
esac
 
100
 
 
101
my_umask=077
 
102
desktop_dir="$HOME/Desktop"
 
103
if xdg-user-dir 2>/dev/null 1>&2; then
 
104
  desktop_dir=`xdg-user-dir DESKTOP`
 
105
fi
 
106
desktop_dir_kde=`kde${KDE_SESSION_VERSION}-config --userpath desktop 2> /dev/null`
 
107
if gconftool-2 -g /apps/nautilus/preferences/desktop_is_home_dir 2> /dev/null | grep true > /dev/null; then
 
108
    desktop_dir_gnome="$HOME"
 
109
    # Don't create $HOME/Desktop if it doesn't exist
 
110
    [ -w "$desktop_dir" ] || desktop_dir=
 
111
fi
 
112
if [ -n "$desktop_dir_kde" ]; then
 
113
    if [ ! -d "$desktop_dir_kde" ]; then
 
114
        save_umask=`umask`
 
115
        umask $my_umask
 
116
        mkdir -p "$desktop_dir_kde"
 
117
        umask $save_umask
 
118
    fi
 
119
    # Is the KDE desktop dir != $HOME/Desktop ?
 
120
    if [ "x`readlink -f "$desktop_dir"`" != "x`readlink -f "$desktop_dir_kde"`" ]; then
 
121
        # If so, don't create $HOME/Desktop if it doesn't exist
 
122
        [ -w "$desktop_dir" ] || desktop_dir=
 
123
    else
 
124
        desktop_dir_kde=
 
125
    fi
 
126
fi
 
127
 
 
128
basefile=`basename "$desktop_file"`
 
129
 
 
130
DEBUG 1 "$action $desktop_file in $desktop_dir $desktop_dir_kde $desktop_dir_gnome"
 
131
 
 
132
case $action in
 
133
    install)
 
134
        save_umask=`umask`
 
135
        umask $my_umask
 
136
 
 
137
        for x in "$desktop_dir" "$desktop_dir_kde" "$desktop_dir_gnome" ; do
 
138
            if [ -n "$x" ]; then
 
139
                mkdir -p "$x"
 
140
                eval 'cp "$desktop_file" "$x/$basefile"'$xdg_redirect_output 
 
141
                chmod u+x "$x/$basefile"
 
142
            fi
 
143
        done
 
144
 
 
145
        umask $save_umask
 
146
        ;;
 
147
 
 
148
    uninstall)
 
149
        for x in "$desktop_dir" "$desktop_dir_kde" "$desktop_dir_gnome" ; do
 
150
            if [ -n "$x" ]; then
 
151
                rm -f "$x/$basefile"
 
152
            fi
 
153
        done
 
154
 
 
155
        ;;
 
156
esac
 
157
 
 
158
exit_success
 
159
 
 
160