#!/bin/bash

_RESULT=$(printf "Google \0icon\x1fgoogle
Arch \0icon\x1fdistributor-logo-archlinux
Github \0icon\x1fgithub" | rofi -dmenu -show-icons -i -theme disconnect -p Search)

echo "$_RESULT"

_SEARCH_ENGINE="$(cut -d " " -f 1 <<< "$_RESULT")"
_QUERRY="$(cut -d " " -f 2- <<< "$_RESULT")"

case $_SEARCH_ENGINE in
  "Google")
    firefox "https://www.google.com/search?client=firefox-b-d&q=$_QUERRY"
    ;;
  "Arch")
    firefox "https://archlinux.org/packages/?sort=&q=$_QUERRY"
    ;;
  "Github")
    firefox "https://github.com/search?q=$_QUERRY"
    ;;
esac
