-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathi3-assign-workspaces
More file actions
executable file
·35 lines (25 loc) · 907 Bytes
/
i3-assign-workspaces
File metadata and controls
executable file
·35 lines (25 loc) · 907 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env python3
from functools import partial
import i3ipc
def move(ouput1, output2, conn):
focused = conn.get_tree().find_focused().id
conn.command('[workspace=1] move workspace to output %s' % ouput1)
conn.command('[workspace=2] move workspace to output %s' % output2)
conn.command('[workspace=3] move workspace to output %s' % output2)
conn.command('[con_id=%s] focus' % focused)
ASSIGNMENTS = {
'HDMI-1 VGA-1': partial(move, 'HDMI-1', 'VGA-1'),
'HDMI-1 LVDS-1': partial(move, 'HDMI-1', 'LVDS-1'),
}
def configure(conn, event=None):
outputs = conn.get_outputs()
active = ' '.join(sorted([o['name'] for o in outputs if o['active']]))
try:
ASSIGNMENTS[active](conn)
except KeyError:
return
if __name__ == '__main__':
conn = i3ipc.Connection()
configure(conn)
conn.on('output::unspecified', configure)
conn.main()