A Python library to programatically get your monitor's resolution info.
It supports multiple strategies:
xrandr
: Linux only, requiresx11-xserver-utils
to be installed.appkit
: MacOS only, requirespyobjc
,AppKit
, andcairo
to be installed.mswindows
: Windows only, requires the Powershell to be installed.
from pymonitors import get_monitors
for monitor in get_monitors():
width: int = monitor.width
height: int = monitor.height
print(f"Monitor {monitor.name} has resolution {width}x{height}.")