You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1021 B

5 years ago
#!/usr/bin/env sh
# URL test passed from $1
URL=${1:-$URL}
# Surf
WINDOW="$(xprop -root | sed -n '/^_NET_ACTIVE_WINDOW/ s/.* //p')"
SURFURL=`xprop -id $WINDOW | grep URI | awk '{print $3}' | sed 's/\"//g'`
if [[ ! -z "$SURFURL" ]]
then
URL="$SURFURL"
fi
# Is normal browser? (FF or Netsurf) - use Ctrl-L Ctrl-C to copy URL
ISNORMBROWS=`xprop -id $(xdotool getactivewindow) | grep -E 'WM_CLASS.*(Netsurf|Firefox)'`
if [[ ! -z "$ISNORMBROWS" ]]
then
xdotool key --clearmodifiers --delay 20 "ctrl+l" "ctrl+c"
sleep 0.2
URL="$(xclip -o)"
fi
COMMAND=$(
echo "
w3m URL
mpv -v URL
mpv -v --ytdl-format='[height<420]' URL
firefox -new-window URL
netsurf URL
surf URL
echo URL | xclip -i
youtube-dl -o- URL | mpv -v -
youtube-dl URL
curl URL | vis -
wget URL
aria2c URL
" | sed "s/URL/'URL'/g" | sed -e '/^\s*$/d' | sed -e 's/^\s*//' | dmenu -p "Pipe URL" -c -l 10
)
[[ -z "$COMMAND" ]] && exit 1
RUN=$(echo $URL | xargs -IURL echo "$COMMAND")
st -e sh -c "$RUN"