| OLD | NEW |
| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 if [ $oldlines -le $newlines ]; then | 75 if [ $oldlines -le $newlines ]; then |
| 76 mv "$temp" "$apps/$1" | 76 mv "$temp" "$apps/$1" |
| 77 # This can take a little bit to get noticed | 77 # This can take a little bit to get noticed |
| 78 sleep 4 | 78 sleep 4 |
| 79 else | 79 else |
| 80 rm -f "$temp" | 80 rm -f "$temp" |
| 81 return 1 | 81 return 1 |
| 82 fi | 82 fi |
| 83 } | 83 } |
| 84 | 84 |
| 85 xdg_mime_fixup() |
| 86 { |
| 87 # xdg-mime may use ktradertest, which will fork off a copy of kdeinit if |
| 88 # one does not already exist. It will exit after about 15 seconds if no |
| 89 # further processes need it around. But since it does not close its stdout, |
| 90 # the shell (via grep) will wait around for kdeinit to exit. If we start a |
| 91 # copy here, that copy will be used in xdg-mime and we will avoid waiting. |
| 92 if [ "$DE" = kde -a -z "$XDG_MIME_FIXED" ]; then |
| 93 ktradertest text/html Application > /dev/null 2>&1 |
| 94 # Only do this once, as we only need it once. |
| 95 XDG_MIME_FIXED=yes |
| 96 fi |
| 97 } |
| 98 |
| 85 get_browser_mime() | 99 get_browser_mime() |
| 86 { | 100 { |
| 101 xdg_mime_fixup |
| 87 xdg-mime query default text/html | 102 xdg-mime query default text/html |
| 88 } | 103 } |
| 89 | 104 |
| 90 set_browser_mime() | 105 set_browser_mime() |
| 91 { | 106 { |
| 107 xdg_mime_fixup |
| 92 orig="`get_browser_mime`" | 108 orig="`get_browser_mime`" |
| 93 # Fixing the local desktop file can actually change the default browser all | 109 # Fixing the local desktop file can actually change the default browser all |
| 94 # by itself, so we fix it only after querying to find the current default | 110 # by itself, so we fix it only after querying to find the current default |
| 95 fix_local_desktop_file "$1" || return | 111 fix_local_desktop_file "$1" || return |
| 96 mkdir -p "${XDG_DATA_HOME:-$HOME/.local/share}/applications" | 112 mkdir -p "${XDG_DATA_HOME:-$HOME/.local/share}/applications" |
| 97 xdg-mime default "$1" text/html || return | 113 xdg-mime default "$1" text/html || return |
| 98 if [ x"`get_browser_mime`" != x"$1" ]; then | 114 if [ x"`get_browser_mime`" != x"$1" ]; then |
| 99 # Put back the original value | 115 # Put back the original value |
| 100 xdg-mime default "$orig" text/html | 116 xdg-mime default "$orig" text/html |
| 101 exit_failure_operation_failed | 117 exit_failure_operation_failed |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 ;; | 486 ;; |
| 471 | 487 |
| 472 generic) | 488 generic) |
| 473 dispatch_generic "$@" | 489 dispatch_generic "$@" |
| 474 ;; | 490 ;; |
| 475 | 491 |
| 476 *) | 492 *) |
| 477 exit_failure_operation_impossible "unknown desktop environment" | 493 exit_failure_operation_impossible "unknown desktop environment" |
| 478 ;; | 494 ;; |
| 479 esac | 495 esac |
| OLD | NEW |