Giter Site home page Giter Site logo

rofi-search's Introduction

rofi-search

Interactive web search via rofi.
Multiple search engines supported.

Preview (click for large preview)

Installation

AUR package rofi-search-git

or npm install -g rofi-search

or copy rofi-search to your $PATH

Features

  • search as you type
  • Google search
  • DuckDuckGo search
  • I'm Feeling Lucky - Open the first result directly without waiting for the results to render
  • get top search results from multiple search engines
  • copy search result website url
  • open search result in web browser

Dependencies

  • nodejs >= 8.2.1
  • rofi-blocks (rofi-blocks-git package in AUR)
  • rofi
  • xclip copy to clipboard
  • ddgr (optional) DuckDuckGo search results scraper

HOW TO RUN

Simply execute rofi-search in terminal (needs ddgr dependency to be installed).
Or see Usage section bellow for more advanced use cases.

Usage

You can choose between multiple methods of getting search results. Each one will give slightly different results.
You can even let rofi-search combine search results from multiple search engines.

  • Use ddgr for scraping DuckDuckGo for search results

    • ddgr does not parse information about number of search results so this information is not currently available when using this method
  • Use google's custom search engine API by setting GOOGLE_API_KEY & GOOGLE_SEARCH_ID env variables

    • It can Search the entire web if you enable it in settings

    • You will need to go to https://cse.google.com/cse/all and create your own google custom search engine.

      • Get Search engine ID from the settings panel
        Preview
    • Get API KEY for the created search engine. Preview

Examples

NOTE: In the following examples, to be able to pass rofi-search to rofi and execute it with custom configuration, env configuration variable ROFI_SEARCH is required to be set.

Google CSE
export GOOGLE_API_KEY='google-api-key'
export GOOGLE_SEARCH_ID='google-search-engine-id'
export ROFI_SEARCH='cse'

rofi -modi blocks -blocks-wrap /absolute/path/to/rofi-search -show blocks \ 
-lines 4 -eh 4 -kb-custom-1 'Control+y' -theme /path/to/your/theme.rasi
ddgr
#for additional ddgr options see "ddgr --help"
export DDG_ARGS='["-n", 5]'
export ROFI_SEARCH='ddgr'

rofi -modi blocks -blocks-wrap /absolute/path/to/rofi-search -show blocks \ 
-lines 4 -eh 4 -kb-custom-1 'Control+y' -theme /path/to/your/theme.rasi 
combine top free results from DuckDuckGo and Google
export DDG_ARGS='["-n", 3]'
export ROFI_SEARCH='cse,ddgr'

rofi -modi blocks -blocks-wrap /absolute/path/to/rofi-search -show blocks \ 
-lines 4 -eh 4 -kb-custom-1 'Control+y' -theme /path/to/your/theme.rasi

You can fetch rofi theme used in the gif preview HERE

Options

  • GOOGLE_API_KEY - secret key to access Google API. You can get it here
  • GOOGLE_SEARCH_ID - Your custom search engine (cse) ID
  • DDG_ARGS - ddgr command line arguments. Serialized json array.
  • ROFI_SEARCH - comma separated search methods
    • Supported methods: cse, ddgr
    • If multiple methods are set, rofi-search will make multiple parallel searches and combine search results in the order search methods were defined
  • TITLE_COLOR - customize search result title color (default blue). This can't be set in rofi theme
  • ROFI_SEARCH_TIMEOUT - integer - delay between last character typed and automatic search execution (default 500ms)
  • ROFI_SEARCH_DEBUG - enables verbose logging if set to any value
  • ROFI_SEARCH_CMD - a command to execute when pressing -kb-accept-entry (enter) - defaults to xdg-open
    • example: export ROFI_SEARCH_CMD='google-chrome $URL'
supported rofi actions
  • -kb-accept-entry - open url with xdg-open (aka. your default browser)
  • -kb-accept-custom - open search results on google.com in your browser
  • -kb-custom-1 - copy url to clipboard

TODO (PR is welcome)

  • DuckDuckGO integration
  • make font sizes configurable
  • buku integration

rofi-search's People

Contributors

fogine avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

rofi-search's Issues

Odd output

For whatever reason when I use this the output comes through fairly garbled.
This is what it looks like. https://imgur.com/5NIG007

This is the command I'm using.

rofi -modi blocks -blocks-wrap /usr/bin/rofi-search -show blocks \ 
-lines 4 -eh 4 -kb-custom-1 'Control+y' -theme /usr/share/rofi/themes/glue_pro_blue.rasi

