first commit

This commit is contained in:
MoonDev
2025-05-21 07:55:46 +03:00
commit 96ea504b10
28 changed files with 919 additions and 0 deletions

28
callbacks/screen.py Normal file
View File

@@ -0,0 +1,28 @@
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}")