aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorneodarz <neodarz@neodarz.net>2018-04-10 10:13:02 +0200
committerneodarz <neodarz@neodarz.net>2018-04-10 10:16:34 +0200
commit6f302a317ab66d31bf970681ea1e43199038a629 (patch)
tree75423696db79a76ce52078fa0c70622c5f324b3d
parent05d4e07a811686aaf36158a8848b2436b4a63a60 (diff)
downloaddotfiles_ascii-6f302a317ab66d31bf970681ea1e43199038a629.tar.xz
dotfiles_ascii-6f302a317ab66d31bf970681ea1e43199038a629.zip
Clean code for script cycle workspace
-rwxr-xr-xscripts/.scripts/cycle-workspace_more_2.py53
1 files changed, 26 insertions, 27 deletions
diff --git a/scripts/.scripts/cycle-workspace_more_2.py b/scripts/.scripts/cycle-workspace_more_2.py
index e49b6df..0977b5f 100755
--- a/scripts/.scripts/cycle-workspace_more_2.py
+++ b/scripts/.scripts/cycle-workspace_more_2.py
@@ -12,7 +12,6 @@ workspace_origin = list(filter(lambda s: s['focused'], i3.get_workspaces()))[0]
outputs = list(filter(lambda s: s['active'], i3.get_outputs()))
output_origin = ""
-print(workspace_origin)
for output in outputs:
if output['current_workspace'] == workspace_origin['name']:
output_origin = output
@@ -26,57 +25,57 @@ def rename(origin, destination):
workspace_destination="30"
return workspace_destination
-workspace_destination = workspace_origin
+output_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
+ output_origin_x = output_origin['rect']['x']
+ output_origin_width = output_origin['rect']['width']
+ next_workspace_start = output_origin_x + output_origin_width
for output in outputs:
if next_workspace_start == output['rect']['x']:
- workspace_destination = output
+ output_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
+ output_origin_x = output_origin['rect']['x']
+ output_origin_width = output_origin['rect']['width']
+ next_workspace_start = output_origin_x - output_origin_width
for output in outputs:
- next_workspace_start = workspace_origin_x - output['rect']['width']
+ next_workspace_start = output_origin_x - output['rect']['width']
if next_workspace_start == output['rect']['x']:
- workspace_destination = output
+ output_destination = output
if sys.argv[1] == "bottom":
- workspace_origin_y = output_origin['rect']['y']
- workspace_origin_height = output_origin['rect']['height']
- next_workspace_start = workspace_origin_y + workspace_origin_height
+ output_origin_y = output_origin['rect']['y']
+ output_origin_height = output_origin['rect']['height']
+ next_workspace_start = output_origin_y + output_origin_height
for output in outputs:
if next_workspace_start == output['rect']['y']:
- workspace_destination = output
+ output_destination = output
if sys.argv[1] == "top":
- workspace_origin_y = output_origin['rect']['y']
- workspace_origin_height = output_origin['rect']['height']
- next_workspace_start = workspace_origin_y - workspace_origin_height
+ output_origin_y = output_origin['rect']['y']
+ output_origin_height = output_origin['rect']['height']
+ next_workspace_start = output_origin_y - output_origin_height
for output in outputs:
- next_workspace_start=workspace_origin_y - output['rect']['height']
+ next_workspace_start=output_origin_y - output['rect']['height']
if next_workspace_start == output['rect']['y']:
- workspace_destination = output
+ output_destination = output
-if (workspace_destination != workspace_origin):
+if (output_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']))
+ workspace_number_destination = rename(workspace_origin['name'], int(output_destination['current_workspace']))
# Move origin workspace to the correct screen
- i3.command('move', 'workspace to output '+workspace_destination['name'])
+ i3.command('move', 'workspace to output '+output_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'])
+ i3.workspace(output_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']))
+ i3.command('rename', 'workspace '+output_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'])
+ i3.command('rename', 'workspace '+workspace_number_destination+' to '+output_destination['current_workspace'])
# Change focus the workspace destination
- i3.workspace(workspace_destination['current_workspace'])
+ i3.workspace(output_destination['current_workspace'])