aboutsummaryrefslogblamecommitdiff
path: root/bin/xgo
blob: e808027c58d5561e0534d013d66d7cd98597873a (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13












                                                                           

                                          
                                 


              


                            



                                                     
                                          


              


                                      
#!/bin/sh
# Test and open a clipboard URL with an apt program

# Check arguments
if [ "$#" -eq 0 ] ; then
    printf 2>&1 'xgo: At least one URL required\n'
fi

# Iterate over the URL arguments
for url ; do (

    # If it's a YouTube video without a given start time, load it in mpv(1)
    case $url in
        *[/.]youtube.com/watch*[?\&]t=) ;;
        *[/.]youtube.com/watch*)
            mpv -- "$url" && exit
            ;;
    esac

    # Get the MIME type data
    mt=$(urlmt "$url")

    # If the MIME type is an image, load it in feh(1)
    case $mt in
        image/gif) ;;
        image/*)
            curl -- "$url" | feh - && exit
            ;;
    esac

    # Otherwise, just pass it to br(1)
    br "$url"
) & done