#!/bin/bash

# Usage:
#
# Name the script how you prefer. This example uses "y" as a script's name.
#
# For example search with DuckDuckGo via your chosen GUI browser:
# $ y ddg death may be your santa claus
# 
# Do the same but with text browser of your liking:
# $ y -c ddg death may be your santa claus
#
# Search YouTube:
# $ y yt death may be your santa claus
#
# Or list all Debian related yubnub commands:
# $ y ls debian
#
# Etc. etc.

set -e

# Change as you please
CLIBROWSER='w3m'
GUIBROWSER='iceweasel'

# Change to your liking
#TERMCMD='xterm -bg black -fg white -ls -j -s -sl 10000 +sb -fa LucidaTypewriter -fs 9 -e '
TERMCMD='urxvt -e '

if [ "$1" == "-c" ]; then
    shift
    SRCH_STR="$@"
    #$CLIBROWSER http://yubnub.org/parser/parse?command="$SRCH_STR"
    $CLIBROWSER http://yubnub.ktamas.com/parser/parse?command="$SRCH_STR"
    exit 0
else
    SRCH_STR="$@"
    #$GUIBROWSER http://yubnub.org/parser/parse?command="$SRCH_STR"
    $GUIBROWSER http://yubnub.ktamas.com/parser/parse?command="$SRCH_STR"
    exit 0
fi

