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

Side by Side Diff: third_party/xdg-utils/scripts/xdg-icon-resource

Issue 151098: Patch from mdm@google.com... (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/
Patch Set: Created 11 years, 5 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
Property Changes:
Name: svn:executable
+ *
OLDNEW
(Empty)
1 #!/bin/sh
2 #---------------------------------------------
3 # xdg-icon-resource
4 #
5 # Utility script to install icons on a Linux desktop.
6 #
7 # Refer to the usage() function below for usage.
8 #
9 # Copyright 2006, Kevin Krammer <kevin.krammer@gmx.at>
10 # Copyright 2006, Jeremy White <jwhite@codeweavers.com>
11 #
12 # LICENSE:
13 #
14 # Permission is hereby granted, free of charge, to any person obtaining a
15 # copy of this software and associated documentation files (the "Software"),
16 # to deal in the Software without restriction, including without limitation
17 # the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 # and/or sell copies of the Software, and to permit persons to whom the
19 # Software is furnished to do so, subject to the following conditions:
20 #
21 # The above copyright notice and this permission notice shall be included
22 # in all copies or substantial portions of the Software.
23 #
24 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
28 # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
29 # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
30 # OTHER DEALINGS IN THE SOFTWARE.
31 #
32 #---------------------------------------------
33
34 manualpage()
35 {
36 cat << _MANUALPAGE
37 Name
38
39 xdg-icon-resource - command line tool for (un)installing icon resources
40
41 Synopsis
42
43 xdg-icon-resource install [--noupdate] [--novendor] [--theme theme] [--context
44 context] [--mode mode] --size size icon-file [icon-name]
45
46 xdg-icon-resource uninstall [--noupdate] [--theme theme] [--context context]
47 [--mode mode] --size size icon-name
48
49 xdg-icon-resource forceupdate [--theme theme] [--mode mode]
50
51 xdg-icon-resource { --help | --manual | --version }
52
53 Description
54
55 The xdg-icon-resource program can be used to install icon resources into the
56 desktop icon system in order to illustrate menu entries, to depict desktop
57 icons or to graphically represent file types.
58
59 The desktop icon system identifies icons by name. Depending on the required
60 size, the choice of icon theme and the context in which the icon is used, the
61 desktop icon system locates an appropriate icon resource to depict an icon.
62 Icon resources can be XPM files or PNG files.
63
64 The desktop icon system works according to the XDG Icon Theme Specification at
65 http://www.freedesktop.org/Standards/icon-theme-spec
66
67 Commands
68
69 install
70 Installs the icon file indicated by icon-file to the desktop icon system
71 under the name icon-name. Icon names do not have an extension. If icon-name
72 is not provided the name is derived from icon-file. The icon file must have
73 .png or .xpm as extension. If a corresponding .icon file exists in the same
74 location as icon-file it will be installed as well.
75 uninstall
76 Removes the icon indicated by icon-name from the desktop icon system. Note
77 that icon names do not have an extension.
78 forceupdate
79 Force an update of the desktop icon system. This is only useful if the last
80 call to xdg-icon-resource included the --noupdate option.
81
82 Options
83
84 --noupdate
85 Postpone updating the desktop icon system. If multiple icons are added in
86 sequence this flag can be used to indicate that additional changes will
87 follow and that it is not necassery to update the desktop icon system right
88 away.
89 --novendor
90
91 Normally, xdg-icon-resource checks to ensure that an icon file to be
92 installed in the apps context has a proper vendor prefix. This option can
93 be used to disable that check.
94
95 A vendor prefix consists of alpha characters ([a-zA-Z]) and is terminated
96 with a dash ("-"). Companies and organizations are encouraged to use a word
97 or phrase, preferably the organizations name, for which they hold a
98 trademark as their vendor prefix. The purpose of the vendor prefix is to
99 prevent name conflicts.
100
101 --theme theme
102 Installs or removes the icon file as part of theme. If no theme is
103 specified the icons will be installed as part of the default hicolor theme.
104 Applications may install icons under multiple themes but should at least
105 install icons for the default hicolor theme.
106 --context context
107 Specifies the context for the icon. Icons to be used in the application
108 menu and as desktop icon should use apps as context which is the default
109 context. Icons to be used as file icons should use mimetypes as context.
110 Other common contexts are actions, devices, emblems, filesystems and stock.
111 --size size
112 Specifies the size of the icon. All icons must be square. Common sizes for
113 icons in the apps context are: 16, 22, 32, 48, 64 and 128. Common sizes for
114 icons in the mimetypes context are: 16, 22, 32, 48, 64 and 128
115 --mode mode
116
117 mode can be user or system. In user mode the file is (un)installed for the
118 current user only. In system mode the file is (un)installed for all users
119 on the system. Usually only root is allowed to install in system mode.
120
121 The default is to use system mode when called by root and to use user mode
122 when called by a non-root user.
123
124 --help
125 Show command synopsis.
126 --manual
127 Show this manualpage.
128 --version
129 Show the xdg-utils version information.
130
131 Environment Variables
132
133 xdg-icon-resource honours the following environment variables:
134
135 XDG_UTILS_DEBUG_LEVEL
136 Setting this environment variable to a non-zero numerical value makes
137 xdg-icon-resource do more verbose reporting on stderr. Setting a higher
138 value increases the verbosity.
139 XDG_UTILS_INSTALL_MODE
140 This environment variable can be used by the user or administrator to
141 override the installation mode. Valid values are user and system.
142
143 Exit Codes
144
145 An exit code of 0 indicates success while a non-zero exit code indicates
146 failure. The following failure codes can be returned:
147
148 1
149 Error in command line syntax.
150 2
151 One of the files passed on the command line did not exist.
152 3
153 A required tool could not be found.
154 4
155 The action failed.
156 5
157 No permission to read one of the files passed on the command line.
158
159 See Also
160
161 xdg-desktop-icon(1), xdg-desktop-menu(1), xdg-mime(1)
162
163 Examples
164
165 To install an icon resource to depict a launcher for the application myfoobar,
166 the company ShinyThings Inc. can use:
167
168 xdg-icon-resource install --size 64 shinythings-myfoobar.png
169
170 To install an icon for a new application/x-foobar file type one can use:
171
172 xdg-icon-resource install --context mimetypes --size 48 ./mime-foobar-48.png app lication-x-foobar
173 xdg-icon-resource install --context mimetypes --size 64 ./mime-foobar-64.png app lication-x-foobar
174
175 This will install two icons with the name application-x-foobar but with
176 different sizes.
177
178 _MANUALPAGE
179 }
180
181 usage()
182 {
183 cat << _USAGE
184 xdg-icon-resource - command line tool for (un)installing icon resources
185
186 Synopsis
187
188 xdg-icon-resource install [--noupdate] [--novendor] [--theme theme] [--context
189 context] [--mode mode] --size size icon-file [icon-name]
190
191 xdg-icon-resource uninstall [--noupdate] [--theme theme] [--context context]
192 [--mode mode] --size size icon-name
193
194 xdg-icon-resource forceupdate [--theme theme] [--mode mode]
195
196 xdg-icon-resource { --help | --manual | --version }
197
198 _USAGE
199 }
200
201 #@xdg-utils-common@
202
203 #----------------------------------------------------------------------------
204 # Common utility functions included in all XDG wrapper scripts
205 #----------------------------------------------------------------------------
206
207 DEBUG()
208 {
209 [ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && return 0;
210 [ ${XDG_UTILS_DEBUG_LEVEL} -lt $1 ] && return 0;
211 shift
212 echo "$@" >&2
213 }
214
215 #-------------------------------------------------------------
216 # Exit script on successfully completing the desired operation
217
218 exit_success()
219 {
220 if [ $# -gt 0 ]; then
221 echo "$@"
222 echo
223 fi
224
225 exit 0
226 }
227
228
229 #-----------------------------------------
230 # Exit script on malformed arguments, not enough arguments
231 # or missing required option.
232 # prints usage information
233
234 exit_failure_syntax()
235 {
236 if [ $# -gt 0 ]; then
237 echo "xdg-icon-resource: $@" >&2
238 echo "Try 'xdg-icon-resource --help' for more information." >&2
239 else
240 usage
241 echo "Use 'man xdg-icon-resource' or 'xdg-icon-resource --manual' for ad ditional info."
242 fi
243
244 exit 1
245 }
246
247 #-------------------------------------------------------------
248 # Exit script on missing file specified on command line
249
250 exit_failure_file_missing()
251 {
252 if [ $# -gt 0 ]; then
253 echo "xdg-icon-resource: $@" >&2
254 fi
255
256 exit 2
257 }
258
259 #-------------------------------------------------------------
260 # Exit script on failure to locate necessary tool applications
261
262 exit_failure_operation_impossible()
263 {
264 if [ $# -gt 0 ]; then
265 echo "xdg-icon-resource: $@" >&2
266 fi
267
268 exit 3
269 }
270
271 #-------------------------------------------------------------
272 # Exit script on failure returned by a tool application
273
274 exit_failure_operation_failed()
275 {
276 if [ $# -gt 0 ]; then
277 echo "xdg-icon-resource: $@" >&2
278 fi
279
280 exit 4
281 }
282
283 #------------------------------------------------------------
284 # Exit script on insufficient permission to read a specified file
285
286 exit_failure_file_permission_read()
287 {
288 if [ $# -gt 0 ]; then
289 echo "xdg-icon-resource: $@" >&2
290 fi
291
292 exit 5
293 }
294
295 #------------------------------------------------------------
296 # Exit script on insufficient permission to read a specified file
297
298 exit_failure_file_permission_write()
299 {
300 if [ $# -gt 0 ]; then
301 echo "xdg-icon-resource: $@" >&2
302 fi
303
304 exit 6
305 }
306
307 check_input_file()
308 {
309 if [ ! -e "$1" ]; then
310 exit_failure_file_missing "file '$1' does not exist"
311 fi
312 if [ ! -r "$1" ]; then
313 exit_failure_file_permission_read "no permission to read file '$1'"
314 fi
315 }
316
317 check_vendor_prefix()
318 {
319 file_label="$2"
320 [ -n "$file_label" ] || file_label="filename"
321 file=`basename "$1"`
322 case "$file" in
323 [a-zA-Z]*-*)
324 return
325 ;;
326 esac
327
328 echo "xdg-icon-resource: $file_label '$file' does not have a proper vendor p refix" >&2
329 echo 'A vendor prefix consists of alpha characters ([a-zA-Z]) and is termina ted' >&2
330 echo 'with a dash ("-"). An example '"$file_label"' is '"'example-$file'" >& 2
331 echo "Use --novendor to override or 'xdg-icon-resource --manual' for additio nal info." >&2
332 exit 1
333 }
334
335 check_output_file()
336 {
337 # if the file exists, check if it is writeable
338 # if it does not exists, check if we are allowed to write on the directory
339 if [ -e "$1" ]; then
340 if [ ! -w "$1" ]; then
341 exit_failure_file_permission_write "no permission to write to file ' $1'"
342 fi
343 else
344 DIR=`dirname "$1"`
345 if [ ! -w "$DIR" -o ! -x "$DIR" ]; then
346 exit_failure_file_permission_write "no permission to create file '$1 '"
347 fi
348 fi
349 }
350
351 #----------------------------------------
352 # Checks for shared commands, e.g. --help
353
354 check_common_commands()
355 {
356 while [ $# -gt 0 ] ; do
357 parm="$1"
358 shift
359
360 case "$parm" in
361 --help)
362 usage
363 echo "Use 'man xdg-icon-resource' or 'xdg-icon-resource --manual' fo r additional info."
364 exit_success
365 ;;
366
367 --manual)
368 manualpage
369 exit_success
370 ;;
371
372 --version)
373 echo "xdg-icon-resource 1.0.1"
374 exit_success
375 ;;
376 esac
377 done
378 }
379
380 check_common_commands "$@"
381
382 [ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && unset XDG_UTILS_DEBUG_LEVEL;
383 if [ ${XDG_UTILS_DEBUG_LEVEL-0} -lt 1 ]; then
384 # Be silent
385 xdg_redirect_output=" > /dev/null 2> /dev/null"
386 else
387 # All output to stderr
388 xdg_redirect_output=" >&2"
389 fi
390
391 #--------------------------------------
392 # Checks for known desktop environments
393 # set variable DE to the desktop environments name, lowercase
394
395 detectDE()
396 {
397 if [ x"$KDE_FULL_SESSION" = x"true" ]; then DE=kde;
398 elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE=gnome;
399 elif xprop -root _DT_SAVE_MODE | grep ' = \"xfce4\"$' >/dev/null 2>&1; then DE=xfce;
400 fi
401 }
402
403 #----------------------------------------------------------------------------
404 # kfmclient exec/openURL can give bogus exit value in KDE <= 3.5.4
405 # It also always returns 1 in KDE 3.4 and earlier
406 # Simply return 0 in such case
407
408 kfmclient_fix_exit_code()
409 {
410 version=`kde${KDE_SESSION_VERSION}-config --version 2>/dev/null | grep KDE`
411 major=`echo $version | sed 's/KDE: \([0-9]\).*/\1/'`
412 minor=`echo $version | sed 's/KDE: [0-9]*\.\([0-9]\).*/\1/'`
413 release=`echo $version | sed 's/KDE: [0-9]*\.[0-9]*\.\([0-9]\).*/\1/'`
414 test "$major" -gt 3 && return $1
415 test "$minor" -gt 5 && return $1
416 test "$release" -gt 4 && return $1
417 return 0
418 }
419
420 # Set GTK_UPDATE_ICON_CACHE to gtk-update-icon-cache executable path or
421 # to "-" if not found.
422 GTK_UPDATE_ICON_CACHE=
423 find_gtk_update_icon_cache()
424 {
425 [ -n "$GTK_UPDATE_ICON_CACHE" ] && return;
426
427 GTK_UPDATE_ICON_CACHE="-"
428 for x in `echo "$PATH:/opt/gnome/bin" | sed 's/:/ /g'`; do
429 DEBUG 3 "Checking $x for gtk-update-icon-cache"
430 if [ -x "$x/gtk-update-icon-cache" ] ; then
431 DEBUG 1 "Found $x/gtk-update-icon-cache"
432 GTK_UPDATE_ICON_CACHE="$x/gtk-update-icon-cache"
433 return
434 fi
435 done
436 }
437
438 # Start GNOME legacy workaround section
439 need_dot_icon_path()
440 {
441 # GTK < 2.6 uses ~/.icons but not XDG_DATA_HOME/icons
442 # The availability of gtk-update-icon-cache is used as indication
443 # of whether the system is using GTK 2.6 or later
444 find_gtk_update_icon_cache
445 [ "$GTK_UPDATE_ICON_CACHE" != "-" ] && return 1;
446 return 0;
447 }
448
449 update_icon_database()
450 {
451 # Touch me, I'm dirty
452 touch "$1/.xdg-icon-resource-dummy"
453 rm -f "$1/.xdg-icon-resource-dummy"
454
455 # Don't create a cache if there wan't one already
456 if [ -f "$1/icon-theme.cache" ] ; then
457 find_gtk_update_icon_cache
458 if [ "$GTK_UPDATE_ICON_CACHE" != "-" ] ; then
459 DEBUG 1 "Running $GTK_UPDATE_ICON_CACHE -f -t \"$1\""
460 eval '$GTK_UPDATE_ICON_CACHE -f -t "$1"'$xdg_redirect_output
461 return
462 fi
463 fi
464 }
465
466 [ x"$1" != x"" ] || exit_failure_syntax
467
468 mode=
469 action=
470 update=yes
471 size=
472 theme=hicolor
473 context=apps
474 icon_file=
475 icon_name=
476
477 case $1 in
478 install)
479 action=install
480 ;;
481
482 uninstall)
483 action=uninstall
484 ;;
485
486 forceupdate)
487 action=forceupdate
488 ;;
489
490 *)
491 exit_failure_syntax "unknown command '$1'"
492 ;;
493 esac
494
495 shift
496
497 vendor=true
498 while [ $# -gt 0 ] ; do
499 parm="$1"
500 shift
501
502 case $parm in
503 --noupdate)
504 update=no
505 ;;
506
507 --mode)
508 if [ -z "$1" ] ; then
509 exit_failure_syntax "mode argument missing for --mode"
510 fi
511 case "$1" in
512 user)
513 mode="user"
514 ;;
515
516 system)
517 mode="system"
518 ;;
519
520 *)
521 exit_failure_syntax "unknown mode '$1'"
522 ;;
523 esac
524 shift
525 ;;
526
527 --theme)
528 if [ -z "$1" ] ; then
529 exit_failure_syntax "theme argument missing for --theme"
530 fi
531 theme="$1"
532 shift
533 ;;
534
535 --size)
536 if [ -z "$1" ] ; then
537 exit_failure_syntax "size argument missing for --size"
538 fi
539 if echo "$1" | grep '[^0-9]' > /dev/null 2> /dev/null; then
540 exit_failure_syntax "size argument must be numeric"
541 fi
542 size="$1"
543 shift
544 ;;
545
546 --context)
547 if [ -z "$1" ] ; then
548 exit_failure_syntax "context argument missing for --context"
549 fi
550 context="$1"
551 shift
552 ;;
553
554 --novendor)
555 vendor=false
556 ;;
557
558 -*)
559 exit_failure_syntax "unexpected option '$parm'"
560 ;;
561
562 *)
563 if [ -n "$icon_name" ] ; then
564 exit_failure_syntax "unexpected argument '$parm'"
565 elif [ -n "$icon_file" ] ; then
566 icon_name="$parm"
567 else
568 if [ "$action" = "install" ] ; then
569 check_input_file "$parm"
570 fi
571 icon_file="$parm"
572 fi
573 ;;
574 esac
575 done
576
577 # Shouldn't happen
578 if [ -z "$action" ] ; then
579 exit_failure_syntax "command argument missing"
580 fi
581
582 # Shouldn't happen
583 if [ -z "$context" ] ; then
584 exit_failure_syntax "context argument missing"
585 fi
586
587 if [ -n "$XDG_UTILS_INSTALL_MODE" ] ; then
588 if [ "$XDG_UTILS_INSTALL_MODE" = "system" ] ; then
589 mode="system"
590 elif [ "$XDG_UTILS_INSTALL_MODE" = "user" ] ; then
591 mode="user"
592 fi
593 fi
594
595 if [ -z "$mode" ] ; then
596 if [ `whoami` = "root" ] ; then
597 mode="system"
598 else
599 mode="user"
600 fi
601 fi
602
603 xdg_dir_name="icons/$theme"
604
605 xdg_user_dir="$XDG_DATA_HOME"
606 [ -n "$xdg_user_dir" ] || xdg_user_dir="$HOME/.local/share"
607 xdg_user_prefix="$xdg_user_dir/icons"
608 xdg_user_dir="$xdg_user_dir/$xdg_dir_name"
609
610 xdg_global_dir=
611 xdg_global_prefix=
612 xdg_system_dirs="$XDG_DATA_DIRS"
613 [ -n "$xdg_system_dirs" ] || xdg_system_dirs="/usr/local/share/:/usr/share/"
614 for x in `echo "$xdg_system_dirs" | sed 's/:/ /g'`; do
615 if [ -w $x/$xdg_dir_name ] ; then
616 xdg_global_prefix="$x/icons"
617 xdg_global_dir="$x/$xdg_dir_name"
618 break
619 fi
620 done
621 [ -w $xdg_global_dir ] || xdg_global_dir=
622
623 dot_icon_dir=
624 dot_base_dir=
625 if [ x"$mode" = x"user" ] ; then
626 xdg_base_dir="$xdg_user_dir"
627 #Gnome 2.8 supports ~/.icons but not XDG_DATA_HOME
628 if need_dot_icon_path ; then
629 dot_icon_dir="$HOME/.icons"
630 dot_base_dir="$dot_icon_dir/$theme"
631 fi
632 else
633 xdg_base_dir="$xdg_global_dir"
634 if [ -z "$xdg_base_dir" ] ; then
635 exit_failure_operation_impossible "No writable system icon directory fou nd."
636 fi
637 fi
638
639 if [ x"$action" = x"forceupdate" ] ; then
640 if [ -n "$icon_file" ] ; then
641 exit_failure_syntax "unexpected argument '$icon_file'"
642 fi
643 update_icon_database $xdg_base_dir
644 if [ -n "$dot_icon_dir" ] ; then
645 if [ -d "$dot_icon_dir/" -a ! -L "$dot_icon_dir" ] ; then
646 update_icon_database $dot_base_dir
647 fi
648 fi
649 exit_success
650 fi
651
652 if [ -z "$icon_file" ] ; then
653 if [ x"$action" = x"install" ] ; then
654 exit_failure_syntax "icon-file argument missing"
655 else
656 exit_failure_syntax "icon-name argument missing"
657 fi
658 fi
659
660 xdg_size_name=
661 extension=
662
663 if [ -z "$size" ] ; then
664 exit_failure_syntax "the icon size must be specified with --size"
665 fi
666 xdg_size_name="${size}x${size}"
667
668 if [ x"$action" = x"install" ] ; then
669 case $icon_file in
670 *.xpm)
671 extension="xpm"
672 ;;
673 *.png)
674 extension="png"
675 ;;
676 *)
677 exit_failure_syntax "icon file to install must be a *.png or *.xpm file"
678 ;;
679 esac
680 fi
681
682 if [ -n "$icon_name" ] ; then
683 case $icon_name in
684 *.png)
685 exit_failure_syntax "icon name should not include an extension"
686 ;;
687 *.xpm)
688 exit_failure_syntax "icon name should not include an extension"
689 ;;
690 esac
691 fi
692
693 # Start KDE legacy workaround section
694 need_kde_icon_path()
695 {
696 local path
697 path=`readlink -f "$1" 2> /dev/null` # Normalize path
698 DEBUG 2 "need_kde_icon_path $path"
699 if [ -z "$path" ] ; then
700 DEBUG 2 "need_kde_icon_path RETURN 1 (not needed, no xdg icon dir)"
701 return 1; # Not needed
702 fi
703
704 # if kde-config not found... return 0
705 kde_icon_dirs=`kde${KDE_SESSION_VERSION}-config --path icon 2> /dev/null |sed 's/:/ /g'`
706 DEBUG 3 "kde_icon_dirs: $kde_icon_dirs"
707 if [ -z "$kde_icon_dirs" ] ; then
708 DEBUG 3 "no result from kde${KDE_SESSION_VERSION}-config --path icon"
709 DEBUG 2 "need_kde_icon_path RETURN 1 (not needed, no kde icon path)"
710 return 1; # Not needed
711 fi
712 needed=0 # Needed
713 for y in $kde_icon_dirs ; do
714 x=`readlink -f "$y"` # Normalize path
715 DEBUG 3 "Normalize $y --> $x"
716 if [ -n "$x" ] ; then
717 if [ "$x" = "$path" ] ; then
718 needed=1 # Not needed
719 fi
720 if [ -w "$x" ] ; then
721 kde_global_prefix="$x"
722 # Take last writable dir
723 fi
724 fi
725 done
726 DEBUG 2 "kde_global_prefix: $kde_global_prefix"
727 [ $needed -eq "1" ] && DEBUG 2 "need_kde_icon_path RETURN $needed (not needed) "
728 [ $needed -eq "0" ] && DEBUG 2 "need_kde_icon_path RETURN $needed (needed)"
729 return $needed
730 }
731
732 kde_dir=
733 if [ x"$mode" = x"user" ] ; then
734 xdg_dir="$xdg_base_dir/$xdg_size_name/$context"
735 #KDE 3.x doesn't support XDG_DATA_HOME for icons
736 #Check if xdg_dir prefix is listed by kde-config --path icon
737 #If not, install additional symlink to kdedir
738 if need_kde_icon_path "$xdg_user_prefix" ; then
739 kde_user_dir="$HOME/.kde/share/icons/$theme"
740 kde_dir="$kde_user_dir/$xdg_size_name/$context"
741 fi
742 #Gnome 2.8 supports ~/.icons but not XDG_DATA_HOME
743 if [ -n "$dot_icon_dir" ] ; then
744 if [ -L "$dot_icon_dir" ] ; then
745 # Don't do anything
746 dot_icon_dir=
747 elif [ ! -d "$dot_icon_dir/" ] ; then
748 # Symlink if it doesn't exist
749 eval 'ln -s ".local/share/icons" "$dot_icon_dir"'$xdg_redirect_outpu t
750 dot_icon_dir=
751 else
752 dot_icon_dir="$dot_icon_dir/$theme/$xdg_size_name/$context"
753 fi
754 fi
755 my_umask=077
756 else
757 xdg_dir="$xdg_base_dir/$xdg_size_name/$context"
758 #KDE 3.x doesn't support XDG_DATA_DIRS for icons
759 #Check if xdg_dir prefix is listed by kde-config --path icon
760 #If not, install additional symlink to kdedir
761 if need_kde_icon_path "$xdg_global_prefix" ; then
762 kde_global_dir="$kde_global_prefix/$theme"
763 kde_dir="$kde_global_dir/$xdg_size_name/$context"
764 fi
765 my_umask=022
766 fi
767 # End KDE legacy workaround section
768
769 # Start GNOME legacy workaround section
770 need_gnome_mime=
771 [ $context = "mimetypes" ] && need_gnome_mime=true
772 # End GNOME legacy workaround section
773
774 [ -n "$icon_name" ] || icon_name=`basename $icon_file | sed 's/\.[a-z][a-z][a-z] $//'`
775
776 if [ "$vendor" = "true" -a "$action" = "install" -a "$context" = "apps" ] ; then
777 check_vendor_prefix "$icon_name" "icon name"
778 fi
779
780 icon_icon_file=`echo "$icon_file" | sed 's/\.[a-z][a-z][a-z]$/.icon/'`
781 icon_icon_name="$icon_name.icon"
782
783 DEBUG 1 "$action icon in $xdg_dir"
784 [ $action = "install" -a -f $icon_icon_file ] && DEBUG 1 "install $icon_icon_nam e meta file in $xdg_dir"
785 [ -n "$kde_dir" ] && DEBUG 1 "$action symlink in $kde_dir (KDE 3.x support)"
786 [ -n "$need_gnome_mime" ] && DEBUG 1 "$action gnome-mime-$icon_name symlink (GNO ME 2.x support)"
787 [ $action = "install" -a -n "$dot_icon_dir" ] && DEBUG 1 "$action ~/.icons syml ink (GNOME 2.8 support)"
788
789 case $action in
790 install)
791 save_umask=`umask`
792 umask $my_umask
793
794 for icon_dir in $xdg_dir $dot_icon_dir; do
795 mkdir -p $icon_dir
796 eval 'cp "$icon_file" "$icon_dir/$icon_name.$extension"'$xdg_redirec t_output
797 if [ -f "$icon_icon_file" ] ; then
798 eval 'cp "$icon_icon_file" "$icon_dir/$icon_icon_name"'$xdg_redi rect_output
799 fi
800 if [ -n "$need_gnome_mime" ] ; then
801 eval 'ln -s "$icon_name.$extension" "$icon_dir/gnome-mime-$icon_ name.$extension"'$xdg_redirect_output
802 fi
803 done
804 if [ -n "$kde_dir" ] ; then
805 mkdir -p $kde_dir
806 eval 'ln -s "$xdg_dir/$icon_name.$extension" "$kde_dir/$icon_name.$e xtension"'$xdg_redirect_output
807 fi
808
809 umask $save_umask
810 ;;
811
812 uninstall)
813 for icon_dir in $xdg_dir $dot_icon_dir; do
814 rm -f "$icon_dir/$icon_name.xpm" "$icon_dir/$icon_name.png"
815 rm -f "$icon_dir/$icon_icon_name"
816 if [ -n "$need_gnome_mime" ] ; then
817 rm -f "$icon_dir/gnome-mime-$icon_name.xpm"
818 rm -f "$icon_dir/gnome-mime-$icon_name.png"
819 fi
820 done
821 if [ -n "$kde_dir" ] ; then
822 rm -f "$kde_dir/$icon_name.xpm" "$kde_dir/$icon_name.png"
823 fi
824
825 ;;
826 esac
827
828 if [ x"$update" = x"yes" ] ; then
829 update_icon_database "$xdg_base_dir"
830 if [ -n "$dot_icon_dir" ] ; then
831 if [ -d "$dot_icon_dir/" -a ! -L "$dot_icon_dir" ] ; then
832 update_icon_database $dot_base_dir
833 fi
834 fi
835 fi
836
837 exit_success
OLDNEW
« no previous file with comments | « third_party/xdg-utils/scripts/xdg-file-dialog.in ('k') | third_party/xdg-utils/scripts/xdg-icon-resource.in » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698