-
-
Save developerworks/5268d9b5e70837bf6005 to your computer and use it in GitHub Desktop.
Revisions
-
aaronj1335 created this gist
Sep 18, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,66 @@ /* global Application, ObjC, $ */ /** * repozish.js * * this is an example of using os x yosemite's "JavaScript for Automation": * * https://developer.apple.com/library/prerelease/mac/releasenotes/interapplicationcommunication/rn-javascriptforautomation/index.html * * it repositions some windows based on some position settings. you can run * this from a terminal with: * * $ osascript repozish.js * * TODO: figure out how to read positions from/write positions to a file */ // importing this gives us the `$.printf` function and probably some other // stuff ObjC.import('stdio'); /** * positions of the windows * * you could query these with something like: * * var positions = ['Terminal', 'MacVim'] * .reduce(function(positions, appName) { * var properties = Application(appName).windows[0].properties(); * positions[appName] = properties.bounds; * return positions; * }, {}); * * // print this stuff to stdout * $.printf(JSON.stringify(positions, null, 2)); */ var positions = { Terminal: { x: 3270, y: -388, width: 573, height: 1412 }, MacVim: { x: 2551, y: -388, width: 718, height: 1397 } }; /** * run * * this is like the 'main' function in C. * * @param args Array of command line args */ function run(args) { Object.keys(positions).forEach(function(appName) { Application(appName).windows[0].properties = { bounds: positions[appName] }; }); }