OLD | NEW |
1 #!/bin/sh | 1 #!/bin/sh |
2 #--------------------------------------------- | 2 #--------------------------------------------- |
3 # xdg-email | 3 # xdg-email |
4 # | 4 # |
5 # Utility script to open the users favorite email program, using the | 5 # Utility script to open the users favorite email program, using the |
6 # RFC 2368 mailto: URI spec | 6 # RFC 2368 mailto: URI spec |
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 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 # All output to stderr | 349 # All output to stderr |
350 xdg_redirect_output=" >&2" | 350 xdg_redirect_output=" >&2" |
351 fi | 351 fi |
352 | 352 |
353 #-------------------------------------- | 353 #-------------------------------------- |
354 # Checks for known desktop environments | 354 # Checks for known desktop environments |
355 # set variable DE to the desktop environments name, lowercase | 355 # set variable DE to the desktop environments name, lowercase |
356 | 356 |
357 detectDE() | 357 detectDE() |
358 { | 358 { |
| 359 # see https://bugs.freedesktop.org/show_bug.cgi?id=34164 |
| 360 unset GREP_OPTIONS |
| 361 |
359 if [ x"$KDE_FULL_SESSION" = x"true" ]; then DE=kde; | 362 if [ x"$KDE_FULL_SESSION" = x"true" ]; then DE=kde; |
360 elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE=gnome; | 363 elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE=gnome; |
361 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; | 364 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; |
362 elif xprop -root _DT_SAVE_MODE 2> /dev/null | grep ' = \"xfce4\"$' >/dev/nul
l 2>&1; then DE=xfce; | 365 elif xprop -root _DT_SAVE_MODE 2> /dev/null | grep ' = \"xfce4\"$' >/dev/nul
l 2>&1; then DE=xfce; |
| 366 elif xprop -root 2> /dev/null | grep -i '^xfce_desktop_window' >/dev/null 2>
&1; then DE=xfce |
363 fi | 367 fi |
364 | 368 |
365 if [ x"$DE" = x"" ]; then | 369 if [ x"$DE" = x"" ]; then |
366 # fallback to checking $DESKTOP_SESSION | 370 # fallback to checking $DESKTOP_SESSION |
367 case "$DESKTOP_SESSION" in | 371 case "$DESKTOP_SESSION" in |
| 372 gnome) |
| 373 DE=gnome; |
368 LXDE) | 374 LXDE) |
369 DE=lxde; | 375 DE=lxde; |
370 ;; | 376 ;; |
371 xfce|xfce4) | 377 xfce|xfce4) |
372 DE=xfce; | 378 DE=xfce; |
373 ;; | 379 ;; |
374 esac | 380 esac |
375 fi | 381 fi |
376 | 382 |
377 if [ x"$DE" = x"" ]; then | 383 if [ x"$DE" = x"" ]; then |
(...skipping 12 matching lines...) Expand all Loading... |
390 fi | 396 fi |
391 } | 397 } |
392 | 398 |
393 #---------------------------------------------------------------------------- | 399 #---------------------------------------------------------------------------- |
394 # kfmclient exec/openURL can give bogus exit value in KDE <= 3.5.4 | 400 # kfmclient exec/openURL can give bogus exit value in KDE <= 3.5.4 |
395 # It also always returns 1 in KDE 3.4 and earlier | 401 # It also always returns 1 in KDE 3.4 and earlier |
396 # Simply return 0 in such case | 402 # Simply return 0 in such case |
397 | 403 |
398 kfmclient_fix_exit_code() | 404 kfmclient_fix_exit_code() |
399 { | 405 { |
400 [ x"$KDE_SESSION_VERSION" = x"4" ] && return 0; | |
401 version=`LC_ALL=C.UTF-8 kde-config --version 2>/dev/null | grep '^KDE'` | 406 version=`LC_ALL=C.UTF-8 kde-config --version 2>/dev/null | grep '^KDE'` |
402 major=`echo $version | sed 's/KDE.*: \([0-9]\).*/\1/'` | 407 major=`echo $version | sed 's/KDE.*: \([0-9]\).*/\1/'` |
403 minor=`echo $version | sed 's/KDE.*: [0-9]*\.\([0-9]\).*/\1/'` | 408 minor=`echo $version | sed 's/KDE.*: [0-9]*\.\([0-9]\).*/\1/'` |
404 release=`echo $version | sed 's/KDE.*: [0-9]*\.[0-9]*\.\([0-9]\).*/\1/'` | 409 release=`echo $version | sed 's/KDE.*: [0-9]*\.[0-9]*\.\([0-9]\).*/\1/'` |
405 test "$major" -gt 3 && return $1 | 410 test "$major" -gt 3 && return $1 |
406 test "$minor" -gt 5 && return $1 | 411 test "$minor" -gt 5 && return $1 |
407 test "$release" -gt 4 && return $1 | 412 test "$release" -gt 4 && return $1 |
408 return 0 | 413 return 0 |
409 } | 414 } |
410 | 415 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 DEBUG 3 "KDE has $client configured as email client which isn't inst
alled" | 482 DEBUG 3 "KDE has $client configured as email client which isn't inst
alled" |
478 if which gnome-open > /dev/null 2> /dev/null && which evolution > /d
ev/null 2> /dev/null; then | 483 if which gnome-open > /dev/null 2> /dev/null && which evolution > /d
ev/null 2> /dev/null; then |
479 DEBUG 3 "Try gnome-open instead" | 484 DEBUG 3 "Try gnome-open instead" |
480 open_gnome "$1" | 485 open_gnome "$1" |
481 fi | 486 fi |
482 fi | 487 fi |
483 fi | 488 fi |
484 DEBUG 1 "Running kmailservice \"$1\"" | 489 DEBUG 1 "Running kmailservice \"$1\"" |
485 if [ x"$KDE_SESSION_VERSION" = x"4" ]; then | 490 if [ x"$KDE_SESSION_VERSION" = x"4" ]; then |
486 KMAILSERVICE=`kde4-config --locate kmailservice --path exe 2>/dev/null` | 491 KMAILSERVICE=`kde4-config --locate kmailservice --path exe 2>/dev/null` |
| 492 $KMAILSERVICE "$1" |
487 else | 493 else |
488 KMAILSERVICE=`which kmailservice 2>/dev/null` | 494 KMAILSERVICE=`which kmailservice 2>/dev/null` |
| 495 # KDE3 uses locale's encoding when decoding the URI, so set it to UTF-8 |
| 496 LC_ALL=C.UTF-8 $KMAILSERVICE "$1" |
489 fi | 497 fi |
490 # KDE uses locale's encoding when decoding the URI, so set it to UTF-8 | |
491 LC_ALL=C.UTF-8 $KMAILSERVICE "$1" | |
492 kfmclient_fix_exit_code $? | |
493 | 498 |
494 if [ $? -eq 0 ]; then | 499 if [ $? -eq 0 ]; then |
495 exit_success | 500 exit_success |
496 else | 501 else |
497 exit_failure_operation_failed | 502 exit_failure_operation_failed |
498 fi | 503 fi |
499 } | 504 } |
500 | 505 |
501 open_gnome3() | 506 open_gnome3() |
502 { | 507 { |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
742 fi | 747 fi |
743 | 748 |
744 detectDE | 749 detectDE |
745 | 750 |
746 if [ x"$DE" = x"" ]; then | 751 if [ x"$DE" = x"" ]; then |
747 DE=generic | 752 DE=generic |
748 fi | 753 fi |
749 | 754 |
750 # if BROWSER variable is not set, check some well known browsers instead | 755 # if BROWSER variable is not set, check some well known browsers instead |
751 if [ x"$BROWSER" = x"" ]; then | 756 if [ x"$BROWSER" = x"" ]; then |
752 BROWSER=links2:links:lynx:w3m | 757 BROWSER=links2:elinks:links:lynx:w3m |
753 if [ -n "$DISPLAY" ]; then | 758 if [ -n "$DISPLAY" ]; then |
754 BROWSER=firefox:mozilla:epiphany:konqueror:chromium-browser:google-chrom
e:$BROWSER | 759 BROWSER=x-www-browser:firefox:seamonkey:mozilla:epiphany:konqueror:chrom
ium-browser:google-chrome:$BROWSER |
755 fi | 760 fi |
756 fi | 761 fi |
757 | 762 |
758 case "$DE" in | 763 case "$DE" in |
759 kde) | 764 kde) |
760 open_kde "${mailto}" | 765 open_kde "${mailto}" |
761 ;; | 766 ;; |
762 | 767 |
763 gnome) | 768 gnome) |
764 open_gnome "${mailto}" | 769 open_gnome "${mailto}" |
765 ;; | 770 ;; |
766 | 771 |
767 gnome3) | 772 gnome3) |
768 open_gnome3 "${mailto}" | 773 open_gnome3 "${mailto}" |
769 ;; | 774 ;; |
770 | 775 |
771 xfce) | 776 xfce) |
772 open_xfce "${mailto}" | 777 open_xfce "${mailto}" |
773 ;; | 778 ;; |
774 | 779 |
775 generic|lxde) | 780 generic|lxde) |
776 open_generic "${mailto}" | 781 open_generic "${mailto}" |
777 ;; | 782 ;; |
778 | 783 |
779 *) | 784 *) |
780 exit_failure_operation_impossible "no method available for opening '${mailto
}'" | 785 exit_failure_operation_impossible "no method available for opening '${mailto
}'" |
781 ;; | 786 ;; |
782 esac | 787 esac |
OLD | NEW |