Skip to content

Commit

Permalink
feature/custom browser command, resolves #4
Browse files Browse the repository at this point in the history
  • Loading branch information
fogine committed May 28, 2020
1 parent 7ded5fa commit 96b3244
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ You can even let `rofi-search` combine search results from multiple search engin
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 set enable it in settings
- It can Search the entire web if you enable it in settings
- You will need to go to [https://cse.google.com/cse/all](https://cse.google.com/cse/all) and create your own google custom search engine.
- Get `Search engine ID` from the settings panel
![Preview](https://github.com/fogine/rofi-search/blob/master/search_engine_key.png)
Expand Down Expand Up @@ -103,6 +103,8 @@ Options
This can't be set in rofi theme
- `ROFI_SEARCH_TIMEOUT` - integer - delay between last character typed and automatic search execution (default `500`ms)
- `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

Expand Down
11 changes: 9 additions & 2 deletions rofi-search
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const $HOME = process.env.HOME;
const $XDG_CACHE_HOME = process.env.XDG_CACHE_HOME;
const TITLE_COLOR = process.env.TITLE_COLOR || '#3296c8';
const ROFI_SEARCH_TIMEOUT = parseInt(process.env.ROFI_SEARCH_TIMEOUT) || 500;
const ROFI_SEARCH_CMD = process.env.ROFI_SEARCH_CMD;

const CACHE_DIR_PATH = ($XDG_CACHE_HOME || ($HOME + "/.cache")) + '/' + APP_NAME;
const CACHE_FILE_PATH = `${CACHE_DIR_PATH}/last_search.json`;
Expand Down Expand Up @@ -674,8 +675,14 @@ function getPreferedSearchMethods() {
* @return stdout
*/
function xdgOpen(url) {
const xdgOpen = child_process.spawn('xdg-open', [url]);
xdgOpen.on('close', exit);
if (ROFI_SEARCH_CMD) {
child_process.exec(ROFI_SEARCH_CMD, {
env: Object.assign({URL: url}, process.env)
}, exit);
} else {
const xdgOpen = child_process.spawn('xdg-open', [url]);
xdgOpen.on('close', exit);
}
}

function exit() {
Expand Down

1 comment on commit 96b3244

@markstos
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Please sign in to comment.