brightness: avoid calling ddcutil without a busNum

This commit is contained in:
Lemmy
2026-02-03 10:05:48 -05:00
parent c74c1b5f2b
commit 6fd14150c1
+14 -9
View File
@@ -227,7 +227,7 @@ Singleton {
// For internal displays, query the system directly
refreshProc.command = ["sh", "-c", "cat " + monitor.brightnessPath + " && " + "cat " + monitor.maxBrightnessPath];
refreshProc.running = true;
} else if (monitor.isDdc) {
} else if (monitor.isDdc && monitor.busNum !== "") {
// For DDC displays, get the current value
refreshProc.command = ["ddcutil", "-b", monitor.busNum, "--sleep-multiplier=0.05", "getvcp", "10", "--brief"];
refreshProc.running = true;
@@ -362,17 +362,20 @@ Singleton {
}
// Execute the brightness change command
monitor.commandRunning = true;
monitor.ignoreNextChange = true;
if (isAppleDisplay) {
monitor.commandRunning = true;
monitor.ignoreNextChange = true;
setBrightnessProc.command = ["asdbctl", "set", rounded];
setBrightnessProc.running = true;
} else if (isDdc) {
} else if (isDdc && busNum !== "") {
monitor.commandRunning = true;
monitor.ignoreNextChange = true;
var ddcValue = Math.round(value * monitor.maxBrightness);
setBrightnessProc.command = ["ddcutil", "-b", busNum, "--noverify", "--async", "--sleep-multiplier=0.05", "setvcp", "10", ddcValue];
setBrightnessProc.running = true;
} else {
} else if (!isDdc) {
monitor.commandRunning = true;
monitor.ignoreNextChange = true;
setBrightnessProc.command = ["brightnessctl", "s", rounded + "%"];
setBrightnessProc.running = true;
}
@@ -381,14 +384,16 @@ Singleton {
function initBrightness(): void {
if (isAppleDisplay) {
initProc.command = ["asdbctl", "get"];
} else if (isDdc) {
initProc.running = true;
} else if (isDdc && busNum !== "") {
initProc.command = ["ddcutil", "-b", busNum, "--sleep-multiplier=0.05", "getvcp", "10", "--brief"];
} else {
initProc.running = true;
} else if (!isDdc) {
// Internal backlight - find the first available backlight device and get its info
// This now returns: device_path, current_brightness, max_brightness (on separate lines)
initProc.command = ["sh", "-c", "for dev in /sys/class/backlight/*; do " + " if [ -f \"$dev/brightness\" ] && [ -f \"$dev/max_brightness\" ]; then " + " echo \"$dev\"; " + " cat \"$dev/brightness\"; " + " cat \"$dev/max_brightness\"; " + " break; " + " fi; " + "done"];
initProc.running = true;
}
initProc.running = true;
}
onBusNumChanged: initBrightness()