Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Side by Side Diff: scripts/xdg-desktop-icon

Issue 6928018: Linux: update xdg-utils to the latest git version and include a one-line fix in xdg-mime. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/xdg-utils/
Patch Set: '' Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « README.chromium ('k') | scripts/xdg-desktop-icon.in » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/bin/sh 1 #!/bin/sh
2 #--------------------------------------------- 2 #---------------------------------------------
3 # xdg-desktop-icon 3 # xdg-desktop-icon
4 # 4 #
5 # Utility script to install desktop items on a Linux desktop. 5 # Utility script to install desktop items on a Linux desktop.
6 # 6 #
7 # Refer to the usage() function below for usage. 7 # Refer to the usage() function below for usage.
8 # 8 #
9 # Copyright 2009-2010, Fathi Boudra <fabo@freedesktop.org> 9 # Copyright 2009-2010, Fathi Boudra <fabo@freedesktop.org>
10 # Copyright 2009-2010, Rex Dieter <rdieter@fedoraproject.org> 10 # Copyright 2009-2010, Rex Dieter <rdieter@fedoraproject.org>
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 #---------------------------------------------------------------------------- 215 #----------------------------------------------------------------------------
216 216
217 DEBUG() 217 DEBUG()
218 { 218 {
219 [ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && return 0; 219 [ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && return 0;
220 [ ${XDG_UTILS_DEBUG_LEVEL} -lt $1 ] && return 0; 220 [ ${XDG_UTILS_DEBUG_LEVEL} -lt $1 ] && return 0;
221 shift 221 shift
222 echo "$@" >&2 222 echo "$@" >&2
223 } 223 }
224 224
225 # This handles backslashes but not quote marks.
226 first_word()
227 {
228 read first rest
229 echo "$first"
230 }
231
232 #-------------------------------------------------------------
233 # map a binary to a .desktop file
234 binary_to_desktop_file()
235 {
236 search="${XDG_DATA_HOME:-$HOME/.local/share}:${XDG_DATA_DIRS:-/usr/local/sha re:/usr/share}"
237 binary="`which "$1"`"
238 binary="`readlink -f "$binary"`"
239 base="`basename "$binary"`"
240 IFS=:
241 for dir in $search; do
242 unset IFS
243 [ "$dir" ] || continue
244 [ -d "$dir/applications" -o -d "$dir/applnk" ] || continue
245 for file in "$dir"/applications/*.desktop "$dir"/applications/*/*.deskto p "$dir"/applnk/*.desktop "$dir"/applnk/*/*.desktop; do
246 [ -r "$file" ] || continue
247 # Check to make sure it's worth the processing.
248 grep -q "^Exec.*$base" "$file" || continue
249 # Make sure it's a visible desktop file (e.g. not "preferred-web-bro wser.desktop").
250 grep -Eq "^(NoDisplay|Hidden)=true" "$file" && continue
251 command="`grep -E "^Exec(\[[^]=]*])?=" "$file" | cut -d= -f 2- | fir st_word`"
252 command="`which "$command"`"
253 if [ x"`readlink -f "$command"`" = x"$binary" ]; then
254 # Fix any double slashes that got added path composition
255 echo "$file" | sed -e 's,//*,/,g'
256 return
257 fi
258 done
259 done
260 }
261
262 #-------------------------------------------------------------
263 # map a .desktop file to a binary
264 ## FIXME: handle vendor dir case
265 desktop_file_to_binary()
266 {
267 search="${XDG_DATA_HOME:-$HOME/.local/share}:${XDG_DATA_DIRS:-/usr/local/sha re:/usr/share}"
268 desktop="`basename "$1"`"
269 IFS=:
270 for dir in $search; do
271 unset IFS
272 [ "$dir" -a -d "$dir/applications" ] || continue
273 file="$dir/applications/$desktop"
274 [ -r "$file" ] || continue
275 # Remove any arguments (%F, %f, %U, %u, etc.).
276 command="`grep -E "^Exec(\[[^]=]*])?=" "$file" | cut -d= -f 2- | first_w ord`"
277 command="`which "$command"`"
278 readlink -f "$command"
279 return
280 done
281 }
282
225 #------------------------------------------------------------- 283 #-------------------------------------------------------------
226 # Exit script on successfully completing the desired operation 284 # Exit script on successfully completing the desired operation
227 285
228 exit_success() 286 exit_success()
229 { 287 {
230 if [ $# -gt 0 ]; then 288 if [ $# -gt 0 ]; then
231 echo "$@" 289 echo "$@"
232 echo 290 echo
233 fi 291 fi
234 292
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 [ -w "$desktop_dir" ] || desktop_dir= 601 [ -w "$desktop_dir" ] || desktop_dir=
544 fi 602 fi
545 if [ -n "$desktop_dir_kde" ]; then 603 if [ -n "$desktop_dir_kde" ]; then
546 if [ ! -d "$desktop_dir_kde" ]; then 604 if [ ! -d "$desktop_dir_kde" ]; then
547 save_umask=`umask` 605 save_umask=`umask`
548 umask $my_umask 606 umask $my_umask
549 mkdir -p "$desktop_dir_kde" 607 mkdir -p "$desktop_dir_kde"
550 umask $save_umask 608 umask $save_umask
551 fi 609 fi
552 # Is the KDE desktop dir != $HOME/Desktop ? 610 # Is the KDE desktop dir != $HOME/Desktop ?
553 if [ x`readlink -f "$desktop_dir"` != x`readlink -f "$desktop_dir_kde"` ]; t hen 611 if [ "x`readlink -f "$desktop_dir"`" != "x`readlink -f "$desktop_dir_kde"`" ]; then
554 # If so, don't create $HOME/Desktop if it doesn't exist 612 # If so, don't create $HOME/Desktop if it doesn't exist
555 [ -w "$desktop_dir" ] || desktop_dir= 613 [ -w "$desktop_dir" ] || desktop_dir=
556 else 614 else
557 desktop_dir_kde= 615 desktop_dir_kde=
558 fi 616 fi
559 fi 617 fi
560 618
561 basefile=`basename "$desktop_file"` 619 basefile=`basename "$desktop_file"`
562 620
563 DEBUG 1 "$action $desktop_file in $desktop_dir $desktop_dir_kde $desktop_dir_gno me" 621 DEBUG 1 "$action $desktop_file in $desktop_dir $desktop_dir_kde $desktop_dir_gno me"
(...skipping 20 matching lines...) Expand all
584 rm -f "$x/$basefile" 642 rm -f "$x/$basefile"
585 fi 643 fi
586 done 644 done
587 645
588 ;; 646 ;;
589 esac 647 esac
590 648
591 exit_success 649 exit_success
592 650
593 651
OLDNEW
« no previous file with comments | « README.chromium ('k') | scripts/xdg-desktop-icon.in » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698