aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/.scripts/cycle-workspace.py26
-rw-r--r--scripts/.scripts/cycle-workspace_more_2.py27
2 files changed, 53 insertions, 0 deletions
diff --git a/scripts/.scripts/cycle-workspace.py b/scripts/.scripts/cycle-workspace.py
new file mode 100755
index 0000000..7f176db
--- /dev/null
+++ b/scripts/.scripts/cycle-workspace.py
@@ -0,0 +1,26 @@
+#!/usr/bin/env python
+#https://gist.github.com/97-109-107/b70356670ae8309ffb4f
+
+import i3
+
+outputs = i3.get_outputs()
+workspaces = i3.get_workspaces()
+
+# figure out what is on, and what is currently on your screen.
+workspace = list(filter(lambda s: s['focused']==True, workspaces))
+output = list(filter(lambda s: s['active']==True, outputs))
+
+# figure out the other workspace name
+other_workspace = list(filter(lambda s: s['name']!=workspace[0]['output'], output))
+
+
+
+# send current to the no-active one
+i3.command('move', 'workspace to output '+other_workspace[0]['name'])
+
+
+
+#print(str(list(filter(lambda s: s['active']==True, workspaces))))
+
+i3.command('workspace', other_workspace[0]['current_workspace'])
+i3.command('move', 'workspace to output '+workspace[0]['output'])
diff --git a/scripts/.scripts/cycle-workspace_more_2.py b/scripts/.scripts/cycle-workspace_more_2.py
new file mode 100644
index 0000000..81ea163
--- /dev/null
+++ b/scripts/.scripts/cycle-workspace_more_2.py
@@ -0,0 +1,27 @@
+#!/usr/bin/env python
+
+# cycle-workspace
+# Moves the currently active workspace to the next active display
+# Depends on i3-py (`pip install i3-py`)
+
+import i3
+
+# figure out what is on, and what is currently on your screen.
+focused_workspace = 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]
+
+# send current to the no-active one
+i3.command('move', 'workspace to output '+other_workspace['name'])