Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Zephyros

 Zephyros

The OS X window manager for hackers

Daniele Polencic

August 28, 2013
Tweet

More Decks by Daniele Polencic

Other Decks in Technology

Transcript

  1. 1 zephyros.bind('t', ['Cmd', 'Shift'], function(err){ 2 zephyros.getFocusedWindow(function(window){ 3 zephyros.getWindowFrame(window.id, function(window){

    4 zephyros.setFrame({ 5 id: window.id, 6 frame: {x: 0, y:0, w: 200, h: 300} 7 }); 8 }); 9 }); 10 }); Callback hell
  2. Lazy Chains 1 new LazyChain([2,1,3]) 2 .invoke('concat', [8,7,6]) 3 .invoke('sort')

    4 .invoke('join', ' ') 5 .force(); 6 7 // 1 2 3 6 7 8
  3. Promises 1 asyncCall() 2 .then(function(data1){ 3 // do something... 4

    return anotherAsyncCall(); 5 }) 6 .fail(function(err) { 7 // handle any error resulting from any of 8 the above calls 9 }) 10 .done();
  4. Mixins 1 var RectangleClickButton = function(w, h, text, callback) {

    2 ... 3 }; 4 5 _.extend(RectangleClickButton.prototype, rectangle); 6 _.extend(RectangleClickButton.prototype, button); 7 _.extend(RectangleClickButton.prototype, onclickControl);
  5. 1 var Zephyros = require('node-zephyros'); 2 3 var z =

    new Zephyros(); 4 5 z.bind('m', ['Cmd', 'Ctrl']) 6 .windowFocused() 7 .maximize(); 8 API
  6. Workflows #1 1 require('shelljs/global'); 2 var Zephyros = require('node-zephyros'); 3

    4 var z = new Zephyros(); 5 6 z.listen('app_launched') 7 .appTitle() 8 .then(function(app){ 9 if( app.title === 'MacVim' ){ 10 exec('mysql.server start'); 11 } 12 });
  7. Workflows #2 1 var Zephyros = require('node-zephyros'); 2 appdb =

    fs.createWriteStream('app.db', { 3 flags: 'a'}); 4 5 var z = new Zephyros(); 6 7 z.listen('focus_changed') 8 .appTitle() 9 .then(function(app){ 10 var now = (new Date()).valueOf(); 11 appdb.write(app.title + ',' + now + '\n'); 12 });
  8. 1 var Zephyros = require('node-zephyros'), 2 request = require('request'); 3

    4 var z = new Zephyros(); 5 6 var cities = ['London', 'Manchester', 'Bath', 'Leeds', 'Liverpool']; 8 z.bind('c', ['Cmd', 'Alt', 'Ctrl']) 9 .chooseFrom({ 10 list: cities, 11 title: 'Cities', 12 lines_tall: 5, 13 chars_wide: 30 14 }) 15 .then(function(index){ 16 request('http://api.openweathermap.org/data/2.5/weather?q=' + cities[index] + 17 ',uk', function(err, res, body){ 19 body = JSON.parse(body); 20 z.api().alert(body.weather[0].description + ' in ' + cities[index]); 22 }); 23 }); Workflows #3