THEAARBS menus - search

Published 05-06-2018 03:11:46

#!/bin/bash
# A menu script for easy web searching.
# Bound to Mod+s

SearchSites=\
"DuckDuckGo
ArchWiki
BandCamp
IMDB
Reddit
Rev
Wikipedia
YouTube"

SearchCommands() {
    case "$Choice" in
        r|Reddit)   $runprefix rtv -s "$Query" ;;
        yt|YouTube) $runprefix youtube-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" ;;
        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 ;}

runprefix=
mymenu=$(setmenu -l)
Query=${@:2}
Choice=$1
amitty=$(tty)
case $amitty in
    *tty1|"not a tty") runprefix="$TERMINAL -e" ;;
esac
if [ -z "$Choice" ]; then Choice=$(echo -e "$SearchSites" | $mymenu "🔎 Search where") ; fi
if [ -z "$Query"  ]; then Query=$(inprompt "🔎 Search terms") ; fi
if [ -z "$Query"  ]; then clear ; exit 1 ; fi
if [ -z "$Choice" ]; then Choice="ddg" ; fi

SearchCommands
clear