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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 if [ x"$KDE_FULL_SESSION" = x"true" ]; then DE=kde; | 359 if [ x"$KDE_FULL_SESSION" = x"true" ]; then DE=kde; |
360 elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE=gnome; | 360 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; | 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; |
362 elif xprop -root _DT_SAVE_MODE 2> /dev/null | grep ' = \"xfce4\"$' >/dev/nul
l 2>&1; then DE=xfce; | 362 elif xprop -root _DT_SAVE_MODE 2> /dev/null | grep ' = \"xfce4\"$' >/dev/nul
l 2>&1; then DE=xfce; |
363 elif [ x"$DESKTOP_SESSION" == x"LXDE" ]; then DE=lxde; | 363 fi |
364 else DE="" | 364 |
| 365 if [ x"$DE" = x"" ]; then |
| 366 # fallback to checking $DESKTOP_SESSION |
| 367 case "$DESKTOP_SESSION" in |
| 368 LXDE) |
| 369 DE=lxde; |
| 370 ;; |
| 371 xfce|xfce4) |
| 372 DE=xfce; |
| 373 ;; |
| 374 esac |
| 375 fi |
| 376 |
| 377 if [ x"$DE" = x"" ]; then |
| 378 # fallback to uname output for other platforms |
| 379 case "$(uname 2>/dev/null)" in |
| 380 Darwin) |
| 381 DE=darwin; |
| 382 ;; |
| 383 esac |
| 384 fi |
| 385 |
| 386 if [ x"$DE" = x"gnome" ]; then |
| 387 # gnome-default-applications-properties is only available in GNOME 2.x |
| 388 # but not in GNOME 3.x |
| 389 which gnome-default-applications-properties 2> /dev/null || DE="gnome3" |
365 fi | 390 fi |
366 } | 391 } |
367 | 392 |
368 #---------------------------------------------------------------------------- | 393 #---------------------------------------------------------------------------- |
369 # kfmclient exec/openURL can give bogus exit value in KDE <= 3.5.4 | 394 # kfmclient exec/openURL can give bogus exit value in KDE <= 3.5.4 |
370 # It also always returns 1 in KDE 3.4 and earlier | 395 # It also always returns 1 in KDE 3.4 and earlier |
371 # Simply return 0 in such case | 396 # Simply return 0 in such case |
372 | 397 |
373 kfmclient_fix_exit_code() | 398 kfmclient_fix_exit_code() |
374 { | 399 { |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 LC_ALL=C.UTF-8 $KMAILSERVICE "$1" | 491 LC_ALL=C.UTF-8 $KMAILSERVICE "$1" |
467 kfmclient_fix_exit_code $? | 492 kfmclient_fix_exit_code $? |
468 | 493 |
469 if [ $? -eq 0 ]; then | 494 if [ $? -eq 0 ]; then |
470 exit_success | 495 exit_success |
471 else | 496 else |
472 exit_failure_operation_failed | 497 exit_failure_operation_failed |
473 fi | 498 fi |
474 } | 499 } |
475 | 500 |
| 501 open_gnome3() |
| 502 { |
| 503 local client |
| 504 local desktop |
| 505 desktop=`xdg-mime query default "x-scheme-handler/mailto"` |
| 506 client=`desktop_file_to_binary "$browser"` |
| 507 echo $client | grep thunderbird > /dev/null 2>&1 |
| 508 if [ $? -eq 0 ] ; then |
| 509 run_thunderbird "$client" "$1" |
| 510 fi |
| 511 |
| 512 if gvfs-open --help 2>/dev/null 1>&2; then |
| 513 DEBUG 1 "Running gvfs-open \"$1\"" |
| 514 gvfs-open "$1" |
| 515 else |
| 516 DEBUG 1 "Running gnome-open \"$1\"" |
| 517 gnome-open "$1" |
| 518 fi |
| 519 |
| 520 if [ $? -eq 0 ]; then |
| 521 exit_success |
| 522 else |
| 523 exit_failure_operation_failed |
| 524 fi |
| 525 } |
| 526 |
476 open_gnome() | 527 open_gnome() |
477 { | 528 { |
478 local client | 529 local client |
479 client=`gconftool-2 --get /desktop/gnome/url-handlers/mailto/command | cut -
d ' ' -f 1` || "" | 530 client=`gconftool-2 --get /desktop/gnome/url-handlers/mailto/command | cut -
d ' ' -f 1` || "" |
480 echo $client | grep thunderbird > /dev/null 2>&1 | 531 echo $client | grep thunderbird > /dev/null 2>&1 |
481 if [ $? -eq 0 ] ; then | 532 if [ $? -eq 0 ] ; then |
482 run_thunderbird "$client" "$1" | 533 run_thunderbird "$client" "$1" |
483 fi | 534 fi |
484 | 535 |
485 if gvfs-open --help 2>/dev/null 1>&2; then | 536 if gvfs-open --help 2>/dev/null 1>&2; then |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 | 757 |
707 case "$DE" in | 758 case "$DE" in |
708 kde) | 759 kde) |
709 open_kde "${mailto}" | 760 open_kde "${mailto}" |
710 ;; | 761 ;; |
711 | 762 |
712 gnome) | 763 gnome) |
713 open_gnome "${mailto}" | 764 open_gnome "${mailto}" |
714 ;; | 765 ;; |
715 | 766 |
| 767 gnome3) |
| 768 open_gnome3 "${mailto}" |
| 769 ;; |
| 770 |
716 xfce) | 771 xfce) |
717 open_xfce "${mailto}" | 772 open_xfce "${mailto}" |
718 ;; | 773 ;; |
719 | 774 |
720 generic|lxde) | 775 generic|lxde) |
721 open_generic "${mailto}" | 776 open_generic "${mailto}" |
722 ;; | 777 ;; |
723 | 778 |
724 *) | 779 *) |
725 exit_failure_operation_impossible "no method available for opening '${mailto
}'" | 780 exit_failure_operation_impossible "no method available for opening '${mailto
}'" |
726 ;; | 781 ;; |
727 esac | 782 esac |
OLD | NEW |