| OLD | NEW |
| 1 #!/bin/sh | 1 #!/bin/sh |
| 2 #--------------------------------------------- | 2 #--------------------------------------------- |
| 3 # xdg-mime | 3 # xdg-mime |
| 4 # | 4 # |
| 5 # Utility script to manipulate MIME related information | 5 # Utility script to manipulate MIME related information |
| 6 # on XDG compliant systems. | 6 # on XDG compliant systems. |
| 7 # | 7 # |
| 8 # Refer to the usage() function below for usage. | 8 # Refer to the usage() function below for usage. |
| 9 # | 9 # |
| 10 # Copyright 2009-2010, Fathi Boudra <fabo@freedesktop.org> | 10 # Copyright 2009-2010, Fathi Boudra <fabo@freedesktop.org> |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 | 66 |
| 67 if [ $? -eq 0 ]; then | 67 if [ $? -eq 0 ]; then |
| 68 exit_success | 68 exit_success |
| 69 else | 69 else |
| 70 exit_failure_operation_failed | 70 exit_failure_operation_failed |
| 71 fi | 71 fi |
| 72 } | 72 } |
| 73 | 73 |
| 74 info_gnome() | 74 info_gnome() |
| 75 { | 75 { |
| 76 file=`readlink -f "$1"` # Normalize path | |
| 77 | |
| 78 if gvfs-info --help 2>/dev/null 1>&2; then | 76 if gvfs-info --help 2>/dev/null 1>&2; then |
| 79 DEBUG 1 "Running gvfs-info \"$file\"" | 77 DEBUG 1 "Running gvfs-info \"$1\"" |
| 80 gvfs-info "$file" 2> /dev/null | grep standard::content-type | cut -d' '
-f4 | 78 gvfs-info "$1" 2> /dev/null | grep standard::content-type | cut -d' ' -f
4 |
| 79 elif gnomevfs-info --help 2>/dev/null 1>&2; then |
| 80 DEBUG 1 "Running gnomevfs-info \"$1\"" |
| 81 gnomevfs-info --slow-mime "$1" 2> /dev/null | grep "^MIME" | cut -d ":" -
f 2 | sed s/"^ "// |
| 81 else | 82 else |
| 82 DEBUG 1 "Running gnomevfs-info \"$file\"" | 83 # according to https://bugs.freedesktop.org/show_bug.cgi?id=33094#c5 |
| 83 gnomevfs-info --slow-mime "$file" 2> /dev/null | grep "^MIME" | cut -d ":
" -f 2 | sed s/"^ "// | 84 # neither gvfs-info or gnomevfs-info are present in a default Ubuntu Natt
y |
| 85 # install, so fallback to info_generic |
| 86 info_generic "$1" |
| 84 fi | 87 fi |
| 85 | 88 |
| 86 if [ $? -eq 0 ]; then | 89 if [ $? -eq 0 ]; then |
| 87 exit_success | 90 exit_success |
| 88 else | 91 else |
| 89 exit_failure_operation_failed | 92 exit_failure_operation_failed |
| 90 fi | 93 fi |
| 91 } | 94 } |
| 92 | 95 |
| 93 info_generic() | 96 info_generic() |
| 94 { | 97 { |
| 95 DEBUG 1 "Running file -i \"$1\"" | 98 if mimetype --version >/dev/null 2>&1; then |
| 96 /usr/bin/file -i "$1" 2> /dev/null | cut -d ":" -f 2 | sed s/"^ "// | 99 DEBUG 1 "Running mimetype -b \"$1\"" |
| 100 mimetype -b "$1" |
| 101 else |
| 102 DEBUG 1 "Running file -i \"$1\"" |
| 103 /usr/bin/file -i "$1" 2> /dev/null | cut -d ":" -f 2 | sed s/"^ "// |
| 104 fi |
| 97 | 105 |
| 98 if [ $? -eq 0 ]; then | 106 if [ $? -eq 0 ]; then |
| 99 exit_success | 107 exit_success |
| 100 else | 108 else |
| 101 exit_failure_operation_failed | 109 exit_failure_operation_failed |
| 102 fi | 110 fi |
| 103 } | 111 } |
| 104 | 112 |
| 105 make_default_kde() | 113 make_default_kde() |
| 106 { | 114 { |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 filename="$2" | 330 filename="$2" |
| 323 if [ -z "$filename" ] ; then | 331 if [ -z "$filename" ] ; then |
| 324 exit_failure_syntax "FILE argument missing" | 332 exit_failure_syntax "FILE argument missing" |
| 325 fi | 333 fi |
| 326 case $filename in | 334 case $filename in |
| 327 -*) | 335 -*) |
| 328 exit_failure_syntax "unexpected option '$filename'" | 336 exit_failure_syntax "unexpected option '$filename'" |
| 329 ;; | 337 ;; |
| 330 esac | 338 esac |
| 331 check_input_file "$filename" | 339 check_input_file "$filename" |
| 340 filename=`readlink -f -- "$filename"` |
| 332 ;; | 341 ;; |
| 333 | 342 |
| 334 default) | 343 default) |
| 335 action=defapp | 344 action=defapp |
| 336 mimetype="$2" | 345 mimetype="$2" |
| 337 if [ -z "$mimetype" ] ; then | 346 if [ -z "$mimetype" ] ; then |
| 338 exit_failure_syntax "mimetype argument missing" | 347 exit_failure_syntax "mimetype argument missing" |
| 339 fi | 348 fi |
| 340 case $mimetype in | 349 case $mimetype in |
| 341 -*) | 350 -*) |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 if [ -x /usr/bin/file ]; then | 424 if [ -x /usr/bin/file ]; then |
| 416 DE=generic | 425 DE=generic |
| 417 fi | 426 fi |
| 418 fi | 427 fi |
| 419 | 428 |
| 420 case "$DE" in | 429 case "$DE" in |
| 421 kde) | 430 kde) |
| 422 info_kde "$filename" | 431 info_kde "$filename" |
| 423 ;; | 432 ;; |
| 424 | 433 |
| 425 gnome) | 434 gnome*) |
| 426 info_gnome "$filename" | 435 info_gnome "$filename" |
| 427 ;; | 436 ;; |
| 428 | 437 |
| 429 *) | 438 *) |
| 430 info_generic "$filename" | 439 info_generic "$filename" |
| 431 ;; | 440 ;; |
| 432 esac | 441 esac |
| 433 exit_failure_operation_impossible "no method available for quering MIME type
of '$filename'" | 442 exit_failure_operation_impossible "no method available for quering MIME type
of '$filename'" |
| 434 fi | 443 fi |
| 435 | 444 |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 784 rm -f $kde_dir/$x.desktop | 793 rm -f $kde_dir/$x.desktop |
| 785 fi | 794 fi |
| 786 done | 795 done |
| 787 ;; | 796 ;; |
| 788 esac | 797 esac |
| 789 | 798 |
| 790 update_mime_database $xdg_base_dir | 799 update_mime_database $xdg_base_dir |
| 791 | 800 |
| 792 exit_success | 801 exit_success |
| 793 | 802 |
| OLD | NEW |