I'm guessing that it's either a font problem or I'm missing a dependency. I'm not sure which is most likely. I installed through the AUR.

[support] Add keyboard shortcut (xfce4)

Hello,

Thanks for this great piece of software.

But I fail to map it to a hotkey in xfce4.

How would I go about this ? I'd like to use ddgr.

rofu itself works great and all needed dependencies are installed.

not able to open link in browser

not able to open search results in the browser. I have added -kb-accept-entry but nothing happens I am able to copy the URL by pressing control+y.

rofi-search spawns rofi

Greetings,

For what I could find, rofi-search spawns internally rofi which makes it incompatible with the provided examples.

$ rofi -modi blocks -blocks-wrap rofi-search -show blocks

(process:773472): Helper-WARNING **: 00:15:00.469: Failed to set lock on pidfile: Rofi already running?

(process:773472): Helper-WARNING **: 00:15:00.469: Got error: -1 Socket operation on non-socket
BlocksMode-Message: 00:15:00.474: Child 773464 exited normally

image

image

Is there a solution for that? If rofi-search spawns rofi internally, it would be nice to be able to pass arguments to rofi. Otherwise rofi should not be launched internally.

wish: support passing a custom browser command

I use a "work profile" and a "personal profile" and I might want to open a search result in either.

Also, a custom browser command could be used to launch an Incognito search.

The custom browser command may contain spaces, as itself might include options passed to a browser binary.

clearing query causes crash

Hi,

I installed your patched rofi-blocks and dropped rofi-search in my $PATH.

rofi command:

rofi -modi blocks -blocks-wrap /usr/local/bin/rofi-search -show blocks -lines 4 -eh 4 -kb-custom-1 'Control+y' -theme /home/clu/.config/rofi/brotab.rasi

Steps to reproduce

  • type any search string
  • backspace to clear query string

What behavior you see

Rofi exits with message:

[ERROR] string index out of range
BlocksMode-Message: 15:17:03.012: Child 309732 exited abnormally

What behavior you expect to see

  • Rofi remains open, allow for another query to be made.

I am unsure if this is expected behavior or perhaps a limitation of the implementation. If I clear the current query string, and quickly type another query a crash can be avoided.

Thanks for sharing this tool. It's impressive what can be accomplished with rofi, and rofi-search is making me rethink some of my own scripts, haha.

[Bug] Duckduckgo not working

With environment variable

Okay i followed your usage guide and set ROFI_SEARCH to ddgr.
When i start rofi-search it displays:
{"prompt":"search","input action":"send"}
and waits for input but doesn't open the search gui.
When i type something into the commandline and hit enter this error pops up (e.g. "a"):

undefined:1
a
^

SyntaxError: Unexpected token a in JSON at position 0
    at JSON.parse (<anonymous>)
    at ReadStream.<anonymous> (/usr/lib/node_modules/rofi-search/rofi-search:80:36)
    at Array.forEach (<anonymous>)
    at ReadStream.<anonymous> (/usr/lib/node_modules/rofi-search/rofi-search:78:22)
    at ReadStream.emit (node:events:527:28)
    at emitReadable_ (node:internal/streams/readable:601:12)
    at processTicksAndRejections (node:internal/process/task_queues:82:21)

Node.js v17.7.2

Without environment variable

Okay after that i tried it without the environment variable set but no googler installed.
Then the GUI opens and when i type something in it, it immediately crashes and shows this error:

Can not find "googler" executable.
BlocksMode-Message: 18:57:03.494: Child 257334 exited abnormally

Which makes sense because googler isn't installed. But shouldn't there be a fallback if googler is not installed to use ddgr?

Information about system and installation

I'm using endeavouros with i3-gaps. I use the linux-zen kernel.
I installed it using AUR but the rofi-blocks-git PKGBUILD file was faulty. So i installed rofi-blocks via makepkg -si and an edited version of the PKGBUILD file. More information on that in the AUR Package comments for rofi-blocks-git.

How do I use this?

There are instructions for installing the package, but not for how to use it in conjuction with rofi

I tried running it in the terminal but just got this:

~
❯ rofi-search
{"prompt":"search","input action":"send"}

does rofi need to configured in a certain way to make use of this package?

Search time string 'unavailable'

Rofi's message box for reporting 'search time' is only displaying:

about <unavailable> results (<unavailable> seconds)

Not a big deal, just figured I would report it while I am here. I do wonder if its something with my environment but have yet to figure it out.

EDIT: Read over this my first time through doc:

(ddgr, googler) ...does not parse information about number of search results so this information is not currently available when using this method

Assuming that why, issue can be closed...sorry.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.