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

Side by Side Diff: scripts/xdg-utils-common.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.in ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 #---------------------------------------------------------------------------- 2 #----------------------------------------------------------------------------
3 # Common utility functions included in all XDG wrapper scripts 3 # Common utility functions included in all XDG wrapper scripts
4 #---------------------------------------------------------------------------- 4 #----------------------------------------------------------------------------
5 5
6 DEBUG() 6 DEBUG()
7 { 7 {
8 [ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && return 0; 8 [ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && return 0;
9 [ ${XDG_UTILS_DEBUG_LEVEL} -lt $1 ] && return 0; 9 [ ${XDG_UTILS_DEBUG_LEVEL} -lt $1 ] && return 0;
10 shift 10 shift
11 echo "$@" >&2 11 echo "$@" >&2
12 } 12 }
13 13
14 # This handles backslashes but not quote marks.
15 first_word()
16 {
17 read first rest
18 echo "$first"
19 }
20
21 #-------------------------------------------------------------
22 # map a binary to a .desktop file
23 binary_to_desktop_file()
24 {
25 search="${XDG_DATA_HOME:-$HOME/.local/share}:${XDG_DATA_DIRS:-/usr/local/sha re:/usr/share}"
26 binary="`which "$1"`"
27 binary="`readlink -f "$binary"`"
28 base="`basename "$binary"`"
29 IFS=:
30 for dir in $search; do
31 unset IFS
32 [ "$dir" ] || continue
33 [ -d "$dir/applications" -o -d "$dir/applnk" ] || continue
34 for file in "$dir"/applications/*.desktop "$dir"/applications/*/*.deskto p "$dir"/applnk/*.desktop "$dir"/applnk/*/*.desktop; do
35 [ -r "$file" ] || continue
36 # Check to make sure it's worth the processing.
37 grep -q "^Exec.*$base" "$file" || continue
38 # Make sure it's a visible desktop file (e.g. not "preferred-web-bro wser.desktop").
39 grep -Eq "^(NoDisplay|Hidden)=true" "$file" && continue
40 command="`grep -E "^Exec(\[[^]=]*])?=" "$file" | cut -d= -f 2- | fir st_word`"
41 command="`which "$command"`"
42 if [ x"`readlink -f "$command"`" = x"$binary" ]; then
43 # Fix any double slashes that got added path composition
44 echo "$file" | sed -e 's,//*,/,g'
45 return
46 fi
47 done
48 done
49 }
50
51 #-------------------------------------------------------------
52 # map a .desktop file to a binary
53 ## FIXME: handle vendor dir case
54 desktop_file_to_binary()
55 {
56 search="${XDG_DATA_HOME:-$HOME/.local/share}:${XDG_DATA_DIRS:-/usr/local/sha re:/usr/share}"
57 desktop="`basename "$1"`"
58 IFS=:
59 for dir in $search; do
60 unset IFS
61 [ "$dir" -a -d "$dir/applications" ] || continue
62 file="$dir/applications/$desktop"
63 [ -r "$file" ] || continue
64 # Remove any arguments (%F, %f, %U, %u, etc.).
65 command="`grep -E "^Exec(\[[^]=]*])?=" "$file" | cut -d= -f 2- | first_w ord`"
66 command="`which "$command"`"
67 readlink -f "$command"
68 return
69 done
70 }
71
14 #------------------------------------------------------------- 72 #-------------------------------------------------------------
15 # Exit script on successfully completing the desired operation 73 # Exit script on successfully completing the desired operation
16 74
17 exit_success() 75 exit_success()
18 { 76 {
19 if [ $# -gt 0 ]; then 77 if [ $# -gt 0 ]; then
20 echo "$@" 78 echo "$@"
21 echo 79 echo
22 fi 80 fi
23 81
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 { 301 {
244 version=`LC_ALL=C.UTF-8 kde-config --version 2>/dev/null | grep '^KDE'` 302 version=`LC_ALL=C.UTF-8 kde-config --version 2>/dev/null | grep '^KDE'`
245 major=`echo $version | sed 's/KDE.*: \([0-9]\).*/\1/'` 303 major=`echo $version | sed 's/KDE.*: \([0-9]\).*/\1/'`
246 minor=`echo $version | sed 's/KDE.*: [0-9]*\.\([0-9]\).*/\1/'` 304 minor=`echo $version | sed 's/KDE.*: [0-9]*\.\([0-9]\).*/\1/'`
247 release=`echo $version | sed 's/KDE.*: [0-9]*\.[0-9]*\.\([0-9]\).*/\1/'` 305 release=`echo $version | sed 's/KDE.*: [0-9]*\.[0-9]*\.\([0-9]\).*/\1/'`
248 test "$major" -gt 3 && return $1 306 test "$major" -gt 3 && return $1
249 test "$minor" -gt 5 && return $1 307 test "$minor" -gt 5 && return $1
250 test "$release" -gt 4 && return $1 308 test "$release" -gt 4 && return $1
251 return 0 309 return 0
252 } 310 }
OLDNEW
« no previous file with comments | « scripts/xdg-settings.in ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698