adjust-screens 967 B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/usr/bin/python2
  2. import subprocess
  3. import sys
  4. def invoke(args):
  5. sys.stderr.write('invoke("{0}")\n'.format(' '.join(args)))
  6. p = subprocess.Popen(args, stdout=subprocess.PIPE)
  7. return p.stdout.readlines()
  8. disps = set()
  9. for x in invoke(['xrandr']):
  10. if x and not x[0].isspace():
  11. cdisp = x.split()[0]
  12. else:
  13. disps.add(cdisp)
  14. if disps:
  15. sys.stderr.write("connected displays: {0}\n".format(', '.join(disps)))
  16. if len(disps) <= 0:
  17. sys.stderr.write("no displays connected.\n")
  18. sys.exit(1)
  19. elif len(disps) == 1:
  20. args = ['xrandr', '--auto']
  21. invoke(args)
  22. elif len(disps) == 2:
  23. other = (disps ^ set(['LVDS1'])).pop()
  24. invoke(['xrandr', '--output', 'LVDS1', '--primary', '--left-of',
  25. other, '--output', other, '--auto'])
  26. else:
  27. sys.stderr.write("more than two connected displays;\n")
  28. sys.stderr.write("unsure how to continue\n")
  29. sys.exit(1)
  30. invoke(['/home/gdritter/Pictures/ghibli/rand.sh'])