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

Side by Side Diff: scripts/xdg-settings.in

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 | « scripts/xdg-settings ('k') | scripts/xdg-utils-common.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-settings 3 # xdg-settings
4 # 4 #
5 # Utility script to get various settings from the desktop environment. 5 # Utility script to get various settings from the desktop environment.
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, Google Inc. 9 # Copyright 2009, Google Inc.
10 # 10 #
(...skipping 26 matching lines...) Expand all
37 ;; 37 ;;
38 *) 38 *)
39 exit_failure_syntax "invalid application name" 39 exit_failure_syntax "invalid application name"
40 ;; 40 ;;
41 esac 41 esac
42 } 42 }
43 43
44 # {{{ default browser 44 # {{{ default browser
45 # {{{ utility functions 45 # {{{ utility functions
46 46
47 # This handles backslashes but not quote marks.
48 first_word()
49 {
50 read first rest
51 echo "$first"
52 }
53
54 binary_to_desktop_file()
55 {
56 search="${XDG_DATA_HOME:-$HOME/.local/share}:${XDG_DATA_DIRS:-/usr/local/sha re:/usr/share}"
57 binary="`which "$1"`"
58 binary="`readlink -f "$binary"`"
59 base="`basename "$binary"`"
60 IFS=:
61 for dir in $search; do
62 unset IFS
63 [ "$dir" ] || continue
64 [ -d "$dir/applications" -o -d "$dir/applnk" ] || continue
65 for file in "$dir"/applications/*.desktop "$dir"/applnk/*.desktop; do
66 [ -r "$file" ] || continue
67 # Check to make sure it's worth the processing.
68 grep -q "^Exec.*$base" "$file" || continue
69 # Make sure it's a visible desktop file (e.g. not "preferred-web-bro wser.desktop").
70 grep -Eq "^(NoDisplay|Hidden)=true" "$file" && continue
71 command="`grep -E "^Exec(\[[^]=]*])?=" "$file" | cut -d= -f 2- | fir st_word`"
72 command="`which "$command"`"
73 if [ x"`readlink -f "$command"`" = x"$binary" ]; then
74 # Fix any double slashes that got added path composition
75 echo "$file" | sed -e 's,//*,/,g'
76 return
77 fi
78 done
79 done
80 }
81
82 desktop_file_to_binary()
83 {
84 search="${XDG_DATA_HOME:-$HOME/.local/share}:${XDG_DATA_DIRS:-/usr/local/sha re:/usr/share}"
85 desktop="`basename "$1"`"
86 IFS=:
87 for dir in $search; do
88 unset IFS
89 [ "$dir" -a -d "$dir/applications" ] || continue
90 file="$dir/applications/$desktop"
91 [ -r "$file" ] || continue
92 # Remove any arguments (%F, %f, %U, %u, etc.).
93 command="`grep -E "^Exec(\[[^]=]*])?=" "$file" | cut -d= -f 2- | first_w ord`"
94 command="`which "$command"`"
95 readlink -f "$command"
96 return
97 done
98 }
99
100 # In order to remove an application from the automatically-generated list of 47 # In order to remove an application from the automatically-generated list of
101 # applications for handling a given MIME type, the desktop environment may copy 48 # applications for handling a given MIME type, the desktop environment may copy
102 # the global .desktop file into the user's .local directory, and remove that 49 # the global .desktop file into the user's .local directory, and remove that
103 # MIME type from its list. In that case, we must restore the MIME type to the 50 # MIME type from its list. In that case, we must restore the MIME type to the
104 # application's list of MIME types before we can set it as the default for that 51 # application's list of MIME types before we can set it as the default for that
105 # MIME type. (We can't just delete the local version, since the user may have 52 # MIME type. (We can't just delete the local version, since the user may have
106 # made other changes to it as well. So, tweak the existing file.) 53 # made other changes to it as well. So, tweak the existing file.)
107 # This function is hard-coded for text/html but it could be adapted if needed. 54 # This function is hard-coded for text/html but it could be adapted if needed.
108 fix_local_desktop_file() 55 fix_local_desktop_file()
109 { 56 {
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 ;; 555 ;;
609 556
610 generic) 557 generic)
611 dispatch_generic "$@" 558 dispatch_generic "$@"
612 ;; 559 ;;
613 560
614 *) 561 *)
615 exit_failure_operation_impossible "unknown desktop environment" 562 exit_failure_operation_impossible "unknown desktop environment"
616 ;; 563 ;;
617 esac 564 esac
OLDNEW
« no previous file with comments | « scripts/xdg-settings ('k') | scripts/xdg-utils-common.in » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698