mirror of
https://github.com/kuhyx/wake-alarm.git
synced 2026-11-10 19:27:02 +01:00
`requires-python` and the CI pin already said 3.14, but ruff, mypy and pylint were still grading against 3.10/3.11 -- three tools judging an interpreter nothing runs any more, and ruff withholding the pyupgrade fixes that only become safe at the newer target. `pin_ci_python.py` rewrites these three knobs. What the stale target was hiding: `datetime.timezone.utc` where `datetime.UTC` is now correct (UP017), `socket.timeout` where `TimeoutError` is (UP041), and ruff's stable formatter applying PEP 758 -- `except (A, B):` becomes `except A, B:`. That makes the source 3.14-only at the syntax level, which is what `requires-python = ">=3.14"` already promised; kuhy chose it deliberately over holding ruff a release back (2026-08-29). ruff, ruff-format, mypy --strict and pylint all clean at the new target. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SfnJmxxsZ534AKk16rC2Gr
49 lines
1.5 KiB
Python
49 lines
1.5 KiB
Python
"""Raise every monitor to full brightness when the alarm fires.
|
|
|
|
Split out of ``_audio.py`` for the 250-line cap; it is display control, not
|
|
audio, and only ever lived there for historical reasons.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import logging
|
|
import shutil
|
|
import subprocess
|
|
|
|
_logger = logging.getLogger(__name__)
|
|
|
|
|
|
def _set_max_brightness() -> None:
|
|
"""Set all connected monitors to maximum brightness via xrandr."""
|
|
xrandr = shutil.which("xrandr")
|
|
if xrandr is None:
|
|
_logger.warning("xrandr not on PATH; skipping max-brightness")
|
|
return
|
|
try:
|
|
result = subprocess.run(
|
|
[xrandr, "--query"],
|
|
capture_output=True,
|
|
text=True,
|
|
timeout=5,
|
|
check=False,
|
|
)
|
|
except OSError, subprocess.TimeoutExpired:
|
|
_logger.warning("xrandr --query failed; skipping max-brightness", exc_info=True)
|
|
return
|
|
for line in result.stdout.splitlines():
|
|
if " connected" in line:
|
|
output = line.split()[0]
|
|
try:
|
|
subprocess.run(
|
|
[xrandr, "--output", output, "--brightness", "1.0"],
|
|
check=False,
|
|
capture_output=True,
|
|
timeout=5,
|
|
)
|
|
except OSError, subprocess.TimeoutExpired:
|
|
_logger.warning(
|
|
"Failed to set brightness on %s",
|
|
output,
|
|
exc_info=True,
|
|
)
|