1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- #!/usr/bin/env bash
- # -----------------------------------------------------------------------------
- # Info:
- # author: Miroslav Vidovic
- # file: web-search.sh
- # created: 24.02.2017.-08:59:54
- # revision: ---
- # version: 1.0
- # -----------------------------------------------------------------------------
- # Requirements:
- # rofi
- # Description:
- # Use rofi to search the web.
- # Usage:
- # web-search.sh
- # -----------------------------------------------------------------------------
- # Script:
- declare -A URLS
- # Default book search
- # https://b-ok.cc/s/?q="
- #
- URLS=(
- ["search"]="https://search.unbl.ink/?q="
- ["google"]="https://www.google.com/search?q="
- ["ddg"]="https://www.duckduckgo.com/?q="
- ["amazon"]="https://www.amazon.com/s?k="
- ["github"]="https://github.com/search?q="
- ["goodreads"]="https://www.goodreads.com/search?q="
- ["stackoverflow"]="http://stackoverflow.com/search?q="
- ["symbolhound"]="http://symbolhound.com/?q="
- ["searchcode"]="https://searchcode.com/?q="
- ["imdb"]="http://www.imdb.com/find?ref_=nv_sr_fn&q="
- ["rottentomatoes"]="https://www.rottentomatoes.com/search/?search="
- ["invidous"]="https://invidio.us/search?q="
- ["vimawesome"]="http://vimawesome.com/?q="
- ["beer"]="https://www.beeradvocate.com/search/?qt=beer&q="
- ["jira"]="https://15five-dev.atlassian.net/plugins/servlet/mobile#issue/ENG-"
- ["books"]="http://zlibraryexau2g3p.onion/s/"
- ["maps"]="https://www.openstreetmap.com/search?query="
- ["pirate"]="https://proxahoy.link/s/?q="
- )
- # List for rofi
- gen_list() {
- for i in "${!URLS[@]}"
- do
- echo "$i"
- done
- }
- main() {
- # Pass the list to rofi
- platform=$( (gen_list) | rofi -dmenu -matching fuzzy -no-custom -location 0 -p "Search > " )
- if [[ -n "$platform" ]]; then
- query=$( (echo ) | rofi -dmenu -matching fuzzy -location 0 -p "Query > " )
- if [[ -n "$query" ]]; then
- url=${URLS[$platform]}$query
- xdg-open "$url"
- else
- exit
- fi
- else
- exit
- fi
- }
- main
- exit 0
|