Screeninfo

0.8.1 · active · verified Thu Apr 09

Screeninfo is a Python library designed to fetch the location and size of physical screens connected to a system. It supports various operating systems including MS Windows, MS Windows (Cygwin), GNU/Linux (via X11 with Xinerama and experimental DRM), and macOS (using AppKit). The current version is 0.8.1, released in September 2022, and while no explicit release cadence is stated, it remains actively maintained.

Warnings

Install

Imports

Quickstart

This quickstart code demonstrates how to retrieve information about all connected monitors and specifically the primary monitor using `screeninfo`.

from screeninfo import get_monitors, get_primary_monitor

print("Detected monitors:")
for m in get_monitors():
    print(f"  Monitor(x={m.x}, y={m.y}, width={m.width}, height={m.height}, is_primary={m.is_primary}, name={m.name})")

primary = get_primary_monitor()
if primary:
    print(f"\nPrimary monitor: Monitor(x={primary.x}, y={primary.y}, width={primary.width}, height={primary.height}, name={primary.name})")
else:
    print("\nNo primary monitor detected.")

view raw JSON →