36 lines
969 B
Python
36 lines
969 B
Python
#!/usr/bin/python
|
|
|
|
import json
|
|
import subprocess
|
|
|
|
CONFIG = {
|
|
'Samsung Electric Company LS27A800U HCJW301093': 1,
|
|
'Seanix Technology Inc NX-EDG27X C6F0K3CN07UL': 2,
|
|
'BOE 0x0BCA': 3
|
|
}
|
|
|
|
|
|
p = subprocess.run(
|
|
['hyprctl', 'monitors', '-j'],
|
|
capture_output=True,
|
|
check=True,
|
|
encoding='utf-8'
|
|
)
|
|
monitors = json.loads(p.stdout)
|
|
print('monitors:', monitors)
|
|
|
|
if set(m['description'] for m in monitors) == CONFIG.keys():
|
|
print('config matched, assigning:')
|
|
dispatches = []
|
|
for m in monitors:
|
|
workspace = CONFIG[m['description']]
|
|
# move workspace to desired monitor
|
|
dispatches.append(f"dispatch moveworkspacetomonitor {workspace} {m['name']}")
|
|
# focus the workspace so that it's visible after moving
|
|
dispatches.append(f"workspace {workspace}")
|
|
cmd = ['hyprctl', '--batch', ' ; '.join(dispatches)]
|
|
print('\n'.join(cmd))
|
|
subprocess.run(cmd, check=True)
|
|
else:
|
|
print('config not matched')
|