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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 exit_failure_file_permission_read() | 203 exit_failure_file_permission_read() |
204 { | 204 { |
205 if [ $# -gt 0 ]; then | 205 if [ $# -gt 0 ]; then |
206 echo "xdg-settings: $@" >&2 | 206 echo "xdg-settings: $@" >&2 |
207 fi | 207 fi |
208 | 208 |
209 exit 5 | 209 exit 5 |
210 } | 210 } |
211 | 211 |
212 #------------------------------------------------------------ | 212 #------------------------------------------------------------ |
213 # Exit script on insufficient permission to read a specified file | 213 # Exit script on insufficient permission to write a specified file |
214 | 214 |
215 exit_failure_file_permission_write() | 215 exit_failure_file_permission_write() |
216 { | 216 { |
217 if [ $# -gt 0 ]; then | 217 if [ $# -gt 0 ]; then |
218 echo "xdg-settings: $@" >&2 | 218 echo "xdg-settings: $@" >&2 |
219 fi | 219 fi |
220 | 220 |
221 exit 6 | 221 exit 6 |
222 } | 222 } |
223 | 223 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 fi | 306 fi |
307 | 307 |
308 #-------------------------------------- | 308 #-------------------------------------- |
309 # Checks for known desktop environments | 309 # Checks for known desktop environments |
310 # set variable DE to the desktop environments name, lowercase | 310 # set variable DE to the desktop environments name, lowercase |
311 | 311 |
312 detectDE() | 312 detectDE() |
313 { | 313 { |
314 if [ x"$KDE_FULL_SESSION" = x"true" ]; then DE=kde; | 314 if [ x"$KDE_FULL_SESSION" = x"true" ]; then DE=kde; |
315 elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE=gnome; | 315 elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE=gnome; |
316 elif xprop -root _DT_SAVE_MODE | grep ' = \"xfce4\"$' >/dev/null 2>&1; then
DE=xfce; | 316 elif `dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop/D
Bus org.freedesktop.DBus.GetNameOwner string:org.gnome.SessionManager > /dev/nul
l 2>&1` ; then DE=gnome; |
| 317 elif xprop -root _DT_SAVE_MODE 2> /dev/null | grep ' = \"xfce4\"$' >/dev/nul
l 2>&1; then DE=xfce; |
317 fi | 318 fi |
318 } | 319 } |
319 | 320 |
320 #---------------------------------------------------------------------------- | 321 #---------------------------------------------------------------------------- |
321 # kfmclient exec/openURL can give bogus exit value in KDE <= 3.5.4 | 322 # kfmclient exec/openURL can give bogus exit value in KDE <= 3.5.4 |
322 # It also always returns 1 in KDE 3.4 and earlier | 323 # It also always returns 1 in KDE 3.4 and earlier |
323 # Simply return 0 in such case | 324 # Simply return 0 in such case |
324 | 325 |
325 kfmclient_fix_exit_code() | 326 kfmclient_fix_exit_code() |
326 { | 327 { |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 | 520 |
520 # Reads the KDE browser setting, compensating for a bug in some versions of krea
dconfig. | 521 # Reads the KDE browser setting, compensating for a bug in some versions of krea
dconfig. |
521 read_kde_browser() | 522 read_kde_browser() |
522 { | 523 { |
523 browser="`kreadconfig --file kdeglobals --group General --key BrowserApplica
tion`" | 524 browser="`kreadconfig --file kdeglobals --group General --key BrowserApplica
tion`" |
524 if [ "$browser" ]; then | 525 if [ "$browser" ]; then |
525 echo "$browser" | 526 echo "$browser" |
526 fi | 527 fi |
527 # kreadconfig in KDE 4 may not notice Key[$*]=... localized settings, so che
ck | 528 # kreadconfig in KDE 4 may not notice Key[$*]=... localized settings, so che
ck |
528 # by hand if it didn't find anything (oddly kwriteconfig works fine though). | 529 # by hand if it didn't find anything (oddly kwriteconfig works fine though). |
529 kdeglobals="${KDE_HOME:-$HOME/.kde}/share/config/kdeglobals" | 530 kdeglobals_dir=`kde${KDE_SESSION_VERSION}-config --path config | cut -d ':'
-f 1` |
| 531 kdeglobals="$kdeglobals_dir/kdeglobals" |
530 [ ! -f "$kdeglobals" ] && return | 532 [ ! -f "$kdeglobals" ] && return |
531 # This will only take the first value if there is more than one. | 533 # This will only take the first value if there is more than one. |
532 grep '^BrowserApplication\[$[^]=]*\]=' "$kdeglobals" | head -n 1 | cut -d= -
f 2- | 534 grep '^BrowserApplication\[$[^]=]*\]=' "$kdeglobals" | head -n 1 | cut -d= -
f 2- |
533 } | 535 } |
534 | 536 |
535 get_browser_kde() | 537 get_browser_kde() |
536 { | 538 { |
537 browser="`read_kde_browser`" | 539 browser="`read_kde_browser`" |
538 if [ x"$browser" = x ]; then | 540 if [ x"$browser" = x ]; then |
539 # No explicit default browser; KDE will use the MIME type text/html. | 541 # No explicit default browser; KDE will use the MIME type text/html. |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
859 ;; | 861 ;; |
860 | 862 |
861 generic) | 863 generic) |
862 dispatch_generic "$@" | 864 dispatch_generic "$@" |
863 ;; | 865 ;; |
864 | 866 |
865 *) | 867 *) |
866 exit_failure_operation_impossible "unknown desktop environment" | 868 exit_failure_operation_impossible "unknown desktop environment" |
867 ;; | 869 ;; |
868 esac | 870 esac |
OLD | NEW |