From 9f62ebd52b7aa745764b81ae562478f4c3537947 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Wed, 3 Jul 2019 20:31:37 +0200 Subject: window.lua: Add large increment window resize hotkeys Change the modifiers to match the window movement hotkeys. --- README.rst | 48 +++++++++++++++++++++++++++++------------------- init.lua | 21 +++++++++++++-------- window.lua | 51 +++++++++++++++++++++++++++++++++++++++++++-------- 3 files changed, 85 insertions(+), 35 deletions(-) diff --git a/README.rst b/README.rst index f89558f..e095b71 100644 --- a/README.rst +++ b/README.rst @@ -45,25 +45,35 @@ Upon activating the mode, the following shortcuts are available: | ``]`` | Move window right one screen | +-------+------------------------------+ -+-------+---------------------------------+ -| ``e`` | Reduce window height 20 units | -+-------+---------------------------------+ -| ``s`` | Reduce window width 20 units | -+-------+---------------------------------+ -| ``d`` | Increase window height 20 units | -+-------+---------------------------------+ -| ``f`` | Increase window width 20 units | -+-------+---------------------------------+ - -+-------------+--------------------------------+ -| ``Shift-e`` | Reduce window height 5 units | -+-------------+--------------------------------+ -| ``Shift-s`` | Reduce window width 5 units | -+-------------+--------------------------------+ -| ``Shift-d`` | Increase window height 5 units | -+-------------+--------------------------------+ -| ``Shift-f`` | Increase window width 5 units | -+-------------+--------------------------------+ ++-------+----------------------------------+ +| ``e`` | Reduce window height 100 units | ++-------+----------------------------------+ +| ``s`` | Reduce window width 100 units | ++-------+----------------------------------+ +| ``d`` | Increase window height 100 units | ++-------+----------------------------------+ +| ``f`` | Increase window width 100 units | ++-------+----------------------------------+ + ++-------------+---------------------------------+ +| ``Shift-e`` | Reduce window height 20 units | ++-------------+---------------------------------+ +| ``Shift-s`` | Reduce window width 20 units | ++-------------+---------------------------------+ +| ``Shift-d`` | Increase window height 20 units | ++-------------+---------------------------------+ +| ``Shift-f`` | Increase window width 20 units | ++-------------+---------------------------------+ + ++--------------+--------------------------------+ +| ``Option-e`` | Reduce window height 5 units | ++--------------+--------------------------------+ +| ``Option-s`` | Reduce window width 5 units | ++--------------+--------------------------------+ +| ``Option-d`` | Increase window height 5 units | ++--------------+--------------------------------+ +| ``Option-f`` | Increase window width 5 units | ++--------------+--------------------------------+ Install diff --git a/init.lua b/init.lua index cce2097..ccb0415 100644 --- a/init.lua +++ b/init.lua @@ -24,15 +24,20 @@ --- [: Move window left one screen --- ]: Move window right one screen --- ---- e: Reduce window height 20 units ---- s: Reduce window width 20 units ---- d: Increase window height 20 units ---- f: Increase window width 20 units +--- e: Reduce window height 100 units +--- s: Reduce window width 100 units +--- d: Increase window height 100 units +--- f: Increase window width 100 units --- ---- Shift-e: Reduce window height 5 units ---- Shift-s: Reduce window width 5 units ---- Shift-d: Increase window height 5 units ---- Shift-f: Increase window width 5 units +--- Shift-e: Reduce window height 20 units +--- Shift-s: Reduce window width 20 units +--- Shift-d: Increase window height 20 units +--- Shift-f: Increase window width 20 units +--- +--- Option-e: Reduce window height 5 units +--- Option-s: Reduce window width 5 units +--- Option-d: Increase window height 5 units +--- Option-f: Increase window width 5 units -- Copyright (c) 2019 Teddy Wing -- diff --git a/window.lua b/window.lua index 8848275..955cbdb 100644 --- a/window.lua +++ b/window.lua @@ -42,6 +42,12 @@ local units = { decrease_up_med = { w = 0, h = -20 }, decrease_left_med = { w = -20, h = 0 }, + increase_right_lg = { w = 100, h = 0 }, + increase_down_lg = { w = 0, h = 100 }, + + decrease_up_lg = { w = 0, h = -100 }, + decrease_left_lg = { w = -100, h = 0 }, + maximum = { x = 0.00, y = 0.00, w = 1.00, h = 1.00 } } @@ -151,6 +157,30 @@ function window.decrease_left_med() ) end +function window.increase_right_lg() + hs.window.focusedWindow():setSize( + window.relative_size(hs.window.focusedWindow(), units.increase_right_lg) + ) +end + +function window.increase_down_lg() + hs.window.focusedWindow():setSize( + window.relative_size(hs.window.focusedWindow(), units.increase_down_lg) + ) +end + +function window.decrease_up_lg() + hs.window.focusedWindow():setSize( + window.relative_size(hs.window.focusedWindow(), units.decrease_up_lg) + ) +end + +function window.decrease_left_lg() + hs.window.focusedWindow():setSize( + window.relative_size(hs.window.focusedWindow(), units.decrease_left_lg) + ) +end + function window.move_to_top() local position = hs.window.focusedWindow():topLeft() @@ -186,15 +216,20 @@ function window:bindModal(modifiers, keycode) window_mode:bind({}, ']', function() hs.window.focusedWindow():moveOneScreenEast(true, false, 0) end) window_mode:bind({}, '[', function() hs.window.focusedWindow():moveOneScreenWest(true, false, 0) end) - window_mode:bind({'shift'}, 'e', window.decrease_up, nil, window.decrease_up) - window_mode:bind({'shift'}, 'd', window.increase_down, nil, window.increase_down) - window_mode:bind({'shift'}, 'f', window.increase_right, nil, window.increase_right) - window_mode:bind({'shift'}, 's', window.decrease_left, nil, window.decrease_left) + window_mode:bind({'option'}, 'e', window.decrease_up, nil, window.decrease_up) + window_mode:bind({'option'}, 'd', window.increase_down, nil, window.increase_down) + window_mode:bind({'option'}, 'f', window.increase_right, nil, window.increase_right) + window_mode:bind({'option'}, 's', window.decrease_left, nil, window.decrease_left) + + window_mode:bind({'shift'}, 'e', window.decrease_up_med, nil, window.decrease_up_med) + window_mode:bind({'shift'}, 'd', window.increase_down_med, nil, window.increase_down_med) + window_mode:bind({'shift'}, 'f', window.increase_right_med, nil, window.increase_right_med) + window_mode:bind({'shift'}, 's', window.decrease_left_med, nil, window.decrease_left_med) - window_mode:bind({}, 'e', window.decrease_up_med, nil, window.decrease_up_med) - window_mode:bind({}, 'd', window.increase_down_med, nil, window.increase_down_med) - window_mode:bind({}, 'f', window.increase_right_med, nil, window.increase_right_med) - window_mode:bind({}, 's', window.decrease_left_med, nil, window.decrease_left_med) + window_mode:bind({}, 'e', window.decrease_up_lg, nil, window.decrease_up_lg) + window_mode:bind({}, 'd', window.increase_down_lg, nil, window.increase_down_lg) + window_mode:bind({}, 'f', window.increase_right_lg, nil, window.increase_right_lg) + window_mode:bind({}, 's', window.decrease_left_lg, nil, window.decrease_left_lg) end return window -- cgit v1.2.3