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.

44 lines
1.1 KiB

5 years ago
#!/usr/bin/env sh
if [ -n "$1" ]
5 years ago
then
# E.g. passed liked: sxmo_urlhandler.sh http://foo.com
URL="$1"
else
# Surf
WINDOW="$(xprop -root | sed -n '/^_NET_ACTIVE_WINDOW/ s/.* //p')"
SURFURL="$(xprop -id "$WINDOW" | grep URI | awk '{print $3}' | sed 's/\"//g')"
if [ -n "$SURFURL" ]; then
URL="$SURFURL"
fi
5 years ago
# 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 [ -n "$ISNORMBROWS" ]; then
xdotool key --clearmodifiers --delay 20 "ctrl+l" "ctrl+c"
sleep 0.2
URL="$(xclip -o)"
fi
5 years ago
fi
COMMAND=$(
echo "
w3m URL
mpv -ao=alsa -v URL
mpv -ao=alsa -v --ytdl-format='[height<420]' URL
firefox -new-window URL
netsurf URL
surf URL
echo URL | xsel -i
youtube-dl -o- URL | mpv -ao=alsa -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 -fn Terminus-15 -p "Pipe URL" -c -l 20
5 years ago
)
[ -z "$COMMAND" ] && exit 1
5 years ago
RUN=$(echo "$URL" | xargs -IURL echo "$COMMAND")
5 years ago
st -e sh -c "$RUN"