Skip to content

Instantly share code, notes, and snippets.

@antoinebou12
Created June 24, 2018 18:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antoinebou12/7a212ccd84cc95e040b2dd0e14662445 to your computer and use it in GitHub Desktop.
Save antoinebou12/7a212ccd84cc95e040b2dd0e14662445 to your computer and use it in GitHub Desktop.
Xlib python example that display all the screen and resolution
import os
from Xlib import 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))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment