Jump to content

positioning 2 (Safari) webpages, after macro


Recommended Posts

Hi and good day,

How can I position 2 (Safari) webpages, LEFT and the other RIGHT after my ALFRED OPEN URL macro, where I call 2 urls,

and I want them side by side.


I guess it could also be done with an AppleScript positioner script after launching the pages?!



with best regards,

Omar K N

Stockholm, Sweden

Link to post

They are 2 static urls, no keywords.

The Alfred macro (hotkey trigger) opens first url1 in Safari, then it opens url2 in a new tab.


The intent is to have them side-by-side.


Maybe it would be enough to have 1 command of some sorts, so as to open url2 in a new Safari *window* and positioning it to the right half of the desktop.


I have this script, but with Safari Tabs I don't know:


tell application "Safari" to set bounds of front window to {150, 25, 1368, 1299}




Any assistance would be greatly appreciated!

With best regards,
Omar KN



Link to post

Here's a script that accepts one or more URLs as command-line arguments, and opens windows for each one, evenly distributed across the screen:


var safari = Application('Safari');

function screenSize() {
  return Application('Finder').desktop.window.bounds();

function openWin(url, bounds) {
  var doc = safari.Document().make();
  doc.url = url;
  var win = safari.windows[0];
  win.bounds = bounds;

function run(urls) {
  var bounds = screenSize(),
    height = bounds.height,
    width = bounds.width / urls.length;

  var x = 0,
    y = 0;

  urls.forEach(function(url) {
    var bounds = {'x': x, 'y': y, 'width': width, 'height': height};
    openWin(url, bounds);
    x += width;

So if you saved the script as browsers.js, you could use it in a Run Script action (Language = /bin/zsh) like this:


/usr/bin/osascript -l JavaScript browsers.js $urls


Edited by deanishe
Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...