#!/bin/bash
# Easy web searching
SearchSites="DuckDuckGo\nArchWiki\nBandCamp\nGitHub\nIMDB\nReddit\nRev\nWikipedia\nYouTube"
Query=${@:2}
Choice=$1
case $(tty) in
*tty*) mymenu="dwmenu Service"
runprefix="$TERMINAL -e" ;;
*) mymenu="fzf --prompt="Service""
runprefix= ;;
esac
if [ -z "$Choice" ]; then Choice=$(echo -e $SearchSites | sort -n | $mymenu) || exit ; fi
if [ -z "$Query" ]; then Query=$(inprompt "Terms") || exit ; fi
if [ -z "$Query" ]; then exit ; fi
if [ -z "$Choice" ]; then Choice="ddg" ; fi
case "$Choice" in
r|Reddit) $runprefix rtv -s "$Query" ;;
# yt|YouTube) $runprefix straw-viewer $Query ;;
yt|YouTube) $runprefix pipe-viewer $Query ;;
rev|Rev) $BROWSER "https://revolutiontt.me/browse.php?search=$Query" ;;
ddg|DuckDuckGo) $BROWSER "https://duckduckgo.com/?q=$Query&t=ffab&atb=v1-1" ;;
aw|ArchWiki) $BROWSER "https://wiki.archlinux.org/index.php?search=$Query" ;;
git|GitHub) $BROWSER "https://github.com/search?q=$Query" ;;
w|Wikipedia) $BROWSER "https://en.wikipedia.org/?search=$Query" ;;
bc|BandCamp) $BROWSER "https://bandcamp.com/search?q=$Query" ;;
im|IMDB) $BROWSER "http://www.imdb.com/find?ref_=nv_sr_fn&q=$Query&s=all" ;;
esac