diff --git a/dot_local/bin/executable_assign-workspace-monitors b/dot_local/bin/executable_assign-workspace-monitors index 005dff0..3ae8746 100644 --- a/dot_local/bin/executable_assign-workspace-monitors +++ b/dot_local/bin/executable_assign-workspace-monitors @@ -3,11 +3,11 @@ import json import subprocess -CONFIG = { - 'Samsung Electric Company LS27A800U HCJW301093': 1, - 'Seanix Technology Inc NX-EDG27X C6F0K3CN07UL': 2, - 'BOE 0x0BCA': 3 -} +CONFIG = [ + {'make': 'Samsung Electric Company', 'model': 'LS27A800U', 'position': 'left', 'workspace': 1}, + {'make': 'Seanix Technology Inc', 'model': 'NX-EDG27X', 'position': 'center', 'workspace': 2}, + {'make': 'BOE', 'model': '0x0BCA', 'position': 'right', 'workspace': 3}, +] p = subprocess.run( @@ -17,15 +17,23 @@ p = subprocess.run( encoding='utf-8' ) monitors = json.loads(p.stdout) -print('monitors:', monitors) +# print('monitors:', monitors) -if set(m['description'] for m in monitors) == CONFIG.keys(): +monitor_ids = {} +for mon in monitors: + for conf in CONFIG: + if conf['make'] == mon['make'] and conf['model'] == mon['model']: + monitor_ids[ conf['position'] ] = mon['id'] + + +if len(monitor_ids) == len(CONFIG): print('config matched, assigning:') dispatches = [] - for m in monitors: - workspace = CONFIG[m['description']] + for conf in CONFIG: + workspace = conf['workspace'] + monitor_id = monitor_ids[ conf['position'] ] # move workspace to desired monitor - dispatches.append(f"dispatch moveworkspacetomonitor {workspace} {m['name']}") + dispatches.append(f"dispatch moveworkspacetomonitor {workspace} {monitor_id}") # focus the workspace so that it's visible after moving dispatches.append(f"workspace {workspace}") cmd = ['hyprctl', '--batch', ' ; '.join(dispatches)]