aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--i3/.config/i3/config2
-rwxr-xr-x[-rw-r--r--]scripts/.scripts/cycle-workspace_more_2.py61
2 files changed, 48 insertions, 15 deletions
diff --git a/i3/.config/i3/config b/i3/.config/i3/config
index 30296aa..63a1dd0 100644
--- a/i3/.config/i3/config
+++ b/i3/.config/i3/config
@@ -117,6 +117,8 @@ bindsym $WinKey+p exec rofi-pass
#bindsym $WinKey+Shift+$AltKey+0 exec ~/.config/i3/switch-workspace.py 6
bindsym XF86AudioPlay exec ~/.config/i3/switch_audio.sh 8
bindsym $WinKey+g exec ~/.scripts/cycle-workspace.py
+bindsym Control+$AltKey+Right exec ~/.scripts/cycle-workspace_more_2.py right
+bindsym Control+$AltKey+Left exec ~/.scripts/cycle-workspace_more_2.py left
# start a terminal
#bindsym $WinKey+Return exec urxvt --termName 'rxvt-unicode' -fn 'xft:Fira Code:size=8' --background 'black' --color0 'black' --color8 'black' --color1 'red' --color9 'red' --color2 'green' --color10 'green' --color3 'yellow' --color11 'yellow' --color4 'blue' --color12 'blue' --color6 'cyan' --color14 'cyan' --color7 'white' --color15 'white' -cursorColor '#ffffff'
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'])