PyMonCtl

raw JSON →
0.92 verified Fri May 01 auth: no python

Cross-Platform toolkit to get info on and control monitors connected to the system. Version 0.92 supports Windows, macOS, and Linux (X11; partial Wayland). Release cadence is irregular.

pip install pymonctl
error ModuleNotFoundError: No module named 'pymonctl'
cause Library not installed.
fix
Run 'pip install pymonctl'.
error AttributeError: module 'pymonctl' has no attribute 'Monitor'
cause Importing from submodule instead of package.
fix
Use 'from pymonctl import Monitor'.
gotcha On Linux, the library may crash in Wayland due to missing support. It may also freeze if invoked with a fake ':1' display.
fix Use only on X11 sessions. Disable Wayland or run under XWayland.
gotcha The watchdog feature can freeze randomly on Linux due to screen_resources and get_output_info calls.
fix Avoid using the watchdog on Linux or disable it (default is off). Upgrade to 0.92 may improve but not eliminate issue.
breaking In version 0.6, findMonitors() and findMonitorsInfo() were renamed to findMonitorsAtPoint() and findMonitorsAtPointInfo().
fix Use new function names. Check deprecation warnings.
deprecated Direct imports from submodules like 'pymonctl.monitor' are internal and may break.
fix Always import from 'pymonctl' package level.

List all monitors and identify the primary monitor.

import pymonctl

monitors = pymonctl.getAllMonitors()
for m in monitors:
    print(m.name, m.width, m.height)

# Get primary monitor
primary = pymonctl.getPrimaryMonitor()
print(f"Primary: {primary.name}")