45 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			45 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
| #!/bin/bash
 | |
| # -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
 | |
| source "$(dirname "$0")/lib/ulib/ulib" || exit 1
 | |
| urequire DEFAULTS
 | |
| 
 | |
| # faut-il supprimer la sortie erreur? les warnings de GTK sont horripilants.
 | |
| : "${OPENURL_STDERR:=}"
 | |
| 
 | |
| function display_help() {
 | |
|     uecho "$scriptname: Ouvrir une URL dans un navigateur
 | |
| 
 | |
| USAGE
 | |
|     $scriptname <file.url|file.desktop|URL>"
 | |
| }
 | |
| 
 | |
| parse_opts "${PRETTYOPTS[@]}" \
 | |
|     --help '$exit_with display_help' \
 | |
|     @ args -- "$@" && set -- "${args[@]}" || die "$args"
 | |
| 
 | |
| "$scriptdir/caturl" --check "$1"
 | |
| case $? in
 | |
| 2) die "Vous devez spécifier l'url à ouvrir";;
 | |
| 3) die "Le fichier spécifié ne contient pas d'url";;
 | |
| esac
 | |
| setx url="$scriptdir/caturl" "$1" || die
 | |
| 
 | |
| if progexists xdg-open; then
 | |
|     if [ -n "$OPENURL_STDERR" ]; then
 | |
|         exec xdg-open "$url"
 | |
|     else
 | |
|         exec xdg-open "$url" 2>/dev/null
 | |
|     fi
 | |
| elif progexists gnome-open; then
 | |
|     if [ -n "$OPENURL_STDERR" ]; then
 | |
|         exec gnome-open "$url"
 | |
|     else
 | |
|         exec gnome-open "$url" 2>/dev/null
 | |
|     fi
 | |
| elif check_sysinfos -s macosx; then
 | |
|     # si on est sur un MacOSX, utiliser open
 | |
|     exec open "$url"
 | |
| fi
 | |
| 
 | |
| die "Impossible de trouver une méthode pour ouvrir l'url $url"
 |