Use rofi to perform web search with instant search suggestions
As of now, it supports the following websites:
- Youtube/Google
- Wikipedia
- Duckduckgo
- Archwiki
- Amazon
- Deezer
- Lastfm (requires Api key)
- Google books
- rofi blocks this is what makes the rofi interaction dynamic.
- Jq for Json processing.
Simply run the wrapper script for whichever API you'd want to handle the request
Example:
suggest youtube
Each of the APis can be run indpendently from your terminal:
youtube <search>
returns youtube suggestions of your entry in plain/text.
you can configure all the APIs in their own respective files.
options can include search language and other basic search parameters.
note: most of them barely include a basic search function, they aren't in any way complete
it's not hard to implement more options by reading through their documentations.
it's also made easy to add a custom API to the list, move them to the /APIs directory and follow the existing declarations.
this script does nothing but to grab your selection which can seem to be pointless on its own.
however, you can combine it with additional scripts to make things more interesting.
here is a non-exhaustive list of scripts that blend well with it.
- play songs/albums in Spotify
- getbook download publicly available books
- youtubemenu a youtube dmenu fetcher with thumbnails support
This is an example for handling the selection based on your search type, you can add it at the end
of the wrapper script:
case "$API" in
"google") $BROWSER "https://www.google.com/search?q=$result" ;;
"deezer" | "lastfm") play "$selection" ;;
"youtube") youtube "$selection" ;;
"books") getBook "$selection" ;;
esac
git clone https://github.com/BelkaDev/RofiFtw.git ~/RofiFtw && cd ~/RofiFtw
chmod +x *
move the folder content to your $PATH directory
- You may notice a small delay while processing the input:
this can be fixed by increasing the refresh rate (ie number of typed characters before sending the request)
which will affect the average response time.
At the time being it's linear and pretty straightforward. if you know a better / more complex algorithm let me know. - Special and non-utf characters cause rofi to break, so they are filtered by default.
If you care about displaying them, this fork fixes the issues. more instructions can be found in the code