X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=blobdiff_plain;f=configure_displays;h=5d122a11dcedb28066c5e9ecdc4a7c9ddc6c26dd;hb=b819ae3d803bc45f2084513d356b9e6369c582fe;hp=40a3ff27134cb73ddea50ce3cddf053ee5a5d5c9;hpb=292b64c293429ff7f53142244f04a62b03784af2;p=dispcfg.git diff --git a/configure_displays b/configure_displays index 40a3ff2..5d122a1 100755 --- a/configure_displays +++ b/configure_displays @@ -1,10 +1,9 @@ #!/usr/bin/python """ -Parse xrandr current information +Configure displays by looking at xrandr information -TODO: -* Cannot seem to undock notebook then recover displays without causing a logout - event. Could it be that i3 is finding there are no displays? +Select the best 1 or 2 xrandr outputs to use as displays, based on xrandr +information, then reconfigure outputs via xrandr. """ import sys @@ -108,6 +107,39 @@ def output_by_name(outputs, name): return None +def print_outputs(header, outputs): + print '%s:' % header + for output in outputs: + print_output(output) + print + + +def all_done(outputs): + for output in outputs: + if not output['done']: + return False + return True + + +def disable_an_entry(outputs): + for output in outputs: + if not output['done'] and not output['use'] and output['enabled']: + xrandr_off(output) + output['done'] = True + return 1 + return 0 + + +def enable_an_entry(outputs): + enables = 0 + for output in reversed(outputs): + if not output['done'] and output['use']: + xrandr_on(output) + output['done'] = True + return 1 + return 0 + + if __name__ == '__main__': def print_output(output): print 'name:%s connected:%r enabled:%r width:%d height:%d pos:%dx%d' % ( @@ -115,35 +147,6 @@ if __name__ == '__main__': output['width'], output['height'], output['posx'], output['posy']) - def print_outputs(header, outputs): - print '%s:' % header - for output in outputs: - print_output(output) - print - - def all_done(outputs): - for output in outputs: - if not output['done']: - return False - return True - - def disable_an_entry(outputs): - for output in outputs: - if not output['done'] and not output['use'] and output['enabled']: - xrandr_off(output) - output['done'] = True - return 1 - return 0 - - def enable_an_entry(outputs): - enables = 0 - for output in reversed(outputs): - if not output['done'] and output['use']: - xrandr_on(output) - output['done'] = True - return 1 - return 0 - def main(argv): global dry_run if len(argv) >= 2 and argv[1] == '--dry-run':