📜 ⬆️ ⬇️

Slate - Silver Bullet for positioning windows on OS X screens

Hi, Habr! I want to share a very interesting tool for "taming" the position of windows in OS X. In short, here is the link to the repository with the wonderful Slate application. For details, welcome under cat.

image

I ran into the problem of positioning (and, most importantly, maintaining this position!) Windows on several monitors in OS X. This problem is especially important if the main work machine is a laptop, but you have to work a lot and, therefore, connect different monitors and in different quantities. I, for example, have a rather large monitor in the office, less at home, and on the road there is no possibility to connect a second monitor at all. As a result, each of my working sessions begins with the inclusion of the IDE and the location of all the windows-tools (terminal, version history, project structure, class inspector, etc.) IDE on monitors. This process is greatly accelerated by applications like ShiftIt , but you still have to spend time on the exact location of each window. I just want to press the cherished key combination and watch how the windows themselves are located at predetermined positions.

And today I have found a solution that covers all my needs with my head and I want to share it with you.
')
Actually, the application is called Slate. Here is the link to the githab. This application allows you to create your own configuration of the location of windows on the monitors as a JS file with a configuration. Slate provides a very powerful and at the same time easy-to-understand API for manipulating windows, it allows building events on shortcuts, has excellent documentation, and (most importantly) works!

To create your own configuration, you must create the file ~ / .slate.js and describe the location of the windows there.

So, for example, it turned out for me:

//    ctrl+alt+cmd+shift+1      slate.bind("1:ctrl,alt,cmd,shift", function() { //      ,      2-. if (slate.screenCount() !== 2) { return; } //        ,     var screen0 = slate.screenForRef('0'); var screen1 = slate.screenForRef('1'); var mainScreen = null, additionalScreen = null; if (screen0.rect().width * screen0.rect().height > screen1.rect().width * screen1.rect().height) { mainScreen = screen0; additionalScreen = screen1; } else { mainScreen = screen1; additionalScreen = screen0; } //      slate.eachApp(function(app) { //       IntelliJ IDEA var appName = app.name(); if (appName !== 'IntelliJ IDEA') { return; } app.eachWindow(function(win) { //     -  IntelliJ IDEA   ,    var w, h, xOffset, yOffset, screen; switch (win.title()) { case 'Terminal': w = 5; h = 5; xOffset = 7; yOffset = 7; screen = mainScreen; break; case 'Version Control': w = 5; h = 5; xOffset = 7; yOffset = 2; screen = mainScreen; break; case 'Database': w = 3; h = 2; xOffset = 9; yOffset = 0; screen = mainScreen; break; case 'Workspaces': w = 2; h = 2; xOffset = 7; yOffset = 0; screen = mainScreen; break; case 'Project': w = 6; h = 12; xOffset = 0; yOffset = 0; screen = additionalScreen; break; case 'Structure': w = 6; h = 12; xOffset = 6; yOffset = 0; screen = additionalScreen; break; default: w = 7; h = 12; xOffset = 0; yOffset = 0; screen = mainScreen; } //     win.doOperation(slate.operation('move', { 'x': 'screenOriginX+screenSizeX/12*' + xOffset, 'y': 'screenOriginY+screenSizeY/12*' + yOffset, 'width': 'screenSizeX/12*' + w, 'height': 'screenSizeY/12*' + h, 'screen': screen })); }); }); }); 

And here is the result:

image

image

Thanks for attention!

Source: https://habr.com/ru/post/313578/


All Articles