Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: scripts/xdg-open

Issue 6735024: Linux: update xdg-utils again, and check in the built versions of the scripts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/xdg-utils/
Patch Set: Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « scripts/xdg-mime ('k') | scripts/xdg-open.in » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/bin/sh 1 #!/bin/sh
2 #--------------------------------------------- 2 #---------------------------------------------
3 # xdg-open 3 # xdg-open
4 # 4 #
5 # Utility script to open a URL in the registered default application. 5 # Utility script to open a URL in the registered default application.
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-2010, Fathi Boudra <fabo@freedesktop.org> 9 # Copyright 2009-2010, Fathi Boudra <fabo@freedesktop.org>
10 # Copyright 2009-2010, Rex Dieter <rdieter@fedoraproject.org> 10 # Copyright 2009-2010, Rex Dieter <rdieter@fedoraproject.org>
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 #-------------------------------------- 300 #--------------------------------------
301 # Checks for known desktop environments 301 # Checks for known desktop environments
302 # set variable DE to the desktop environments name, lowercase 302 # set variable DE to the desktop environments name, lowercase
303 303
304 detectDE() 304 detectDE()
305 { 305 {
306 if [ x"$KDE_FULL_SESSION" = x"true" ]; then DE=kde; 306 if [ x"$KDE_FULL_SESSION" = x"true" ]; then DE=kde;
307 elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE=gnome; 307 elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE=gnome;
308 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; 308 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;
309 elif xprop -root _DT_SAVE_MODE 2> /dev/null | grep ' = \"xfce4\"$' >/dev/nul l 2>&1; then DE=xfce; 309 elif xprop -root _DT_SAVE_MODE 2> /dev/null | grep ' = \"xfce4\"$' >/dev/nul l 2>&1; then DE=xfce;
310 elif [ x"$DESKTOP_SESSION" == x"LXDE" ]; then DE=lxde; 310 fi
311 else DE="" 311
312 if [ x"$DE" = x"" ]; then
313 # fallback to checking $DESKTOP_SESSION
314 case "$DESKTOP_SESSION" in
315 LXDE)
316 DE=lxde;
317 ;;
318 xfce|xfce4)
319 DE=xfce;
320 ;;
321 esac
322 fi
323
324 if [ x"$DE" = x"" ]; then
325 # fallback to uname output for other platforms
326 case "$(uname 2>/dev/null)" in
327 Darwin)
328 DE=darwin;
329 ;;
330 esac
331 fi
332
333 if [ x"$DE" = x"gnome" ]; then
334 # gnome-default-applications-properties is only available in GNOME 2.x
335 # but not in GNOME 3.x
336 which gnome-default-applications-properties 2> /dev/null || DE="gnome3"
312 fi 337 fi
313 } 338 }
314 339
315 #---------------------------------------------------------------------------- 340 #----------------------------------------------------------------------------
316 # kfmclient exec/openURL can give bogus exit value in KDE <= 3.5.4 341 # kfmclient exec/openURL can give bogus exit value in KDE <= 3.5.4
317 # It also always returns 1 in KDE 3.4 and earlier 342 # It also always returns 1 in KDE 3.4 and earlier
318 # Simply return 0 in such case 343 # Simply return 0 in such case
319 344
320 kfmclient_fix_exit_code() 345 kfmclient_fix_exit_code()
321 { 346 {
322 [ x"$KDE_SESSION_VERSION" = x"4" ] && return 0; 347 [ x"$KDE_SESSION_VERSION" = x"4" ] && return 0;
323 version=`LC_ALL=C.UTF-8 kde-config --version 2>/dev/null | grep '^KDE'` 348 version=`LC_ALL=C.UTF-8 kde-config --version 2>/dev/null | grep '^KDE'`
324 major=`echo $version | sed 's/KDE.*: \([0-9]\).*/\1/'` 349 major=`echo $version | sed 's/KDE.*: \([0-9]\).*/\1/'`
325 minor=`echo $version | sed 's/KDE.*: [0-9]*\.\([0-9]\).*/\1/'` 350 minor=`echo $version | sed 's/KDE.*: [0-9]*\.\([0-9]\).*/\1/'`
326 release=`echo $version | sed 's/KDE.*: [0-9]*\.[0-9]*\.\([0-9]\).*/\1/'` 351 release=`echo $version | sed 's/KDE.*: [0-9]*\.[0-9]*\.\([0-9]\).*/\1/'`
327 test "$major" -gt 3 && return $1 352 test "$major" -gt 3 && return $1
328 test "$minor" -gt 5 && return $1 353 test "$minor" -gt 5 && return $1
329 test "$release" -gt 4 && return $1 354 test "$release" -gt 4 && return $1
330 return 0 355 return 0
331 } 356 }
332 357
333 # This handles backslashes but not quote marks. 358 # This handles backslashes but not quote marks.
334 first_word() 359 first_word()
335 { 360 {
336 read first rest 361 read first rest
337 echo "$first" 362 echo "$first"
338 } 363 }
339 364
365 last_word()
366 {
367 read first rest
368 echo "$rest"
369 }
370
371 open_darwin()
372 {
373 open "$1"
374
375 if [ $? -eq 0 ]; then
376 exit_success
377 else
378 exit_failure_operation_failed
379 fi
380 }
381
340 open_kde() 382 open_kde()
341 { 383 {
342 if kde-open -v 2>/dev/null 1>&2; then 384 if kde-open -v 2>/dev/null 1>&2; then
343 kde-open "$1" 385 kde-open "$1"
344 else 386 else
345 if [ x"$KDE_SESSION_VERSION" = x"4" ]; then 387 if [ x"$KDE_SESSION_VERSION" = x"4" ]; then
346 kfmclient openURL "$1" 388 kfmclient openURL "$1"
347 else 389 else
348 kfmclient exec "$1" 390 kfmclient exec "$1"
349 kfmclient_fix_exit_code $? 391 kfmclient_fix_exit_code $?
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 filetype=`xdg-mime query filetype "$1" | sed "s/;.*//"` 430 filetype=`xdg-mime query filetype "$1" | sed "s/;.*//"`
389 default=`xdg-mime query default "$filetype"` 431 default=`xdg-mime query default "$filetype"`
390 if [ -n "$default" ] ; then 432 if [ -n "$default" ] ; then
391 xdg_user_dir="$XDG_DATA_HOME" 433 xdg_user_dir="$XDG_DATA_HOME"
392 [ -n "$xdg_user_dir" ] || xdg_user_dir="$HOME/.local/share" 434 [ -n "$xdg_user_dir" ] || xdg_user_dir="$HOME/.local/share"
393 435
394 xdg_system_dirs="$XDG_DATA_DIRS" 436 xdg_system_dirs="$XDG_DATA_DIRS"
395 [ -n "$xdg_system_dirs" ] || xdg_system_dirs=/usr/local/share/:/usr/shar e/ 437 [ -n "$xdg_system_dirs" ] || xdg_system_dirs=/usr/local/share/:/usr/shar e/
396 438
397 for x in `echo "$xdg_user_dir:$xdg_system_dirs" | sed 's/:/ /g'`; do 439 for x in `echo "$xdg_user_dir:$xdg_system_dirs" | sed 's/:/ /g'`; do
398 local file="$x/applications/$default" 440 local file
441 # look for both vendor-app.desktop, vendor/app.desktop
442 if [ -r "$x/applications/$default" ]; then
443 file="$x/applications/$default"
444 elif [ -r "$x/applications/`echo $default | sed -e 's|-|/|'`" ]; the n
445 file="$x/applications/`echo $default | sed -e 's|-|/|'`"
446 fi
447
399 if [ -r "$file" ] ; then 448 if [ -r "$file" ] ; then
400 command="`grep -E "^Exec(\[[^]=]*])?=" "$file" | cut -d= -f 2- | first_word`" 449 command="`grep -E "^Exec(\[[^]=]*])?=" "$file" | cut -d= -f 2- | first_word`"
401 command_exec=`which $command 2>/dev/null` 450 command_exec=`which $command 2>/dev/null`
451 arguments="`grep -E "^Exec(\[[^]=]*])?=" "$file" | cut -d= -f 2- | last_word`"
452 arguments_exec="`echo $arguments | sed -e 's*%[fFuU]*"'"$1"'"*g' `"
402 if [ -x "$command_exec" ] ; then 453 if [ -x "$command_exec" ] ; then
403 $command_exec "$1" 454 if echo $arguments | grep -iq '%[fFuU]' ; then
455 eval $command_exec $arguments_exec
456 else
457 eval $command_exec $arguments_exec "$1"
458 fi
459
404 if [ $? -eq 0 ]; then 460 if [ $? -eq 0 ]; then
405 exit_success 461 exit_success
406 fi 462 fi
407 fi 463 fi
408 fi 464 fi
409 done 465 done
410 fi 466 fi
411 } 467 }
412 468
413 open_generic() 469 open_generic()
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 if [ -n "$DISPLAY" ]; then 585 if [ -n "$DISPLAY" ]; then
530 BROWSER=firefox:mozilla:epiphany:konqueror:chromium-browser:google-chrom e:$BROWSER 586 BROWSER=firefox:mozilla:epiphany:konqueror:chromium-browser:google-chrom e:$BROWSER
531 fi 587 fi
532 fi 588 fi
533 589
534 case "$DE" in 590 case "$DE" in
535 kde) 591 kde)
536 open_kde "$url" 592 open_kde "$url"
537 ;; 593 ;;
538 594
539 gnome) 595 gnome*)
540 open_gnome "$url" 596 open_gnome "$url"
541 ;; 597 ;;
542 598
543 xfce) 599 xfce)
544 open_xfce "$url" 600 open_xfce "$url"
545 ;; 601 ;;
546 602
547 lxde) 603 lxde)
548 open_lxde "$url" 604 open_lxde "$url"
549 ;; 605 ;;
550 606
551 generic) 607 generic)
552 open_generic "$url" 608 open_generic "$url"
553 ;; 609 ;;
554 610
555 *) 611 *)
556 exit_failure_operation_impossible "no method available for opening '$url'" 612 exit_failure_operation_impossible "no method available for opening '$url'"
557 ;; 613 ;;
558 esac 614 esac
OLDNEW
« no previous file with comments | « scripts/xdg-mime ('k') | scripts/xdg-open.in » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698