Intuitive, friendly, fast: none of these things describe window management on a Mac. Particularly if you use more than one screen with a laptop and occasionally unplug the second screen. What a mess! Anyway, those of us in such situations have adopted a variety of tools for forcing windows to behave. I currently use Spectacle, which is free and...

Intuitive, friendly, fast: none of these things describe window management on a Mac. Particularly if you use more than one screen with a laptop and occasionally unplug the second screen. What a mess! Anyway, those of us in such situations have adopted a variety of tools for forcing windows to behave. I currently use Spectacle, which is free and open source!

What about a programmatic API? Daniele Polencic sent in node-zephyros (GitHub: danielepolencic / node-zephyros, License: MIT), which is a Node module that talks to Zephyros:

The OS X window manager for hackers. At its core, Zephyros just runs quietly in your menu bar, and listens for your script. You typically write a script that binds global hot keys to do stuff, like moving or resizing windows.

You can bind keys to JavaScript callbacks, and even call the Zephyros API:

varZephyros=require('zephyros');varz=newZephyros();z.bind('t',['Cmd','Shift']).clipboardContents().then(function(clipboard){console.log('clipboard:',clipboard);});

Daniele’s project originated from a talk at LNUG about Zephyros:

Originally the library was a nice excuse to get my hands dirty with Michael Fogus’ book, Functional JavaScript. It features lazy chains, promises and mixins, and the tests are written in Mocha.

If you’re wondering how the tests work, then take a look at mockServer.js. The module communicates with Zephyros using sockets, so it can be tested by creating a mock server that generates the expected responses.

Now you should be able to get those windows under control.

Read more https://feedproxy.google.com/~r/dailyjs/~3/9J1o5EklBE8/zephyros

© 2024 Extly, CB - All rights reserved.