2 #---------------------------------------------
5 # Utility script to manipulate MIME related information
6 # on XDG compliant systems.
8 # Refer to the usage() function below for usage.
10 # Copyright 2006, Kevin Krammer <kevin.krammer@gmx.at>
11 # Copyright 2006, Jeremy White <jwhite@codeweavers.com>
15 # Permission is hereby granted, free of charge, to any person obtaining a
16 # copy of this software and associated documentation files (the "Software"),
17 # to deal in the Software without restriction, including without limitation
18 # the rights to use, copy, modify, merge, publish, distribute, sublicense,
19 # and/or sell copies of the Software, and to permit persons to whom the
20 # Software is furnished to do so, subject to the following conditions:
22 # The above copyright notice and this permission notice shall be included
23 # in all copies or substantial portions of the Software.
25 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
26 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
28 # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
29 # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
30 # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
31 # OTHER DEALINGS IN THE SOFTWARE.
33 #---------------------------------------------
40 xdg-mime - command line tool for querying information about file type handling
41 and adding descriptions for new file types
45 xdg-mime query { filetype | default } ...
47 xdg-mime default application mimetype(s)
49 xdg-mime install [--mode mode] [--novendor] mimetypes-file
51 xdg-mime uninstall [--mode mode] mimetypes-file
53 xdg-mime { --help | --manual | --version }
57 The xdg-mime program can be used to query information about file types and to
58 add descriptions for new file types.
64 Returns information related to file types.
66 The query option is for use inside a desktop session only. It is not
67 recommended to use xdg-mime query as root.
69 The following queries are supported:
71 query filetype FILE: Returns the file type of FILE in the form of a MIME
74 query default mimetype: Returns the default application that the desktop
75 environment uses for opening files of type mimetype. The default
76 application is identified by its *.desktop file.
80 Ask the desktop environment to make application the default application for
81 opening files of type mimetype. An application can be made the default for
82 several file types by specifying multiple mimetypes.
84 application is the desktop file id of the application and has the form
85 vendor-name.desktop application must already be installed in the desktop
86 menu before it can be made the default handler. The aplication's desktop
87 file must list support for all the MIME types that it wishes to be the
90 Requests to make an application a default handler may be subject to system
91 policy or approval by the end-user. xdg-mime query can be used to verify
92 whether an application is the actual default handler for a specific file
95 The default option is for use inside a desktop session only. It is not
96 recommended to use xdg-mime default as root.
99 Adds the file type descriptions provided in mimetypes-file to the desktop
100 environment. mimetypes-file must be a XML file that follows the
101 freedesktop.org Shared MIME-info Database specification and that has a
102 mime-info element as its document root. For each new file type one or more
103 icons with name major-minor must be installed with the xdg-icon-resource
104 command in the mimetypes context. For example the application/
105 vnd.oasis.opendocument.text filetype requires an icon by the name of
106 application-vnd.oasis.opendocument.text to be installed.
108 Removes the file type descriptions provided in mimetypes-file and
109 previously added with xdg-mime install from the desktop environment.
110 mimetypes-file must be a XML file that follows the freedesktop.org Shared
111 MIME-info Database specification and that has a mime-info element as its
118 mode can be user or system. In user mode the file is (un)installed for the
119 current user only. In system mode the file is (un)installed for all users
120 on the system. Usually only root is allowed to install in system mode.
122 The default is to use system mode when called by root and to use user mode
123 when called by a non-root user.
127 Normally, xdg-mime checks to ensure that the mimetypes-file to be installed
128 has a proper vendor prefix. This option can be used to disable that check.
130 A vendor prefix consists of alpha characters ([a-zA-Z]) and is terminated
131 with a dash ("-"). Companies and organizations are encouraged to use a word
132 or phrase, preferably the organizations name, for which they hold a
133 trademark as their vendor prefix. The purpose of the vendor prefix is to
134 prevent name conflicts.
137 Show command synopsis.
139 Show this manualpage.
141 Show the xdg-utils version information.
143 Environment Variables
145 xdg-mime honours the following environment variables:
147 XDG_UTILS_DEBUG_LEVEL
148 Setting this environment variable to a non-zero numerical value makes
149 xdg-mime do more verbose reporting on stderr. Setting a higher value
150 increases the verbosity.
151 XDG_UTILS_INSTALL_MODE
152 This environment variable can be used by the user or administrator to
153 override the installation mode. Valid values are user and system.
157 An exit code of 0 indicates success while a non-zero exit code indicates
158 failure. The following failure codes can be returned:
161 Error in command line syntax.
163 One of the files passed on the command line did not exist.
165 A required tool could not be found.
169 No permission to read one of the files passed on the command line.
173 xdg-icon-resource(1), xdg-desktop-menu(1)
177 xdg-mime query filetype /tmp/foobar.png
179 Prints the MIME type of the file /tmp/foobar.png, in this case image/png
181 xdg-mime query default image/png
183 Prints the .desktop filename of the application which is registered to open PNG
186 xdg-mime install shinythings-shiny.xml
188 Adds a file type description for "shiny"-files. "shinythings-" is used as the
189 vendor prefix. The file type description could look as folows.
191 shinythings-shiny.xml:
193 <?xml version="1.0"?>
194 <mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
195 <mime-type type="text/x-shiny">
196 <comment>Shiny new file type</comment>
197 <glob pattern="*.shiny"/>
198 <glob pattern="*.shi"/>
202 An icon for this new file type must also be installed, for example with:
204 xdg-icon-resource install --context mimetypes --size 64 shiny-file-icon.png text-x-shiny
212 xdg-mime - command line tool for querying information about file type handling
213 and adding descriptions for new file types
217 xdg-mime query { filetype | default } ...
219 xdg-mime default application mimetype(s)
221 xdg-mime install [--mode mode] [--novendor] mimetypes-file
223 xdg-mime uninstall [--mode mode] mimetypes-file
225 xdg-mime { --help | --manual | --version }
232 #----------------------------------------------------------------------------
233 # Common utility functions included in all XDG wrapper scripts
234 #----------------------------------------------------------------------------
238 [ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && return 0;
239 [ ${XDG_UTILS_DEBUG_LEVEL} -lt $1 ] && return 0;
244 #-------------------------------------------------------------
245 # Exit script on successfully completing the desired operation
249 if [ $# -gt 0 ]; then
258 #-----------------------------------------
259 # Exit script on malformed arguments, not enough arguments
260 # or missing required option.
261 # prints usage information
263 exit_failure_syntax
()
265 if [ $# -gt 0 ]; then
266 echo "xdg-mime: $@" >&2
267 echo "Try 'xdg-mime --help' for more information." >&2
270 echo "Use 'man xdg-mime' or 'xdg-mime --manual' for additional info."
276 #-------------------------------------------------------------
277 # Exit script on missing file specified on command line
279 exit_failure_file_missing
()
281 if [ $# -gt 0 ]; then
282 echo "xdg-mime: $@" >&2
288 #-------------------------------------------------------------
289 # Exit script on failure to locate necessary tool applications
291 exit_failure_operation_impossible
()
293 if [ $# -gt 0 ]; then
294 echo "xdg-mime: $@" >&2
300 #-------------------------------------------------------------
301 # Exit script on failure returned by a tool application
303 exit_failure_operation_failed
()
305 if [ $# -gt 0 ]; then
306 echo "xdg-mime: $@" >&2
312 #------------------------------------------------------------
313 # Exit script on insufficient permission to read a specified file
315 exit_failure_file_permission_read
()
317 if [ $# -gt 0 ]; then
318 echo "xdg-mime: $@" >&2
324 #------------------------------------------------------------
325 # Exit script on insufficient permission to read a specified file
327 exit_failure_file_permission_write
()
329 if [ $# -gt 0 ]; then
330 echo "xdg-mime: $@" >&2
338 if [ ! -e "$1" ]; then
339 exit_failure_file_missing
"file '$1' does not exist"
341 if [ ! -r "$1" ]; then
342 exit_failure_file_permission_read
"no permission to read file '$1'"
346 check_vendor_prefix
()
349 [ -n "$file_label" ] || file_label
="filename"
357 echo "xdg-mime: $file_label '$file' does not have a proper vendor prefix" >&2
358 echo 'A vendor prefix consists of alpha characters ([a-zA-Z]) and is terminated' >&2
359 echo 'with a dash ("-"). An example '"$file_label"' is '"'example-$file'" >&2
360 echo "Use --novendor to override or 'xdg-mime --manual' for additional info." >&2
366 # if the file exists, check if it is writeable
367 # if it does not exists, check if we are allowed to write on the directory
369 if [ ! -w "$1" ]; then
370 exit_failure_file_permission_write
"no permission to write to file '$1'"
374 if [ ! -w "$DIR" -o ! -x "$DIR" ]; then
375 exit_failure_file_permission_write
"no permission to create file '$1'"
380 #----------------------------------------
381 # Checks for shared commands, e.g. --help
383 check_common_commands
()
385 while [ $# -gt 0 ] ; do
392 echo "Use 'man xdg-mime' or 'xdg-mime --manual' for additional info."
402 echo "xdg-mime 1.0.1"
409 check_common_commands
"$@"
411 [ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && unset XDG_UTILS_DEBUG_LEVEL
;
412 if [ ${XDG_UTILS_DEBUG_LEVEL-0} -lt 1 ]; then
414 xdg_redirect_output
=" > /dev/null 2> /dev/null"
416 # All output to stderr
417 xdg_redirect_output
=" >&2"
420 #--------------------------------------
421 # Checks for known desktop environments
422 # set variable DE to the desktop environments name, lowercase
426 if [ x
"$KDE_FULL_SESSION" = x
"true" ]; then DE
=kde
;
427 elif [ x
"$GNOME_DESKTOP_SESSION_ID" != x
"" ]; then DE
=gnome
;
428 elif xprop
-root _DT_SAVE_MODE |
grep ' = \"xfce4\"$' >/dev
/null
2>&1; then DE
=xfce
;
432 #----------------------------------------------------------------------------
433 # kfmclient exec/openURL can give bogus exit value in KDE <= 3.5.4
434 # It also always returns 1 in KDE 3.4 and earlier
435 # Simply return 0 in such case
437 kfmclient_fix_exit_code
()
439 version
=`kde-config --version 2>/dev/null | grep KDE`
440 major
=`echo $version | sed 's/KDE: \([0-9]\).*/\1/'`
441 minor
=`echo $version | sed 's/KDE: [0-9]*\.\([0-9]\).*/\1/'`
442 release
=`echo $version | sed 's/KDE: [0-9]*\.[0-9]*\.\([0-9]\).*/\1/'`
443 test "$major" -gt 3 && return $1
444 test "$minor" -gt 5 && return $1
445 test "$release" -gt 4 && return $1
449 update_mime_database
()
451 if [ x
"$mode" = x
"user" -a -n "$DISPLAY" ] ; then
453 if [ x
"$DE" = x
"kde" ] ; then
454 DEBUG
1 "Running kbuildsycoca"
455 eval 'kbuildsycoca'$xdg_redirect_output
458 for x
in `echo "$PATH:/opt/gnome/bin" | sed 's/:/ /g'`; do
459 if [ -x $x/update-mime-database
] ; then
460 DEBUG
1 "Running $x/update-mime-database $1"
461 eval '$x/update-mime-database $1'$xdg_redirect_output
469 DEBUG
1 "Running kfile \"$1\""
470 kfile
"$1" 2> /dev
/null |
head -n 1 | cut
-d "(" -f 2 | cut
-d ")" -f 1
477 file=`readlink -f "$1"` # Normalize path
478 DEBUG
1 "Running gnomevfs-info \"$file\""
479 gnomevfs-info
"$file" 2> /dev
/null |
grep MIME | cut
-d ":" -f 2 |
sed s
/"^ "//
486 DEBUG
1 "Running /usr/bin/file -i \"$1\""
487 /usr
/bin
/file -i "$1" 2> /dev
/null | cut
-d ":" -f 2 |
sed s
/"^ "//
494 # $1 is vendor-name.desktop
496 # Add to $KDE_HOME/share/config/profilerc:
500 # Remove all [$2 - *] sections, or even better,
501 # renumber [$2 - *] sections and remove duplicate
503 default_file
="$HOME/.kde/share/config/profilerc"
504 DEBUG
2 "make_default_kde $1 $2"
505 DEBUG
1 "Updating $default_file"
506 mkdir
-p "$HOME/.kde/share/config"
507 [ -f $default_file ] ||
touch $default_file
508 awk -v application
="$1" -v mimetype
="$2" '
510 header_start="[" mimetype " - "
514 if (index($0, header_start) == 1 )
517 if (/^\[/) { supress=0 }
525 print "[" mimetype " - 1]"
526 print "Application=" application
527 print "AllowAsDefault=true"
528 print "GenericServiceType=Application"
530 print "ServiceType=" mimetype
532 ' $default_file > ${default_file}.new
&& mv ${default_file}.new
$default_file
535 make_default_generic
()
537 # $1 is vendor-name.desktop
539 # Add $2=$1 to XDG_DATA_HOME/applications/defaults.list
540 xdg_user_dir
="$XDG_DATA_HOME"
541 [ -n "$xdg_user_dir" ] || xdg_user_dir
="$HOME/.local/share"
542 default_file
="$xdg_user_dir/applications/defaults.list"
543 DEBUG
2 "make_default_generic $1 $2"
544 DEBUG
1 "Updating $default_file"
545 grep -v "$2=" $default_file > ${default_file}.new
2> /dev
/null
546 if ! grep "[Default Applications]" ${default_file}.new
> /dev
/null
; then
547 echo "[Default Applications]" >> ${default_file}.new
549 echo $2=$1 >> ${default_file}.new
550 mv ${default_file}.new
$default_file
556 xdg_user_dir
="$XDG_DATA_HOME"
557 [ -n "$xdg_user_dir" ] || xdg_user_dir
="$HOME/.local/share"
558 xdg_user_dir
="$xdg_user_dir/$xdg_dir_name"
559 xdg_system_dirs
="$XDG_DATA_DIRS"
560 [ -n "$xdg_system_dirs" ] || xdg_system_dirs
=/usr
/local
/share
/:/usr
/share
/
562 for x
in `echo "$xdg_user_dir:$xdg_system_dirs" | sed 's/:/ /g'`; do
563 DEBUG
2 "Checking $x/applications/defaults.list"
564 trader_result
=`grep "$MIME=" $x/applications/defaults.list 2> /dev/null | cut -d '=' -f 2 | cut -d ';' -f 1`
565 if [ -n "$trader_result" ] ; then
576 ktradertest
=`which ktradertest 2> /dev/null`
577 if [ -n "$ktradertest" ] ; then
578 DEBUG
1 "Running ktradertest \"$MIME\" Application"
579 trader_result
=`ktradertest "$MIME" Application 2>/dev/null | grep DesktopEntryPath \
580 | head -n 1 | cut -d ':' -f 2 | cut -d \' -f 2`
581 if [ -n "$trader_result" ] ; then
582 basename "$trader_result"
585 exit_failure_operation_failed
592 [ x
"$1" != x
"" ] || exit_failure_syntax
611 if [ -z "$1" ] ; then
612 exit_failure_syntax
"query type argument missing"
620 if [ -z "$filename" ] ; then
621 exit_failure_syntax
"FILE argument missing"
625 exit_failure_syntax
"unexpected option '$filename'"
628 check_input_file
"$filename"
634 if [ -z "$mimetype" ] ; then
635 exit_failure_syntax
"mimetype argument missing"
639 exit_failure_syntax
"unexpected option '$mimetype'"
647 exit_failure_syntax
"mimetype '$mimetype' is not in the form 'minor/major'"
653 exit_failure_syntax
"unknown query type '$1'"
662 if [ -z "$1" ] ; then
663 exit_failure_syntax
"application argument missing"
667 exit_failure_syntax
"unexpected option '$1'"
675 exit_failure_syntax
"malformed argument '$1', expected *.desktop"
681 exit_failure_syntax
"unknown command '$1'"
688 if [ "$action" = "makedefault" ]; then
689 if [ -z "$1" ] ; then
690 exit_failure_syntax
"mimetype argument missing"
693 while [ $# -gt 0 ] ; do
696 exit_failure_syntax
"unexpected option '$1'"
702 make_default_kde
"$filename" "$mimetype"
703 make_default_generic
"$filename" "$mimetype"
708 if [ "$action" = "info" ]; then
711 if [ x
"$DE" = x
"" ]; then
712 if [ -x /usr
/bin
/file ]; then
723 info_gnome
"$filename"
727 info_generic
"$filename"
730 exit_failure_operation_impossible
"no method available for quering MIME type of '$filename'"
733 if [ "$action" = "defapp" ]; then
738 defapp_kde
"$mimetype"
742 defapp_generic
"$mimetype"
745 exit_failure_operation_impossible
"no method available for quering default application for '$mimetype'"
749 while [ $# -gt 0 ] ; do
755 if [ -z "$1" ] ; then
756 exit_failure_syntax
"mode argument missing for --mode"
768 exit_failure_syntax
"unknown mode '$1'"
779 exit_failure_syntax
"unexpected option '$parm'"
783 if [ -n "$filename" ] ; then
784 exit_failure_syntax
"unexpected argument '$parm'"
788 check_input_file
"$filename"
793 if [ -z "$action" ] ; then
794 exit_failure_syntax
"command argument missing"
797 if [ -n "$XDG_UTILS_INSTALL_MODE" ] ; then
798 if [ "$XDG_UTILS_INSTALL_MODE" = "system" ] ; then
800 elif [ "$XDG_UTILS_INSTALL_MODE" = "user" ] ; then
805 if [ -z "$mode" ] ; then
806 if [ `whoami` = "root" ] ; then
813 if [ -z "$filename" ] ; then
814 exit_failure_syntax
"mimetypes-file argument missing"
817 if [ "$vendor" = "true" -a "$action" = "install" ] ; then
818 check_vendor_prefix
"$filename"
822 xdg_dir_name
=mime
/packages
/
824 xdg_user_dir
="$XDG_DATA_HOME"
825 [ -n "$xdg_user_dir" ] || xdg_user_dir
="$HOME/.local/share"
826 [ x
"$mode" = x
"user" ] && xdg_base_dir
="$xdg_user_dir/mime"
827 xdg_user_dir
="$xdg_user_dir/$xdg_dir_name"
829 xdg_system_dirs
="$XDG_DATA_DIRS"
830 [ -n "$xdg_system_dirs" ] || xdg_system_dirs
=/usr
/local
/share
/:/usr
/share
/
831 for x
in `echo $xdg_system_dirs | sed 's/:/ /g'`; do
832 if [ -w $x/$xdg_dir_name ] ; then
833 [ x
"$mode" = x
"system" ] && xdg_base_dir
="$x/mime"
834 xdg_global_dir
="$x/$xdg_dir_name"
838 [ -w $xdg_global_dir ] || xdg_global_dir
=
839 DEBUG
3 "xdg_user_dir: $xdg_user_dir"
840 DEBUG
3 "xdg_global_dir: $xdg_global_dir"
842 # Find KDE3 mimelnk directory
845 kde_global_dirs
=`kde-config --path mime 2> /dev/null`
846 DEBUG
3 "kde_global_dirs: $kde_global_dirs"
848 for x
in `echo $kde_global_dirs | sed 's/:/ /g'` ; do
849 if [ -z "$first" ] ; then
852 elif [ -w $x ] ; then
856 DEBUG
3 "kde_user_dir: $kde_user_dir"
857 DEBUG
3 "kde_global_dir: $kde_global_dir"
859 # TODO: Gnome legacy support
860 # See http://forums.fedoraforum.org/showthread.php?t=26875
861 gnome_user_dir
="$HOME/.gnome/apps"
862 gnome_global_dir
=/usr
/share
/gnome
/apps
863 [ -w $gnome_global_dir ] || gnome_global_dir
=
864 DEBUG
3 "gnome_user_dir: $gnome_user_dir"
865 DEBUG
3 "gnome_global_dir: $gnome_global_dir"
867 if [ x
"$mode" = x
"user" ] ; then
868 xdg_dir
="$xdg_user_dir"
869 kde_dir
="$kde_user_dir"
870 gnome_dir
="$gnome_user_dir"
873 xdg_dir
="$xdg_global_dir"
874 kde_dir
="$kde_global_dir"
875 gnome_dir
="$gnome_global_dir"
877 if [ -z "${xdg_dir}${kde_dir}${gnome_dir}" ] ; then
878 exit_failure_operation_impossible
"No writable system mimetype directory found."
882 # echo "[xdg|$xdg_user_dir|$xdg_global_dir]"
883 # echo "[kde|$kde_user_dir|$kde_global_dir]"
884 # echo "[gnome|$gnome_user_dir|$gnome_global_dir]"
885 # echo "[using|$xdg_dir|$kde_dir|$gnome_dir]"
887 basefile
=`basename "$filename"`
888 #[ -z $vendor ] || basefile="$vendor-$basefile"
891 if [ -n "$kde_dir" ] ; then
892 DEBUG
2 "KDE3 mimelnk directory found, extracting mimetypes from XML file"
894 mimetypes
=`awk < "$filename" '
902 if (match($0,/-->/)) {
903 $0=substr($0,RSTART+RLENGTH)
911 if (match($0,/<!--/)) {
912 if (RSTART>1) print substr($0,0,RSTART)
913 $0=substr($0,RSTART+RLENGTH)
924 # List MIME types listed in <mime-type> tags
928 /^mime-info/, /^\/mime-info/ {
929 if (match($0,/^mime-type/)) {
930 if (match($0,/type="[^"]*/) || match($0,/type='"'"'[^'"'"']*/)) {
931 print substr($0,RSTART+6,RLENGTH-6)
937 DEBUG
1 "$action mimetype in $xdg_dir"
944 for x
in $xdg_dir ; do
946 eval 'cp $filename $x/$basefile'$xdg_redirect_output
949 if [ -n "$mimetypes" ] ; then
950 # No quotes around $mimetypes
951 for x
in $mimetypes ; do
952 DEBUG
1 "Installing $kde_dir/$x.desktop (KDE 3.x support)"
953 mkdir
-p `dirname $kde_dir/$x.desktop`
962 if (match($0,/-->/)) {
963 $0=substr($0,RSTART+RLENGTH)
971 if (match($0,/<!--/)) {
972 if (RSTART>1) print substr($0,0,RSTART)
973 $0=substr($0,RSTART+RLENGTH)
983 ' |
awk > $kde_dir/$x.desktop
'
984 # Extract mimetype $x from the XML file $filename
985 # Note that bash requires us to escape a single quote as '"'"'
994 /^mime-info/, /^\/mime-info/ {
995 if (match($0,/^mime-type/)) {
996 if (match($0,/type="[^"]*/) || match($0,/type='"'"'[^'"'"']*/)) {
997 if (substr($0,RSTART+6,RLENGTH-6) == the_type) {
999 print "[Desktop Entry]"
1000 print "# Installed by xdg-mime from " the_source
1001 print "Type=MimeType"
1002 print "MimeType=" the_type
1004 sub("/", "-", the_icon)
1005 print "Icon=" the_icon
1010 if (match($0,/^\/mime-type/)) {
1012 print "Patterns=" glob_patterns
1016 if (match($0,/^sub-class-of/)) {
1017 if (match($0,/type="[^"]*/) || match($0,/type='"'"'[^'"'"']*/)) {
1018 print "X-KDE-IsAlso=" substr($0,RSTART+6,RLENGTH-6)
1021 print "Error: '"'"'type'"'"' argument missing in " RS $0
1025 if (match($0,/^glob/)) {
1026 if (match($0,/pattern="[^"]*/) || match($0,/pattern='"'"'[^'"'"']*/)) {
1027 glob_patterns = glob_patterns substr($0,RSTART+9,RLENGTH-9) ";"
1030 print "Error: '"'"'pattern'"'"' argument missing in " RS $0
1034 if (match($0,/^comment/)) {
1035 if (match($0,/xml:lang="[^"]*/) || match($0,/xml:lang='"'"'[^'"'"']*/)) {
1036 lang=substr($0,RSTART+10,RLENGTH-10)
1041 if (match($0,/>/)) {
1042 comment=substr($0,RSTART+1)
1043 sub("<", "<", comment)
1044 sub(">", ">", comment)
1045 sub("&", "\\&", comment)
1047 print "Comment[" lang "]=" comment
1049 print "Comment=" comment
1056 print "Error: Mimetype '"'"'" the_type "'"'"' not found"
1061 if [ "$?" = "1" ] ; then
1062 grep -A 10 "^Error:" $kde_dir/$x.desktop
>&2
1063 rm $kde_dir/$x.desktop
1073 for x
in $xdg_dir ; do
1077 # No quotes around $mimetypes
1078 for x
in $mimetypes ; do
1079 if grep '^# Installed by xdg-mime' $kde_dir/$x.desktop
&>/dev
/null
; then
1080 DEBUG
1 "Removing $kde_dir/$x.desktop (KDE 3.x support)"
1081 rm -f $kde_dir/$x.desktop
1087 update_mime_database
$xdg_base_dir