Skip to content

Commit 1206f03

Browse files
author
Nicola Paolucci
committed
[hammerspoon] rotation of states reset properly
1 parent 71dd60e commit 1206f03

File tree

2 files changed

+44
-9
lines changed

2 files changed

+44
-9
lines changed

.bashrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# Source: http://github.com/durdn/cfg/.bashrc
44

55
#Global options {{{
6+
export SHELL_SESSION_HISTORY=0
67
export HISTFILESIZE=999999
78
export HISTSIZE=999999
89
export HISTCONTROL=ignoredups:ignorespace

.hammerspoon/init.lua

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,35 @@
33
-- end)
44

55
-- half left
6+
rightjust = 0
7+
leftjust = 0
8+
centered = 0
69
hs.hotkey.bind({"alt"}, "h", function()
710
local win = hs.window.focusedWindow()
811
local f = win:frame()
912
local screen = win:screen()
1013
local max = screen:frame()
1114

12-
f.x = max.x
13-
f.y = max.y
14-
f.w = max.w / 2
15-
f.h = max.h
15+
if leftjust == 0 then
16+
f.x = max.x
17+
f.y = max.y
18+
f.w = max.w / 2
19+
f.h = max.h
20+
elseif leftjust == 1 then
21+
f.x = max.x
22+
f.y = max.y
23+
f.w = max.w / 2
24+
f.h = max.h / 2
25+
elseif leftjust == 2 then
26+
f.x = max.x
27+
f.y = max.y + (max.h / 2)
28+
f.w = max.w / 2
29+
f.h = max.h / 2
30+
end
31+
rightjust = 0
32+
centered = 0
1633
win:setFrame(f)
34+
leftjust = (leftjust + 1) % 3
1735
end)
1836

1937
-- half right
@@ -23,11 +41,26 @@ hs.hotkey.bind({"alt"}, "l", function()
2341
local screen = win:screen()
2442
local max = screen:frame()
2543

26-
f.x = max.x + (max.w / 2)
27-
f.y = max.y
28-
f.w = max.w / 2
29-
f.h = max.h
44+
if rightjust == 0 then
45+
f.x = max.x + (max.w / 2)
46+
f.y = max.y
47+
f.w = max.w / 2
48+
f.h = max.h
49+
elseif rightjust == 1 then
50+
f.x = max.x + (max.w / 2)
51+
f.y = max.y
52+
f.w = max.w / 2
53+
f.h = max.h / 2
54+
elseif rightjust == 2 then
55+
f.x = max.x + (max.w / 2)
56+
f.y = max.y + (max.h / 2)
57+
f.w = max.w / 2
58+
f.h = max.h / 2
59+
end
60+
leftjust = 0
61+
centered = 0
3062
win:setFrame(f)
63+
rightjust = (rightjust + 1) % 3
3164
end)
3265

3366
-- maximise
@@ -45,7 +78,6 @@ hs.hotkey.bind({"alt"}, "m", function()
4578
end)
4679

4780
-- center
48-
centered = 0
4981
hs.hotkey.bind({"alt"}, "c", function()
5082
local win = hs.window.focusedWindow()
5183
local f = win:frame()
@@ -63,6 +95,8 @@ hs.hotkey.bind({"alt"}, "c", function()
6395
f.w = max.w/2
6496
f.h = max.h/2
6597
end
98+
leftjust = 0
99+
rightjust = 0
66100
win:setFrame(f)
67101
centered = (centered + 1) % 2
68102
end)

0 commit comments

Comments
 (0)