| OLD | NEW |
| 1 #!/bin/sh | 1 #!/bin/sh |
| 2 #--------------------------------------------- | 2 #--------------------------------------------- |
| 3 # xdg-desktop-icon | 3 # xdg-desktop-icon |
| 4 # | 4 # |
| 5 # Utility script to install desktop items on a Linux desktop. | 5 # Utility script to install desktop items on a Linux desktop. |
| 6 # | 6 # |
| 7 # Refer to the usage() function below for usage. | 7 # Refer to the usage() function below for usage. |
| 8 # | 8 # |
| 9 # Copyright 2006, Kevin Krammer <kevin.krammer@gmx.at> | 9 # Copyright 2006, Kevin Krammer <kevin.krammer@gmx.at> |
| 10 # Copyright 2006, Jeremy White <jwhite@codeweavers.com> | 10 # Copyright 2006, Jeremy White <jwhite@codeweavers.com> |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 exit_failure_file_permission_read() | 294 exit_failure_file_permission_read() |
| 295 { | 295 { |
| 296 if [ $# -gt 0 ]; then | 296 if [ $# -gt 0 ]; then |
| 297 echo "xdg-desktop-icon: $@" >&2 | 297 echo "xdg-desktop-icon: $@" >&2 |
| 298 fi | 298 fi |
| 299 | 299 |
| 300 exit 5 | 300 exit 5 |
| 301 } | 301 } |
| 302 | 302 |
| 303 #------------------------------------------------------------ | 303 #------------------------------------------------------------ |
| 304 # Exit script on insufficient permission to read a specified file | 304 # Exit script on insufficient permission to write a specified file |
| 305 | 305 |
| 306 exit_failure_file_permission_write() | 306 exit_failure_file_permission_write() |
| 307 { | 307 { |
| 308 if [ $# -gt 0 ]; then | 308 if [ $# -gt 0 ]; then |
| 309 echo "xdg-desktop-icon: $@" >&2 | 309 echo "xdg-desktop-icon: $@" >&2 |
| 310 fi | 310 fi |
| 311 | 311 |
| 312 exit 6 | 312 exit 6 |
| 313 } | 313 } |
| 314 | 314 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 echo "Use 'man xdg-desktop-icon' or 'xdg-desktop-icon --manual' for
additional info." | 371 echo "Use 'man xdg-desktop-icon' or 'xdg-desktop-icon --manual' for
additional info." |
| 372 exit_success | 372 exit_success |
| 373 ;; | 373 ;; |
| 374 | 374 |
| 375 --manual) | 375 --manual) |
| 376 manualpage | 376 manualpage |
| 377 exit_success | 377 exit_success |
| 378 ;; | 378 ;; |
| 379 | 379 |
| 380 --version) | 380 --version) |
| 381 echo "xdg-desktop-icon 1.0.1" | 381 echo "xdg-desktop-icon 1.0.2" |
| 382 exit_success | 382 exit_success |
| 383 ;; | 383 ;; |
| 384 esac | 384 esac |
| 385 done | 385 done |
| 386 } | 386 } |
| 387 | 387 |
| 388 check_common_commands "$@" | 388 check_common_commands "$@" |
| 389 | 389 |
| 390 [ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && unset XDG_UTILS_DEBUG_LEVEL; | 390 [ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && unset XDG_UTILS_DEBUG_LEVEL; |
| 391 if [ ${XDG_UTILS_DEBUG_LEVEL-0} -lt 1 ]; then | 391 if [ ${XDG_UTILS_DEBUG_LEVEL-0} -lt 1 ]; then |
| 392 # Be silent | 392 # Be silent |
| 393 xdg_redirect_output=" > /dev/null 2> /dev/null" | 393 xdg_redirect_output=" > /dev/null 2> /dev/null" |
| 394 else | 394 else |
| 395 # All output to stderr | 395 # All output to stderr |
| 396 xdg_redirect_output=" >&2" | 396 xdg_redirect_output=" >&2" |
| 397 fi | 397 fi |
| 398 | 398 |
| 399 #-------------------------------------- | 399 #-------------------------------------- |
| 400 # Checks for known desktop environments | 400 # Checks for known desktop environments |
| 401 # set variable DE to the desktop environments name, lowercase | 401 # set variable DE to the desktop environments name, lowercase |
| 402 | 402 |
| 403 detectDE() | 403 detectDE() |
| 404 { | 404 { |
| 405 if [ x"$KDE_FULL_SESSION" = x"true" ]; then DE=kde; | 405 if [ x"$KDE_FULL_SESSION" = x"true" ]; then DE=kde; |
| 406 elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE=gnome; | 406 elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE=gnome; |
| 407 elif xprop -root _DT_SAVE_MODE | grep ' = \"xfce4\"$' >/dev/null 2>&1; then
DE=xfce; | 407 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; |
| 408 elif xprop -root _DT_SAVE_MODE 2> /dev/null | grep ' = \"xfce4\"$' >/dev/nul
l 2>&1; then DE=xfce; |
| 408 fi | 409 fi |
| 409 } | 410 } |
| 410 | 411 |
| 411 #---------------------------------------------------------------------------- | 412 #---------------------------------------------------------------------------- |
| 412 # kfmclient exec/openURL can give bogus exit value in KDE <= 3.5.4 | 413 # kfmclient exec/openURL can give bogus exit value in KDE <= 3.5.4 |
| 413 # It also always returns 1 in KDE 3.4 and earlier | 414 # It also always returns 1 in KDE 3.4 and earlier |
| 414 # Simply return 0 in such case | 415 # Simply return 0 in such case |
| 415 | 416 |
| 416 kfmclient_fix_exit_code() | 417 kfmclient_fix_exit_code() |
| 417 { | 418 { |
| 418 version=`kde${KDE_SESSION_VERSION}-config --version 2>/dev/null | grep KDE` | 419 version=`kde${KDE_SESSION_VERSION}-config --version 2>/dev/null | grep KDE` |
| 419 major=`echo $version | sed 's/KDE: \([0-9]\).*/\1/'` | 420 major=`echo $version | sed 's/KDE: \([0-9]\).*/\1/'` |
| 420 minor=`echo $version | sed 's/KDE: [0-9]*\.\([0-9]\).*/\1/'` | 421 minor=`echo $version | sed 's/KDE: [0-9]*\.\([0-9]\).*/\1/'` |
| 421 release=`echo $version | sed 's/KDE: [0-9]*\.[0-9]*\.\([0-9]\).*/\1/'` | 422 release=`echo $version | sed 's/KDE: [0-9]*\.[0-9]*\.\([0-9]\).*/\1/'` |
| 422 test "$major" -gt 3 && return $1 | 423 test "$major" -gt 3 && return $1 |
| 423 test "$minor" -gt 5 && return $1 | 424 test "$minor" -gt 5 && return $1 |
| 424 test "$release" -gt 4 && return $1 | 425 test "$release" -gt 4 && return $1 |
| 425 return 0 | 426 return 0 |
| 426 } | 427 } |
| 427 | 428 |
| 428 [ x"$1" != x"" ] || exit_failure_syntax | 429 [ x"$1" != x"" ] || exit_failure_syntax |
| 429 | 430 |
| 430 action= | 431 action= |
| 431 desktop_file= | 432 desktop_file= |
| 432 | 433 |
| 433 case $1 in | 434 case $1 in |
| 434 install) | 435 install) |
| 435 action=install | 436 action=install |
| 436 ;; | 437 ;; |
| 437 | 438 |
| 438 uninstall) | 439 uninstall) |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 # Shouldn't happen | 476 # Shouldn't happen |
| 476 if [ -z "$action" ] ; then | 477 if [ -z "$action" ] ; then |
| 477 exit_failure_syntax "command argument missing" | 478 exit_failure_syntax "command argument missing" |
| 478 fi | 479 fi |
| 479 | 480 |
| 480 if [ -z "$desktop_file" ] ; then | 481 if [ -z "$desktop_file" ] ; then |
| 481 exit_failure_syntax "FILE argument missing" | 482 exit_failure_syntax "FILE argument missing" |
| 482 fi | 483 fi |
| 483 | 484 |
| 484 filetype= | 485 filetype= |
| 485 case $desktop_file in | 486 case "$desktop_file" in |
| 486 *.desktop) | 487 *.desktop) |
| 487 filetype=desktop | 488 filetype=desktop |
| 488 if [ "$vendor" = "true" -a "$action" = "install" ] ; then | 489 if [ "$vendor" = "true" -a "$action" = "install" ] ; then |
| 489 check_vendor_prefix "$desktop_file" | 490 check_vendor_prefix "$desktop_file" |
| 490 fi | 491 fi |
| 491 ;; | 492 ;; |
| 492 *) | 493 *) |
| 493 filetype=other | 494 filetype=other |
| 494 ;; | 495 ;; |
| 495 esac | 496 esac |
| 496 | 497 |
| 497 my_umask=077 | 498 my_umask=077 |
| 498 desktop_dir="$HOME/Desktop" | 499 if xdg-user-dir 2>/dev/null 1>&2; then |
| 500 desktop_dir=`xdg-user-dir DESKTOP` |
| 501 fi |
| 499 desktop_dir_kde=`kde${KDE_SESSION_VERSION}-config --userpath desktop 2> /dev/nul
l` | 502 desktop_dir_kde=`kde${KDE_SESSION_VERSION}-config --userpath desktop 2> /dev/nul
l` |
| 500 if gconftool-2 -g /apps/nautilus/preferences/desktop_is_home_dir 2> /dev/null |
grep true > /dev/null; then | 503 if gconftool-2 -g /apps/nautilus/preferences/desktop_is_home_dir 2> /dev/null |
grep true > /dev/null; then |
| 501 desktop_dir_gnome="$HOME" | 504 desktop_dir_gnome="$HOME" |
| 502 # Don't create $HOME/Desktop if it doesn't exist | 505 # Don't create $HOME/Desktop if it doesn't exist |
| 503 [ -w $desktop_dir ] || desktop_dir= | 506 [ -w "$desktop_dir" ] || desktop_dir= |
| 504 fi | 507 fi |
| 505 if [ -n "$desktop_dir_kde" ]; then | 508 if [ -n "$desktop_dir_kde" ]; then |
| 506 if [ ! -d "$desktop_dir_kde" ]; then | 509 if [ ! -d "$desktop_dir_kde" ]; then |
| 507 save_umask=`umask` | 510 save_umask=`umask` |
| 508 umask $my_umask | 511 umask $my_umask |
| 509 mkdir -p $desktop_dir_kde | 512 mkdir -p "$desktop_dir_kde" |
| 510 umask $save_umask | 513 umask $save_umask |
| 511 fi | 514 fi |
| 512 # Is the KDE desktop dir != $HOME/Desktop ? | 515 # Is the KDE desktop dir != $HOME/Desktop ? |
| 513 if [ x`readlink -f "$desktop_dir"` != x`readlink -f "$desktop_dir_kde"` ]; t
hen | 516 if [ x`readlink -f "$desktop_dir"` != x`readlink -f "$desktop_dir_kde"` ]; t
hen |
| 514 # If so, don't create $HOME/Desktop if it doesn't exist | 517 # If so, don't create $HOME/Desktop if it doesn't exist |
| 515 [ -w $desktop_dir ] || desktop_dir= | 518 [ -w "$desktop_dir" ] || desktop_dir= |
| 516 else | 519 else |
| 517 desktop_dir_kde= | 520 desktop_dir_kde= |
| 518 fi | 521 fi |
| 519 fi | 522 fi |
| 520 desktop_dir="$desktop_dir $desktop_dir_kde $desktop_dir_gnome" | |
| 521 | 523 |
| 522 basefile=`basename "$desktop_file"` | 524 basefile=`basename "$desktop_file"` |
| 523 | 525 |
| 524 DEBUG 1 "$action $desktop_file in $desktop_dir" | 526 DEBUG 1 "$action $desktop_file in $desktop_dir $desktop_dir_kde $desktop_dir_gno
me" |
| 525 | 527 |
| 526 case $action in | 528 case $action in |
| 527 install) | 529 install) |
| 528 save_umask=`umask` | 530 save_umask=`umask` |
| 529 umask $my_umask | 531 umask $my_umask |
| 530 | 532 |
| 531 for x in $desktop_dir ; do | 533 for x in "$desktop_dir" "$desktop_dir_kde" "$desktop_dir_gnome" ; do |
| 532 mkdir -p $x | 534 if [ -n "$x" ]; then |
| 533 eval 'cp $desktop_file $x/$basefile'$xdg_redirect_output | 535 mkdir -p "$x" |
| 536 eval 'cp "$desktop_file" "$x/$basefile"'$xdg_redirect_output |
| 537 fi |
| 534 done | 538 done |
| 535 | 539 |
| 536 umask $save_umask | 540 umask $save_umask |
| 537 ;; | 541 ;; |
| 538 | 542 |
| 539 uninstall) | 543 uninstall) |
| 540 for x in $desktop_dir ; do | 544 for x in "$desktop_dir" "$desktop_dir_kde" "$desktop_dir_gnome" ; do |
| 541 rm -f $x/$basefile | 545 if [ -n "$x" ]; then |
| 546 rm -f "$x/$basefile" |
| 547 fi |
| 542 done | 548 done |
| 543 | |
| 544 ;; | 549 ;; |
| 545 esac | 550 esac |
| 546 | 551 |
| 547 exit_success | 552 exit_success |
| 548 | 553 |
| 549 | 554 |
| OLD | NEW |