diff --git a/Window Manager.alfredworkflow b/Window Manager.alfredworkflow
index 83fbf15..11043c2 100644
Binary files a/Window Manager.alfredworkflow and b/Window Manager.alfredworkflow differ
diff --git a/src/WindowManager.py b/src/WindowManager.py
index 36330ef..9ec0736 100644
--- a/src/WindowManager.py
+++ b/src/WindowManager.py
@@ -111,18 +111,58 @@ def __init__(self, dim: str()) -> None:
self.dimension = json.loads(dim)
def x_pos(self) -> int:
+ """
+ Get x position of the window from a str represenation of a dimension
+
+ Returns:
+
+ int: x postition
+
+ """
return int(self.dimension.get('x', None))
def y_pos(self) -> int:
+ """
+ Get y position of the window from a str represenation of a dimension
+
+ Returns:
+
+ int: y postition
+
+ """
return int(self.dimension.get('y', None))
def width(self) -> int:
+ """
+ Get width of the window from a str represenation of a dimension
+
+ Returns:
+
+ int: window width
+
+ """
return int(self.dimension.get('width', None))
def height(self) -> int:
+ """
+ Get height of the window from a str represenation of a dimension
+
+ Returns:
+
+ int: window height
+
+ """
return int(self.dimension.get('height', None))
def get_dimensions(self) -> dict:
+ """
+ Get dimension from dimension provided as string
+
+ Returns:
+
+ int: dimension
+
+ """
return self.dimension
@@ -132,9 +172,25 @@ def __init__(self) -> None:
self.screen_res = self._sys_profiler()
def screen_width(self) -> int:
+ """
+ Get screen width
+
+ Returns:
+
+ int: screen width
+
+ """
return self.screen_res[0]
def screen_height(self) -> int:
+ """
+ Get Screen height
+
+ Returns:
+
+ int: screen height
+
+ """
return self.screen_res[1]
def _sys_profiler(self) -> tuple:
diff --git a/src/get_dimensions.py b/src/get_dimensions.py
index eaa6ad7..d58bc00 100644
--- a/src/get_dimensions.py
+++ b/src/get_dimensions.py
@@ -10,14 +10,15 @@
cache_file = os.path.join(cache_dir, "dimensions.json")
app_id = Tools.getEnv('app_id') # get app id from previous wf step
-post_action = Tools.getArgv(1) # get post action e.g 'delete' from prev step
+post_action = Tools.getArgv(1) # post action e.g 'delete' from prev step
delete_entry = True if post_action == 'delete' else False
Dim = Dimensions(cache_file)
+# read dimensionsn and deltet the entry when post action == delete
vars = Dim.get_dimension(app_id, delete=delete_entry)
if vars == None or vars == {}:
- vars = json.loads('{"x":521,"y":404,"width":1073,"height":565}') # fallback
+ vars = json.loads('{"x":521,"y":404,"width":1073,"height":565}') # fallback dimensions
aj = AlfJson()
aj.add_variables(vars)
diff --git a/src/info.plist b/src/info.plist
index 3af9286..18bdd65 100644
--- a/src/info.plist
+++ b/src/info.plist
@@ -60,6 +60,30 @@
vitoclose
+
+ destinationuid
+ 980F8228-5E0B-479A-819C-653F9F8B8DF5
+ modifiers
+ 0
+ modifiersubtext
+
+ sourceoutputuid
+ 344349A7-17A2-4EBB-AAE5-F92BDDF0D289
+ vitoclose
+
+
+
+ destinationuid
+ CFAD3BF2-AB4B-4DA4-ADD9-3C68698ABA6E
+ modifiers
+ 0
+ modifiersubtext
+
+ sourceoutputuid
+ AFEE483B-C085-48B6-B72E-B882A0A265B5
+ vitoclose
+
+
22201393-C9B4-4640-8A11-350343F16191
@@ -78,7 +102,7 @@
destinationuid
- EF549D57-A294-4ED5-B421-59B5F50B39DB
+ D0BA191C-A3CE-4974-A263-B9979376FFEF
modifiers
0
modifiersubtext
@@ -152,19 +176,6 @@
- 4F266713-42A1-460C-B59D-AA7839398302
-
-
- destinationuid
- D5D03267-BC05-4901-A995-FF97DC4788D2
- modifiers
- 0
- modifiersubtext
-
- vitoclose
-
-
-
5E6F5E3B-B9CB-449B-9724-E4E8B4F45CC1
@@ -247,7 +258,7 @@
destinationuid
- 4F266713-42A1-460C-B59D-AA7839398302
+ D0BA191C-A3CE-4974-A263-B9979376FFEF
modifiers
0
modifiersubtext
@@ -295,32 +306,6 @@
- BA1C121D-CDD6-4C92-9A54-9BA8B582A69C
-
-
- destinationuid
- DFAB7703-E721-48C0-8903-E5FD4582B311
- modifiers
- 0
- modifiersubtext
-
- vitoclose
-
-
-
- C57CE0D7-D6BB-49AC-83C0-7B26EF57644A
-
-
- destinationuid
- D9985E7C-DCF8-4D3B-8FBC-0F7B70D3F973
- modifiers
- 0
- modifiersubtext
-
- vitoclose
-
-
-
C76A989A-F196-41C9-BF7C-D85DE630794D
@@ -360,19 +345,6 @@
- D5D03267-BC05-4901-A995-FF97DC4788D2
-
-
- destinationuid
- C57CE0D7-D6BB-49AC-83C0-7B26EF57644A
- modifiers
- 0
- modifiersubtext
-
- vitoclose
-
-
-
D65BB2F2-21FE-475E-9598-B0503F6C828B
@@ -386,32 +358,6 @@
- D9985E7C-DCF8-4D3B-8FBC-0F7B70D3F973
-
-
- destinationuid
- CFAD3BF2-AB4B-4DA4-ADD9-3C68698ABA6E
- modifiers
- 0
- modifiersubtext
-
- vitoclose
-
-
-
- DFAB7703-E721-48C0-8903-E5FD4582B311
-
-
- destinationuid
- F38BCC86-A1FD-4572-B86A-AD4A6F0BC981
- modifiers
- 0
- modifiersubtext
-
- vitoclose
-
-
-
E71F89BE-1869-4DAF-BCDD-CA883A26CECF
@@ -438,32 +384,6 @@
- EF549D57-A294-4ED5-B421-59B5F50B39DB
-
-
- destinationuid
- BA1C121D-CDD6-4C92-9A54-9BA8B582A69C
- modifiers
- 0
- modifiersubtext
-
- vitoclose
-
-
-
- F38BCC86-A1FD-4572-B86A-AD4A6F0BC981
-
-
- destinationuid
- 980F8228-5E0B-479A-819C-653F9F8B8DF5
- modifiers
- 0
- modifiersubtext
-
- vitoclose
-
-
-
F9ED3B81-132C-4B76-AFED-DC01089EDD0D
@@ -599,148 +519,18 @@
version
2
-
- config
-
- concurrently
-
- escaping
- 102
- script
- query=$1
-
-./save_dimensions.py $query
- scriptargtype
- 1
- scriptfile
-
- type
- 5
-
- type
- alfred.workflow.action.script
- uid
- D9985E7C-DCF8-4D3B-8FBC-0F7B70D3F973
- version
- 2
-
-
- config
-
- tasksettings
-
- out_format
- bundle_id
-
- taskuid
- com.alfredapp.automation.core/macOS/app.current
-
- type
- alfred.workflow.automation.task
- uid
- 4F266713-42A1-460C-B59D-AA7839398302
- version
- 1
-
config
tasksettings
taskuid
- com.alfredapp.automation.core/window-management/windows.current.bounds
-
- type
- alfred.workflow.automation.task
- uid
- C57CE0D7-D6BB-49AC-83C0-7B26EF57644A
- version
- 1
-
-
- config
-
- tasksettings
-
- preset
- maximise
-
- taskuid
com.alfredapp.automation.core/window-management/windows.current.bounds.set.preset
type
alfred.workflow.automation.task
uid
- CFAD3BF2-AB4B-4DA4-ADD9-3C68698ABA6E
- version
- 1
-
-
- config
-
- action
- 0
- argument
- 0
- focusedappvariable
-
- focusedappvariablename
-
- hotkey
- 46
- hotmod
- 786432
- hotstring
- M
- leftcursor
-
- modsmode
- 0
- relatedAppsMode
- 0
-
- type
- alfred.workflow.trigger.hotkey
- uid
- 888A02A3-2C70-4D4A-A926-A4954E8E9BD5
- version
- 2
-
-
- config
-
- argument
-
- passthroughargument
-
- variables
-
- app_id
- {query}
-
-
- type
- alfred.workflow.utility.argument
- uid
- D5D03267-BC05-4901-A995-FF97DC4788D2
- version
- 1
-
-
- config
-
- tasksettings
-
- preset
- centre
-
- taskuid
- com.alfredapp.automation.core/window-management/windows.current.bounds.set.preset
-
- type
- alfred.workflow.automation.task
- uid
- E90EB173-3B7E-4C6C-B148-E83B370D1154
+ 561D6C7F-E66D-40EB-8814-4E275EED1214
version
1
@@ -750,17 +540,19 @@
action
0
argument
- 0
+ 3
+ argumenttext
+ left
focusedappvariable
focusedappvariablename
hotkey
- 8
+ 33
hotmod
786432
hotstring
- C
+ [
leftcursor
modsmode
@@ -771,7 +563,7 @@
type
alfred.workflow.trigger.hotkey
uid
- 38151F7B-8008-4180-B4E4-9C5D423C5066
+ D2302F7A-7011-4B69-995F-29395ABE636E
version
2
@@ -781,17 +573,19 @@
action
0
argument
- 0
+ 3
+ argumenttext
+ right
focusedappvariable
focusedappvariablename
hotkey
- 4
+ 30
hotmod
786432
hotstring
- H
+ ]
leftcursor
modsmode
@@ -802,153 +596,101 @@
type
alfred.workflow.trigger.hotkey
uid
- 23D71A90-5EC3-4261-A130-EE34F4505EB5
- version
- 2
-
-
- config
-
- concurrently
-
- escaping
- 102
- script
- query=$1
-
-./save_dimensions.py $query
- scriptargtype
- 1
- scriptfile
-
- type
- 5
-
- type
- alfred.workflow.action.script
- uid
- F38BCC86-A1FD-4572-B86A-AD4A6F0BC981
+ 411DB4D7-6C73-4FA1-99A5-E2A2C8068D85
version
2
-
- config
-
- tasksettings
-
- out_format
- bundle_id
-
- taskuid
- com.alfredapp.automation.core/macOS/app.current
-
- type
- alfred.workflow.automation.task
- uid
- EF549D57-A294-4ED5-B421-59B5F50B39DB
- version
- 1
-
config
tasksettings
preset
- twothirds-centrewidth
-
- taskuid
- com.alfredapp.automation.core/window-management/windows.current.bounds.set.preset
-
- type
- alfred.workflow.automation.task
- uid
- 980F8228-5E0B-479A-819C-653F9F8B8DF5
- version
- 1
-
-
- config
-
- tasksettings
-
- taskuid
- com.alfredapp.automation.core/window-management/windows.current.bounds
-
- type
- alfred.workflow.automation.task
- uid
- DFAB7703-E721-48C0-8903-E5FD4582B311
- version
- 1
-
-
- config
-
- argument
-
- passthroughargument
-
- variables
-
- app_id
- {query}
+ half-right
-
- type
- alfred.workflow.utility.argument
- uid
- BA1C121D-CDD6-4C92-9A54-9BA8B582A69C
- version
- 1
-
-
- config
-
- tasksettings
-
taskuid
com.alfredapp.automation.core/window-management/windows.current.bounds.set.preset
type
alfred.workflow.automation.task
uid
- 561D6C7F-E66D-40EB-8814-4E275EED1214
+ 7CFADCC9-E898-4C75-9703-919B361362A6
version
1
config
- action
- 0
- argument
- 3
- argumenttext
- left
- focusedappvariable
-
- focusedappvariablename
-
- hotkey
- 33
- hotmod
- 786432
- hotstring
- [
- leftcursor
-
- modsmode
- 0
- relatedAppsMode
- 0
+ conditions
+
+
+ inputstring
+ {var:direction}
+ matchcasesensitive
+
+ matchmode
+ 0
+ matchstring
+ left
+ outputlabel
+ left
+ uid
+ A2DD67A8-6C3C-48EC-9497-B5FD00A9868C
+
+
+ inputstring
+ {var:direction}
+ matchcasesensitive
+
+ matchmode
+ 0
+ matchstring
+ right
+ outputlabel
+ right
+ uid
+ 4918B6D8-F620-4FC2-A1FD-15DD8F7C5D0F
+
+
+ inputstring
+ {var:direction}
+ matchcasesensitive
+
+ matchmode
+ 0
+ matchstring
+ center_two_thirds
+ outputlabel
+ center_two_thirds
+ uid
+ 344349A7-17A2-4EBB-AAE5-F92BDDF0D289
+
+
+ inputstring
+ {var:direction}
+ matchcasesensitive
+
+ matchmode
+ 0
+ matchstring
+ maximize
+ outputlabel
+ maximize
+ uid
+ AFEE483B-C085-48B6-B72E-B882A0A265B5
+
+
+ elselabel
+ else
+ hideelse
+
type
- alfred.workflow.trigger.hotkey
+ alfred.workflow.utility.conditional
uid
- D2302F7A-7011-4B69-995F-29395ABE636E
+ 19C17E3D-DA6F-4A35-9E9B-455BA4FD1031
version
- 2
+ 1
config
@@ -1011,46 +753,20 @@
config
- conditions
-
-
- inputstring
- {var:direction}
- matchcasesensitive
-
- matchmode
- 0
- matchstring
- left
- outputlabel
- left
- uid
- A2DD67A8-6C3C-48EC-9497-B5FD00A9868C
-
-
- inputstring
- {var:direction}
- matchcasesensitive
-
- matchmode
- 0
- matchstring
- right
- outputlabel
- right
- uid
- 4918B6D8-F620-4FC2-A1FD-15DD8F7C5D0F
-
-
- elselabel
- else
- hideelse
-
+ argument
+
+ passthroughargument
+
+ variables
+
+ app_id
+ {query}
+
type
- alfred.workflow.utility.conditional
+ alfred.workflow.utility.argument
uid
- 19C17E3D-DA6F-4A35-9E9B-455BA4FD1031
+ B269FAEA-BEC7-42B2-8575-605D0C2C09EC
version
1
@@ -1063,34 +779,65 @@
variables
- app_id
+ direction
{query}
type
alfred.workflow.utility.argument
uid
- B269FAEA-BEC7-42B2-8575-605D0C2C09EC
+ D0BA191C-A3CE-4974-A263-B9979376FFEF
version
1
config
+ action
+ 0
argument
+ 3
+ argumenttext
+ center_two_thirds
+ focusedappvariable
+
+ focusedappvariablename
- passthroughargument
+ hotkey
+ 4
+ hotmod
+ 786432
+ hotstring
+ H
+ leftcursor
- variables
+ modsmode
+ 0
+ relatedAppsMode
+ 0
+
+ type
+ alfred.workflow.trigger.hotkey
+ uid
+ 23D71A90-5EC3-4261-A130-EE34F4505EB5
+ version
+ 2
+
+
+ config
+
+ tasksettings
- direction
- {query}
+ preset
+ twothirds-centrewidth
+ taskuid
+ com.alfredapp.automation.core/window-management/windows.current.bounds.set.preset
type
- alfred.workflow.utility.argument
+ alfred.workflow.automation.task
uid
- D0BA191C-A3CE-4974-A263-B9979376FFEF
+ 980F8228-5E0B-479A-819C-653F9F8B8DF5
version
1
@@ -1102,17 +849,17 @@
argument
3
argumenttext
- right
+ maximize
focusedappvariable
focusedappvariablename
hotkey
- 30
+ 46
hotmod
786432
hotstring
- ]
+ M
leftcursor
modsmode
@@ -1123,7 +870,7 @@
type
alfred.workflow.trigger.hotkey
uid
- 411DB4D7-6C73-4FA1-99A5-E2A2C8068D85
+ 888A02A3-2C70-4D4A-A926-A4954E8E9BD5
version
2
@@ -1133,7 +880,7 @@
tasksettings
preset
- half-right
+ maximise
taskuid
com.alfredapp.automation.core/window-management/windows.current.bounds.set.preset
@@ -1141,7 +888,56 @@
type
alfred.workflow.automation.task
uid
- 7CFADCC9-E898-4C75-9703-919B361362A6
+ CFAD3BF2-AB4B-4DA4-ADD9-3C68698ABA6E
+ version
+ 1
+
+
+ config
+
+ action
+ 0
+ argument
+ 0
+ focusedappvariable
+
+ focusedappvariablename
+
+ hotkey
+ 8
+ hotmod
+ 786432
+ hotstring
+ C
+ leftcursor
+
+ modsmode
+ 0
+ relatedAppsMode
+ 0
+
+ type
+ alfred.workflow.trigger.hotkey
+ uid
+ 38151F7B-8008-4180-B4E4-9C5D423C5066
+ version
+ 2
+
+
+ config
+
+ tasksettings
+
+ preset
+ centre
+
+ taskuid
+ com.alfredapp.automation.core/window-management/windows.current.bounds.set.preset
+
+ type
+ alfred.workflow.automation.task
+ uid
+ E90EB173-3B7E-4C6C-B148-E83B370D1154
version
1
@@ -1173,7 +969,7 @@
script
query=$1
-./get_dimensions.py delete
+./get_dimensions.py $query
scriptargtype
1
scriptfile
@@ -1644,58 +1440,64 @@ Keyboard shortcuts below are suggestions:
0AA55BB7-9F32-4DA6-8F55-DAD10CF532FF
+ colorindex
+ 6
note
Scale up left side of the window
xpos
- 55
+ 50
ypos
- 1815
+ 2130
0FB4C25D-DC38-42C7-8070-516CE4943789
+ colorindex
+ 6
note
Scale down window
xpos
- 55
+ 50
ypos
- 1505
+ 1820
10499795-894B-44C4-9953-016F46E1135D
xpos
- 840
+ 1285
ypos
- 1365
+ 1680
19C17E3D-DA6F-4A35-9E9B-455BA4FD1031
xpos
- 1040
+ 1035
ypos
- 960
+ 640
22201393-C9B4-4640-8A11-350343F16191
xpos
- 840
+ 865
ypos
- 940
+ 650
23D71A90-5EC3-4261-A130-EE34F4505EB5
+ colorindex
+ 3
note
Center Two Thirds
xpos
- 60
+ 65
ypos
- 675
+ 755
26D6E144-607A-492B-9D56-EE7349D443B4
xpos
- 840
+ 1280
ypos
- 1175
+ 1310
3204E945-B6BF-4265-AAA8-C6C25741884E
@@ -1711,25 +1513,27 @@ Keyboard shortcuts below are suggestions:
3411AFF0-2041-4E95-B451-45847D3EFE3E
xpos
- 400
+ 435
ypos
- 1365
+ 1680
34BFA0E9-B1E3-4F31-B594-AAEED8A8299D
xpos
- 640
+ 665
ypos
- 940
+ 650
38151F7B-8008-4180-B4E4-9C5D423C5066
+ colorindex
+ 3
note
Center Window
xpos
- 60
+ 65
ypos
- 520
+ 1080
411DB4D7-6C73-4FA1-99A5-E2A2C8068D85
@@ -1738,23 +1542,18 @@ Keyboard shortcuts below are suggestions:
note
Window to the right screen
xpos
- 55
- ypos
- 1015
-
- 4F266713-42A1-460C-B59D-AA7839398302
-
- xpos
- 245
+ 65
ypos
- 375
+ 565
561D6C7F-E66D-40EB-8814-4E275EED1214
+ note
+ Left
xpos
- 1165
+ 1280
ypos
- 835
+ 395
5E6F5E3B-B9CB-449B-9724-E4E8B4F45CC1
@@ -1770,135 +1569,137 @@ Keyboard shortcuts below are suggestions:
61F8EE82-4398-4234-8CC2-A79D378F0D91
xpos
- 375
+ 1270
ypos
60
69CEBDAD-0632-4A61-9233-9F35F7E9F02C
xpos
- 310
+ 295
ypos
- 1395
+ 1710
7903F372-2DC3-488B-9D7F-E575C0C1DFFE
+ colorindex
+ 6
note
Move window left
xpos
- 55
+ 50
ypos
- 1970
+ 2285
7AB06038-BFF3-4C09-87A1-2558A032D37A
+ colorindex
+ 6
note
Move window right
xpos
- 55
+ 50
ypos
- 2100
+ 2415
7AE7B102-6F0E-4086-A929-4CBC0F8F230F
colorindex
- 3
+ 1
note
Reset Window
xpos
- 55
+ 65
ypos
- 1175
+ 1310
7CFADCC9-E898-4C75-9703-919B361362A6
+ note
+ Right
xpos
- 1170
+ 1280
ypos
- 1015
+ 570
7FBAFD3E-D7E8-4F5E-B79C-08BAE6819634
+ colorindex
+ 6
note
Move window up
xpos
- 50
+ 45
ypos
- 2230
+ 2545
888A02A3-2C70-4D4A-A926-A4954E8E9BD5
+ colorindex
+ 3
note
Maximize
xpos
- 60
+ 65
ypos
- 375
+ 900
951B4211-41AD-4138-967E-9C35F483E46F
xpos
- 410
+ 435
ypos
- 1175
+ 1310
980F8228-5E0B-479A-819C-653F9F8B8DF5
+ note
+ Center Two Thirds
xpos
- 825
+ 1280
ypos
- 675
+ 765
B112413B-7E57-4B10-8450-284C42B5E36F
xpos
- 415
+ 440
ypos
- 940
+ 650
B269FAEA-BEC7-42B2-8575-605D0C2C09EC
xpos
- 565
- ypos
- 970
-
- BA1C121D-CDD6-4C92-9A54-9BA8B582A69C
-
- xpos
- 390
- ypos
- 705
-
- C57CE0D7-D6BB-49AC-83C0-7B26EF57644A
-
- xpos
- 480
+ 590
ypos
- 375
+ 680
C76A989A-F196-41C9-BF7C-D85DE630794D
+ colorindex
+ 6
note
Scale up right side of the window
xpos
- 55
+ 50
ypos
- 1660
+ 1975
CFAD3BF2-AB4B-4DA4-ADD9-3C68698ABA6E
+ note
+ Maximize
xpos
- 830
+ 1280
ypos
- 375
+ 935
D0BA191C-A3CE-4974-A263-B9979376FFEF
xpos
- 330
+ 350
ypos
- 970
+ 680
D2302F7A-7011-4B69-995F-29395ABE636E
@@ -1907,97 +1708,68 @@ Keyboard shortcuts below are suggestions:
note
Window to the left screen
xpos
- 55
- ypos
- 880
-
- D5D03267-BC05-4901-A995-FF97DC4788D2
-
- xpos
- 390
+ 65
ypos
- 405
+ 430
D65BB2F2-21FE-475E-9598-B0503F6C828B
xpos
- 560
- ypos
- 1205
-
- D9985E7C-DCF8-4D3B-8FBC-0F7B70D3F973
-
- xpos
- 665
- ypos
- 375
-
- DFAB7703-E721-48C0-8903-E5FD4582B311
-
- xpos
- 480
+ 590
ypos
- 675
+ 1340
E71F89BE-1869-4DAF-BCDD-CA883A26CECF
+ colorindex
+ 6
note
Move window down
xpos
- 50
+ 45
ypos
- 2365
+ 2680
E90EB173-3B7E-4C6C-B148-E83B370D1154
+ note
+ Center
xpos
- 390
+ 1280
ypos
- 520
+ 1085
ED2BA858-527C-44E5-9FF2-D9421C2F823C
xpos
- 635
+ 865
ypos
- 1175
+ 1310
EEB61DAA-AC41-493F-9CA0-93678C6BCD3B
xpos
- 380
+ 1275
ypos
195
- EF549D57-A294-4ED5-B421-59B5F50B39DB
-
- xpos
- 245
- ypos
- 675
-
- F38BCC86-A1FD-4572-B86A-AD4A6F0BC981
-
- xpos
- 665
- ypos
- 675
-
F9ED3B81-132C-4B76-AFED-DC01089EDD0D
xpos
- 600
+ 865
ypos
- 1365
+ 1680
FE582004-9AD4-40DD-AB0B-13BEABC1B505
+ colorindex
+ 6
note
Scale up window
xpos
- 55
+ 50
ypos
- 1365
+ 1680
userconfigurationconfig
@@ -2048,7 +1820,7 @@ Keyboard shortcuts below are suggestions:
variablesdontexport
version
- 1.1.2
+ 1.1.3
webaddress
https://github.com/Acidham/alfred-window-manager
diff --git a/src/save_dimensions.py b/src/save_dimensions.py
index c55abaa..9bdeb78 100644
--- a/src/save_dimensions.py
+++ b/src/save_dimensions.py
@@ -6,6 +6,8 @@
from Alfred3 import Tools
from WindowManager import Dimensions
+IGNORE_PREV_ACTIONS = ('left', 'right', 'maximize', 'center_two_thirds')
+
app_id = Tools.getEnv('app_id')
direction = Tools.getEnv('direction')
window_dimensions = json.loads(Tools.getArgv(1))
@@ -15,7 +17,5 @@
Dim = Dimensions(cache_file)
pre_dim = Dim.get_dimension(app_id)
prev_action = pre_dim.get('prev_action', None)
-if (direction == 'right' or direction == 'left') and (prev_action == 'left' or prev_action == 'right'):
- pass
-else:
+if prev_action not in IGNORE_PREV_ACTIONS: # Save only when previous action is not part of ignored action
Dim.add_dimension(app_id, window_dimensions, prev_action=direction)
diff --git a/src/window_pos.py b/src/window_pos.py
deleted file mode 100644
index 214c84b..0000000
--- a/src/window_pos.py
+++ /dev/null
@@ -1,75 +0,0 @@
-#!/usr/bin/python3
-
-import os
-
-from Alfred3 import AlfJson, Tools
-from WindowManager import Dimensions, Screen, Window
-
-
-def get_dock_position() -> str:
- return os.popen('defaults read com.apple.dock orientation').read().strip()
-
-
-def get_dock_size() -> int:
- ts = int(os.popen('defaults read com.apple.dock tilesize').read().strip())
- autohide = int(os.popen('defaults read com.apple.dock autohide').read().strip())
- return int((ts+20)/2) if autohide == 0 else 0
-
-
-cache_dir = Tools.getCacheDir()
-cache_file = os.path.join(cache_dir, "dimensions.json")
-Tools.log(f"Cache File: {cache_file}")
-app_id = Tools.getEnv("app_id")
-Tools.log(f"App ID: {app_id}")
-
-
-window_postion = Tools.getArgv(1)
-# window_postion = '{"x":521,"y":404,"width":1073,"height":565}' # uncomment for testing
-direction = Tools.getEnv("direction")
-
-# Get Window positions of Frontmost app
-Win = Window(window_postion)
-actual_window_pos = Win.get_dimensions()
-window_x = Win.x_pos()
-window_y = Win.y_pos()
-window_width = Win.width()
-windov_height = Win.height()
-
-# Persist Dimensions for frontmost app for reset
-Dim = Dimensions(cache_file)
-Dim.add_dimension(app_id, actual_window_pos)
-
-# Get Screen width and height
-Scr = Screen()
-screen_width = Scr.screen_width()
-screen_height = Scr.screen_height()
-
-dock_position = get_dock_position()
-dock_size = get_dock_size()
-
-# Calculate new Window dimensions based on window move direction and Dock position
-window_x_new = 0
-window_y_new = 0
-if direction == "left": # calculate dimensions for moving right side of the screen
- window_width_new = int(screen_width/2)
- window_height_new = screen_height
- if dock_position == "left":
- window_x_new = dock_size
- window_width_new -= 2 * dock_size
-
-if direction == "right": # calculate dimensions for moving right side of the screen
- window_x_new = int(screen_width/2)
- window_width_new = int(screen_width/2)
- window_height_new = int(screen_height)
- if dock_position == "right":
- window_x_new = screen_width - dock_size
- window_width_new -= - 2 * dock_size
-
-vars = {"x": window_x_new,
- "y": window_y_new,
- "width": window_width_new,
- "height": window_height_new
- }
-aj = AlfJson()
-aj.add_variables(vars)
-aj.write_json()