by svat · 5y ago · 0 comments
I've had the idea for a while of writing for myself such a tool (probably can't be a browser extension?), but I haven't gotten around to it yet. Does one already exist, or is trivial to write?
As I type this comment, I found that at the commandline on macOS one can do, say:
open -a "Google Chrome" "https://duckduckgo.com/?q=umbrella"
open -a "Google Chrome" "https://www.google.com/search?q=umbrella"
(or whatever your usual browser is) and it's easy to wrap that in a script: function search() {
open -a "Google Chrome" "https://duckduckgo.com/?q=$*"
open -a "Google Chrome" "https://www.google.com/search?q=$*"
}
This (invoke like say `search freddie mercury`) opens two tabs and I haven't yet figured out how to open them in side-by-side windows, but maybe I'll try for a few weeks to be disciplined about doing all searches this way, and see how it goes. Seems worth finding out! function search {
local query="${@}"
osascript -l JavaScript -e "
browser = Application('Google Chrome')
google_window = browser.Window().make()
ddg_window = browser.Window().make()
google_window.activeTab.url = 'https://duckduckgo.com/?q=${query}'
ddg_window.activeTab.url = 'https://www.google.com/search?q=${query}'
google_window.bounds = { 'x': 0, 'y': 0, 'width': 600, 'height': 600 }
ddg_window.bounds = { 'x': 600, 'y': 0, 'width': 600, 'height': 600 }
"
}
It could be improved in a few ways, like:* Not opening the extra window if Chrome isn’t already running.
* URL-encoding your query.
* Auto-detecting the screen bounds (and Dock).
* Auto-detecting the active browser.
But I didn’t want to turn this comment into a full-fledged gist. As is, this works in Chromium-based browsers (replace the name in the `browser = Application('Google Chrome')` line). Adding support for all of them and Safari is simple: https://gist.github.com/vitorgalvao/5392178
Like most people I know, I switched to Google directly when I realised I just scrolled down to Google and clicked the first link.
At least on Linux it's likely doable with xdotool, it should let you identify the windows and put them where you want them.
Two iframes side by side?
https://stackoverflow.com/questions/23737427/how-to-put-two-...