1 | 1 |
new file mode 100755 |
... | ... |
@@ -0,0 +1,21 @@ |
1 |
+#!/usr/bin/env python3 |
|
2 |
+ |
|
3 |
+import sys |
|
4 |
+import subprocess |
|
5 |
+import json |
|
6 |
+ |
|
7 |
+I3_GET = ['i3-msg', '-t', 'get_workspaces'] |
|
8 |
+I3_RENAME = ['i3-msg', 'rename', 'workspace', 'to'] |
|
9 |
+ |
|
10 |
+def get(): |
|
11 |
+ for workspace in json.loads(subprocess.check_output(I3_GET)): |
|
12 |
+ if workspace['focused']: |
|
13 |
+ return workspace['name'] |
|
14 |
+ |
|
15 |
+def filter(value): |
|
16 |
+ return subprocess.check_output([*sys.argv[1:], value]) |
|
17 |
+ |
|
18 |
+def rename(value): |
|
19 |
+ subprocess.call([*I3_RENAME, value]) |
|
20 |
+ |
|
21 |
+rename(filter(get())) |