dots-of-war/files/scripts/rofi-search.sh

17 lines
818 B
Bash
Raw Normal View History

2020-03-19 11:03:08 +00:00
#!/bin/bash
# todo combine selection with query by using first word as selection and rest as query
selection=$( echo -e "hoogle\ngoogle" | rofi -dmenu )
if [ $selection = "hoogle" ]; then
input=$( rofi -p "search hoogle" -dmenu )
query=$( echo $input | sed 's/ p=.*$//g' )
package=$( echo $input | sed 's/.*p=//g' )
[ $package = $query ] && package=""
#firefox --new-window "https://hoogle.haskell.org/?hoogle=$query&scope=package:$package" &
2020-03-20 15:40:53 +00:00
#surf "https://hoogle.haskell.org/?hoogle=$query&scope=package:$package" &
result=$( hoogle $query | rofi -p "select" -dmenu | sed 's/^\(.*\) :: .*$/\1/' | sed 's/\ /./g' | xargs hoogle --info )
notify-send "hoogle" "$result"
2020-03-19 11:03:08 +00:00
elif [ $selection = "google" ]; then
query=$( rofi -p "search google" -dmenu )
2020-03-19 13:14:18 +00:00
$BROWSER "https://google.de/search?q=$query" &
2020-03-19 11:03:08 +00:00
fi