Last active
December 20, 2015 11:19
-
-
Save mhubig/6121995 to your computer and use it in GitHub Desktop.
Simple zephyros config file. Use `mash` + `UP/DOWN/LEFT/RIGHT` to move and resize your focused window.
This file contains 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 characters
#!/usr/bin/env python | |
# -*- coding: UTF-8 -*- | |
# vim: set ft=python fenc=UTF-8 ts=4 sts=4 sw=4 et : | |
def push_up(): | |
win = zephyros.api.focused_window() | |
screen = win.screen() | |
frame = screen.frame_without_dock_or_menu() | |
frame.h /= 2 | |
frame.inset(10, 10) | |
win.set_frame(frame) | |
def push_down(): | |
win = zephyros.api.focused_window() | |
screen = win.screen() | |
frame = screen.frame_without_dock_or_menu() | |
frame.y += frame.h / 2 | |
frame.h /= 2 | |
frame.inset(10, 10) | |
win.set_frame(frame) | |
def push_left(): | |
win = zephyros.api.focused_window() | |
screen = win.screen() | |
frame = screen.frame_without_dock_or_menu() | |
frame.w /= 2 | |
frame.inset(10, 10) | |
win.set_frame(frame) | |
def push_right(): | |
win = zephyros.api.focused_window() | |
screen = win.screen() | |
frame = screen.frame_without_dock_or_menu() | |
frame.x += frame.w / 2 | |
frame.w /= 2 | |
frame.inset(10, 10) | |
win.set_frame(frame) | |
def max_window(): | |
win = zephyros.api.focused_window() | |
screen = win.screen() | |
frame = screen.frame_without_dock_or_menu() | |
frame.inset(10, 10) | |
win.set_frame(frame) | |
def center_window(): | |
win = zephyros.api.focused_window() | |
wframe = win.frame() | |
screen = zephyros.api.main_screen() | |
sframe = screen.frame_without_dock_or_menu() | |
frame = zephyros.Rect() | |
frame.x = (sframe.w - wframe.w) / 2 | |
frame.y = (sframe.h - wframe.h) / 2 | |
frame.w = wframe.w | |
frame.h = wframe.h | |
win.set_frame(frame) | |
@zephyros.zephyros | |
def configuration(): | |
mash = ['Ctrl', 'Alt', 'Cmd'] | |
zephyros.api.bind('UP', mash, push_up) | |
zephyros.api.bind('DOWN', mash, push_down) | |
zephyros.api.bind('LEFT', mash, push_left) | |
zephyros.api.bind('RIGHT', mash, push_right) | |
zephyros.api.bind('M', mash, max_window) | |
zephyros.api.bind('C', mash, center_window) |
This file contains 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 characters
#!/usr/bin/env ruby | |
# -*- coding: UTF-8 -*- | |
# vim: set ft=ruby fenc=UTF-8 sw=2 ts=2 et: | |
require '/Applications/Zephyros.app/Contents/Resources/libs/zephyros.rb' | |
mash = ["cmd", "alt", "ctrl"] | |
# push to top half of screen | |
API.bind "UP", mash do | |
win = API.focused_window | |
frame = win.screen.frame_without_dock_or_menu | |
frame.h /= 2 | |
frame.inset! 10, 10 | |
win.frame = frame | |
end | |
# push to bottom half of screen | |
API.bind "DOWN", mash do | |
win = API.focused_window | |
frame = win.screen.frame_without_dock_or_menu | |
frame.y += frame.h / 2 | |
frame.h /= 2 | |
frame.inset! 10, 10 | |
win.frame = frame | |
end | |
# push to left half of screen | |
API.bind "LEFT", mash do | |
win = API.focused_window | |
frame = win.screen.frame_without_dock_or_menu | |
frame.w /= 2 | |
frame.inset! 10, 10 | |
win.frame = frame | |
end | |
# push to right half of screen | |
API.bind "RIGHT", mash do | |
win = API.focused_window | |
frame = win.screen.frame_without_dock_or_menu | |
frame.x += frame.w / 2 | |
frame.w /= 2 | |
frame.inset! 10, 10 | |
win.frame = frame | |
end | |
API.bind "M", mash do | |
win = API.focused_window | |
frame = win.screen.frame_without_dock_or_menu | |
frame.inset! 10, 10 | |
win.frame = frame | |
end | |
API.bind "C", mash do | |
win = API.focused_window | |
wframe = win.frame | |
screen = API.main_screen | |
sframe = screen.frame_without_dock_or_menu | |
frame = Rect.new | |
frame.x = (sframe.w - wframe.w) / 2 | |
frame.y = (sframe.h - wframe.h) / 2 | |
frame.w = wframe.w | |
frame.h = wframe.h | |
win.frame = frame | |
end | |
wait_on_callbacks |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment