Created
July 31, 2014 14:10
-
-
Save silasb/27c1c2185d76de1b814e to your computer and use it in GitHub Desktop.
Ability to move window to east and west screens if we are already east or west wall.
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
function movewindow_righthalf() | |
local win = window.focusedwindow() | |
local win_size = win:size() | |
local win_point = win:topleft() | |
local newframe = win:screen():frame_without_dock_or_menu() | |
newframe.w = newframe.w / 2 | |
newframe.x = newframe.x + newframe.w -- comment out this line to push it to left half of screen | |
local frame_already_on_east_wall = newframe.h == win_size.h and newframe.w == win_size.w and | |
newframe.x == win_point.x and newframe.y == win_point.y | |
if frame_already_on_east_wall then | |
local screen = win:screen():toeast() | |
if screen then | |
local frame_to_east = screen:frame_without_dock_or_menu() | |
frame_to_east.w = frame_to_east.w / 2 | |
win:setframe(frame_to_east) | |
end | |
else | |
win:setframe(newframe) | |
end | |
end | |
function movewindow_lefthalf() | |
local win = window.focusedwindow() | |
local win_size = win:size() | |
local win_point = win:topleft() | |
local newframe = win:screen():frame_without_dock_or_menu() | |
newframe.w = newframe.w / 2 | |
local frame_already_on_west_wall = newframe.h == win_size.h and newframe.w == win_size.w and | |
newframe.x == win_point.x and newframe.y == win_point.y | |
if frame_already_on_west_wall then | |
local screen = win:screen():towest() | |
if screen then | |
local frame_to_west = screen:frame_without_dock_or_menu() | |
frame_to_west.w = frame_to_west.w / 2 | |
frame_to_west.x = frame_to_west.x + frame_to_west.w | |
win:setframe(frame_to_west) | |
end | |
else | |
win:setframe(newframe) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment