From cf81956c8c21f004c1cd7754c68fd08d3718de71 Mon Sep 17 00:00:00 2001 From: neodarz Date: Tue, 10 Apr 2018 19:16:34 +0200 Subject: Rename cycle-workspace script to a better name --- scripts/.scripts/cycle-workspace-multiscreen.py | 74 +++++++++++++++++++++++++ scripts/.scripts/cycle-workspace_more_2.py | 74 ------------------------- 2 files changed, 74 insertions(+), 74 deletions(-) create mode 100755 scripts/.scripts/cycle-workspace-multiscreen.py delete mode 100755 scripts/.scripts/cycle-workspace_more_2.py (limited to 'scripts') diff --git a/scripts/.scripts/cycle-workspace-multiscreen.py b/scripts/.scripts/cycle-workspace-multiscreen.py new file mode 100755 index 0000000..e5e70ef --- /dev/null +++ b/scripts/.scripts/cycle-workspace-multiscreen.py @@ -0,0 +1,74 @@ +#!/usr/bin/env python + +# cycle-workspace-multiscreen +# Moves the currently active workspace to the left/right/top/bottom active +# display. +# Depends on i3-py (`pip install i3-py`) +# Because workspace name are fixed to a display, just rename workspace can +# change workspace to another display. +# So for the moment this script is tested and work if workspaces are fixed +# to a display. + +import i3 +import sys + +# figure out what is on, and what is currently on your screen. +workspace_origin = list(filter(lambda s: s['focused'], i3.get_workspaces()))[0] +outputs = list(filter(lambda s: s['active'], i3.get_outputs())) +output_origin = "" + +for output in outputs: + if output['current_workspace'] == workspace_origin['name']: + output_origin = output + +output_destination = workspace_origin + +if sys.argv[1] == "right": + 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']: + output_destination = output + +if sys.argv[1] == "left": + 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 = output_origin_x - output['rect']['width'] + if next_workspace_start == output['rect']['x']: + output_destination = output + +if sys.argv[1] == "bottom": + 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']: + output_destination = output + +if sys.argv[1] == "top": + 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=output_origin_y - output['rect']['height'] + if next_workspace_start == output['rect']['y']: + output_destination = output + +if (output_destination != workspace_origin): + # Move origin workspace to the correct screen + 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 a_fucking_workspace') + # Change focus to the workspace destination + 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 '+output_destination['current_workspace']+' to '+str(workspace_origin['name'])) + # Rename temporary workspace to workspace destination + i3.command('rename', 'workspace a_fucking_workspace to '+output_destination['current_workspace']) + # Change focus the workspace destination + i3.workspace(output_destination['current_workspace']) diff --git a/scripts/.scripts/cycle-workspace_more_2.py b/scripts/.scripts/cycle-workspace_more_2.py deleted file mode 100755 index e5e70ef..0000000 --- a/scripts/.scripts/cycle-workspace_more_2.py +++ /dev/null @@ -1,74 +0,0 @@ -#!/usr/bin/env python - -# cycle-workspace-multiscreen -# Moves the currently active workspace to the left/right/top/bottom active -# display. -# Depends on i3-py (`pip install i3-py`) -# Because workspace name are fixed to a display, just rename workspace can -# change workspace to another display. -# So for the moment this script is tested and work if workspaces are fixed -# to a display. - -import i3 -import sys - -# figure out what is on, and what is currently on your screen. -workspace_origin = list(filter(lambda s: s['focused'], i3.get_workspaces()))[0] -outputs = list(filter(lambda s: s['active'], i3.get_outputs())) -output_origin = "" - -for output in outputs: - if output['current_workspace'] == workspace_origin['name']: - output_origin = output - -output_destination = workspace_origin - -if sys.argv[1] == "right": - 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']: - output_destination = output - -if sys.argv[1] == "left": - 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 = output_origin_x - output['rect']['width'] - if next_workspace_start == output['rect']['x']: - output_destination = output - -if sys.argv[1] == "bottom": - 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']: - output_destination = output - -if sys.argv[1] == "top": - 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=output_origin_y - output['rect']['height'] - if next_workspace_start == output['rect']['y']: - output_destination = output - -if (output_destination != workspace_origin): - # Move origin workspace to the correct screen - 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 a_fucking_workspace') - # Change focus to the workspace destination - 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 '+output_destination['current_workspace']+' to '+str(workspace_origin['name'])) - # Rename temporary workspace to workspace destination - i3.command('rename', 'workspace a_fucking_workspace to '+output_destination['current_workspace']) - # Change focus the workspace destination - i3.workspace(output_destination['current_workspace']) -- cgit v1.2.1