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 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 | 480 |
481 #-------------------------------------- | 481 #-------------------------------------- |
482 # Checks for known desktop environments | 482 # Checks for known desktop environments |
483 # set variable DE to the desktop environments name, lowercase | 483 # set variable DE to the desktop environments name, lowercase |
484 | 484 |
485 detectDE() | 485 detectDE() |
486 { | 486 { |
487 # see https://bugs.freedesktop.org/show_bug.cgi?id=34164 | 487 # see https://bugs.freedesktop.org/show_bug.cgi?id=34164 |
488 unset GREP_OPTIONS | 488 unset GREP_OPTIONS |
489 | 489 |
490 if [ x"$KDE_FULL_SESSION" = x"true" ]; then DE=kde; | 490 if [ -n "${XDG_CURRENT_DESKTOP}" ]; then |
491 elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE=gnome; | 491 case "${XDG_CURRENT_DESKTOP}" in |
492 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; | 492 GNOME) |
493 elif xprop -root _DT_SAVE_MODE 2> /dev/null | grep ' = \"xfce4\"$' >/dev/nul
l 2>&1; then DE=xfce; | 493 DE=gnome; |
494 elif xprop -root 2> /dev/null | grep -i '^xfce_desktop_window' >/dev/null 2>
&1; then DE=xfce | 494 ;; |
| 495 KDE) |
| 496 DE=kde; |
| 497 ;; |
| 498 LXDE) |
| 499 DE=lxde; |
| 500 ;; |
| 501 XFCE) |
| 502 DE=xfce |
| 503 esac |
| 504 fi |
| 505 |
| 506 if [ x"$DE" = x"" ]; then |
| 507 # classic fallbacks |
| 508 if [ x"$KDE_FULL_SESSION" = x"true" ]; then DE=kde; |
| 509 elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE=gnome; |
| 510 elif `dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop
/DBus org.freedesktop.DBus.GetNameOwner string:org.gnome.SessionManager > /dev/n
ull 2>&1` ; then DE=gnome; |
| 511 elif xprop -root _DT_SAVE_MODE 2> /dev/null | grep ' = \"xfce4\"$' >/dev/n
ull 2>&1; then DE=xfce; |
| 512 elif xprop -root 2> /dev/null | grep -i '^xfce_desktop_window' >/dev/null
2>&1; then DE=xfce |
| 513 fi |
495 fi | 514 fi |
496 | 515 |
497 if [ x"$DE" = x"" ]; then | 516 if [ x"$DE" = x"" ]; then |
498 # fallback to checking $DESKTOP_SESSION | 517 # fallback to checking $DESKTOP_SESSION |
499 case "$DESKTOP_SESSION" in | 518 case "$DESKTOP_SESSION" in |
500 gnome) | 519 gnome) |
501 DE=gnome; | 520 DE=gnome; |
502 ;; | 521 ;; |
503 LXDE) | 522 LXDE) |
504 DE=lxde; | 523 DE=lxde; |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
602 exit_failure_operation_failed | 621 exit_failure_operation_failed |
603 fi | 622 fi |
604 } | 623 } |
605 | 624 |
606 info_generic() | 625 info_generic() |
607 { | 626 { |
608 if mimetype --version >/dev/null 2>&1; then | 627 if mimetype --version >/dev/null 2>&1; then |
609 DEBUG 1 "Running mimetype -b \"$1\"" | 628 DEBUG 1 "Running mimetype -b \"$1\"" |
610 mimetype -b "$1" | 629 mimetype -b "$1" |
611 else | 630 else |
612 DEBUG 1 "Running file -i \"$1\"" | 631 DEBUG 1 "Running file --mime-type \"$1\"" |
613 /usr/bin/file -i "$1" 2> /dev/null | cut -d ":" -f 2 | sed s/"^ "// | 632 /usr/bin/file --mime-type "$1" 2> /dev/null | cut -d ":" -f 2 | sed s/"^
"// |
614 fi | 633 fi |
615 | 634 |
616 if [ $? -eq 0 ]; then | 635 if [ $? -eq 0 ]; then |
617 exit_success | 636 exit_success |
618 else | 637 else |
619 exit_failure_operation_failed | 638 exit_failure_operation_failed |
620 fi | 639 fi |
621 } | 640 } |
622 | 641 |
623 make_default_kde() | 642 make_default_kde() |
(...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1374 rm -f $kde_dir/$x.desktop | 1393 rm -f $kde_dir/$x.desktop |
1375 fi | 1394 fi |
1376 done | 1395 done |
1377 ;; | 1396 ;; |
1378 esac | 1397 esac |
1379 | 1398 |
1380 update_mime_database $xdg_base_dir | 1399 update_mime_database $xdg_base_dir |
1381 | 1400 |
1382 exit_success | 1401 exit_success |
1383 | 1402 |
OLD | NEW |