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

25 lines
912 B
Bash
Raw Normal View History

2020-03-23 10:38:19 +00:00
#!/bin/dash
openDetailsAction() {
echo "Details:surf https://hoogle.haskell.org/?hoogle=$1&scope=package:$2"
}
2020-03-29 09:36:09 +00:00
query=$( echo "h\ng" | rofi -i -theme /home/leon/scripts/rofi-scripts/default_theme.rasi -dmenu )
2020-03-23 10:38:19 +00:00
selection=$( echo "$query" | awk '{print $1}' )
input=$( echo "$query" | awk '{print $2}' )
case "$selection" in
"h")
query=$( echo "$input" | sed 's/ p=.*$//g' )
package=$( echo "$input" | sed 's/.*p=//g' )
[ "$package" = "$query" ] && package=""
2020-04-04 13:12:33 +00:00
selection=$( hoogle "$query" | rofi -matching fuzzy -p "select" -i -theme /home/leon/scripts/rofi-scripts/default_theme.rasi -dmenu | sed 's/^\(.*\) :: .*$/\1/' | sed 's/\ /./g' )
2020-03-23 10:38:19 +00:00
result=$( echo "$selection" | xargs hoogle --info )
notify-send.sh --icon="dialog-information" --action="$(openDetailsAction "$query" "$package")" "Hoogle" "$result"
;;
"g")
$BROWSER "https://google.de/search?q=$input" &
;;
esac