aboutsummaryrefslogtreecommitdiff
path: root/scripts/.scripts
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-x[-rw-r--r--]scripts/.scripts/cycle-workspace_more_2.py61
1 files changed, 46 insertions, 15 deletions
diff --git a/scripts/.scripts/cycle-workspace_more_2.py b/scripts/.scripts/cycle-workspace_more_2.py
index 81ea163..a8a46d1 100644..100755
--- a/scripts/.scripts/cycle-workspace_more_2.py
+++ b/scripts/.scripts/cycle-workspace_more_2.py
@@ -5,23 +5,54 @@
# Depends on i3-py (`pip install i3-py`)
import i3
+import sys
# figure out what is on, and what is currently on your screen.
-focused_workspace = list(filter(lambda s: s['focused'], i3.get_workspaces()))[0]
+workspace_origin = list(filter(lambda s: s['focused'], i3.get_workspaces()))[0]
outputs = list(filter(lambda s: s['active'], i3.get_outputs()))
-# find the index of the currently focused workspace
-currentIndex = 0
-for i, output in enumerate(outputs):
- if output['name'] == focused_workspace['output']:
- currentIndex = i
- break
-
-# find the next workspace
-nextIndex = currentIndex + 1
-if nextIndex >= len(outputs):
- nextIndex = 0
-other_workspace = outputs[nextIndex]
+def rename(origin, destination):
+ if destination >= 1 and destination <= 10:
+ workspace_destination="10"
+ elif destination >= 11 and destination <= 20:
+ workspace_destination="20"
+ elif destination >= 21 and destination <= 30:
+ workspace_destination="30"
+ return workspace_destination
-# send current to the no-active one
-i3.command('move', 'workspace to output '+other_workspace['name'])
+workspace_destination = workspace_origin
+
+if sys.argv[1] == "right":
+ workspace_origin_x = workspace_origin['rect']['x']
+ workspace_origin_width = workspace_origin['rect']['width']
+ next_workspace_start = workspace_origin_x + workspace_origin_width
+ for output in outputs:
+ if output['rect']['x'] == next_workspace_start:
+ workspace_destination = output
+
+if sys.argv[1] == "left":
+ workspace_origin_x = workspace_origin['rect']['x']
+ workspace_origin_width = workspace_origin['rect']['width']
+ next_workspace_start = workspace_origin_x - workspace_origin_width
+ for output in outputs:
+ if output['rect']['x'] == next_workspace_start:
+ workspace_destination = output
+
+if (workspace_destination != workspace_origin):
+ # Because workspace name are fixed to screen, just rename workspace can change workspace to another screen.
+ # Get temprory workspace of the screen destination (10, 20 or 30)
+ workspace_number_destination = rename(workspace_origin['name'], int(workspace_destination['current_workspace']))
+ # Move origin workspace to the correct screen
+ i3.command('move', 'workspace to output '+workspace_destination['name'])
+ # Rename origin workspace to temporary workspace of the screen destination
+ i3.command('rename', 'workspace '+str(workspace_origin['name'])+' to '+workspace_number_destination)
+ # Change focus to the workspace destination
+ i3.workspace(workspace_destination['current_workspace'])
+ # Move destination workspace to the correct screen
+ i3.command('move', 'workspace to output '+workspace_origin['output'])
+ # Rename workspace destination to the origin workspace
+ i3.command('rename', 'workspace '+workspace_destination['current_workspace']+' to '+str(workspace_origin['name']))
+ # Rename temporary workspace to workspace destination
+ i3.command('rename', 'workspace '+workspace_number_destination+' to '+workspace_destination['current_workspace'])
+ # Change focus the workspace destination
+ i3.workspace(workspace_destination['current_workspace'])