Files
oaip-project-app/callbacks/screen.py
2025-05-21 07:55:46 +03:00

29 lines
828 B
Python

import monitorcontrol
def get_monitors():
"""Retrieve a list of connected monitors."""
return monitorcontrol.get_monitors()
def set_brightness(monitor, brightness):
"""Set the brightness of a specific monitor."""
if not 0 <= brightness <= 100:
raise ValueError("Brightness must be between 0 and 100")
with monitor:
monitor.set_luminance(brightness)
print(f"Set brightness to {brightness}%")
def chenge_brightness(args):
try:
level = args.get('level', 10)
monitors = get_monitors()
if not monitors:
raise OSError(f"No DDC/CI compatible monitors found.")
return
for i, monitor in enumerate(monitors):
set_brightness(monitor, level)
except Exception as e:
raise OSError(f"An error occurred: {e}")