dotfiles

My collection of dotfiles
git clone git://git.noxz.tech/dotfiles
Log | Files | Refs

dmenu_url_open (1724B)


      1 #!/bin/sh
      2 
      3 options="
      4 	copy
      5 	mpv
      6 	surf
      7 	vimb
      8 	w3m
      9 	wget
     10 	yt-dl
     11 "
     12 url="$1"; shift
     13 visual="$url"
     14 
     15 if [ "${#visual}" -gt 30 ]; then
     16 	visual="$(expr substr $url 1 20)...$(expr substr $url $((${#url} -6)) 7)"
     17 fi
     18 
     19 args=" $@ -i -p $visual"
     20 
     21 case "$url" in
     22 *//api.lbry.tv*)
     23 	url="$(echo "$url"                                                      \
     24 	| sed "s/api.lbry.tv/player$((RANDOM%6+1)).lbryplayer.xyz/")";;
     25 esac
     26 
     27 case "$(printf "$options"                                                   \
     28 | sed -e '/^$/d' -e 's/^[ \t]*//'                                           \
     29 | sort                                                                      \
     30 | dmenu_vtc${args})" in
     31 copy)
     32 	printf "$url"                                                           \
     33 	| xclip -selection primary -f                                           \
     34 	| xclip -selection clipboard & ;;
     35 mpv)
     36 	mpvc load "$url" ;;
     37 yt-dl-video)
     38 	youtube-dl                                                              \
     39 		-f webm                                                             \
     40 		-o "$HOME/downloads/%(title)s-%(id)s.%(ext)s"                       \
     41 		"$url" >/dev/null 2>&1 & ;;
     42 yt-dl-audio)
     43 	youtube-dl                                                              \
     44 		-extract-audio                                                      \
     45 		--audio-format vorbis                                               \
     46 		--audio-quality 0                                                   \
     47 		-o "$HOME/downloads/%(title)s-%(id)s.%(ext)s"                       \
     48 		"$url" >/dev/null 2>&1 & ;;
     49 wget)
     50 	wget "$url" >/dev/null 2>&1 & ;;
     51 surf)
     52 	surf "$url" >/dev/null 2>&1 & ;;
     53 vimb)
     54 	vimb-tabbed "$url" >/dev/null 2>&1 & ;;
     55 w3m)
     56 	w3m "$url" >/dev/null 2>&1 & ;;
     57 esac