It seems like an simple problem, but I can\'t find the answer: How do you query (via X11) what monitors exist and their resolutions?
Python
import os
from Xlib import X, display
d = display.Display()
s = d.screen().root
output = os.popen("xrandr --listmonitors | grep '*' | awk {'print $4'}").read().splitlines()
num_sc = s.xinerama_get_screen_count().screen_count
width = s.get_geometry().width
height = s.get_geometry().height
print("Total count screens: %s" % num_sc)
for i in range(num_sc):
print("\tScreen %s(%s): %sX%s" % (i, output[i], width, height))
Bash
$ xrandr --listmonitors
$ xrandr
$ xrandr | grep '*' | awk {'print $1'}