1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-08-02 03:28:28 -04:00

brightness: avoid targeting inactive panels

fixes #1127
This commit is contained in:
bbedward
2026-07-04 20:28:13 -04:00
parent fefc0afa6f
commit 30ceda97a0
+13 -4
View File
@@ -228,7 +228,7 @@ Singleton {
if (deviceExists) { if (deviceExists) {
setCurrentDevice(lastDevice, false); setCurrentDevice(lastDevice, false);
} else { } else {
const backlight = devices.find(d => d.class === "backlight"); const backlight = internalPanelActive() ? devices.find(d => d.class === "backlight") : null;
const nonKbdDevice = devices.find(d => !d.id.includes("kbd")); const nonKbdDevice = devices.find(d => !d.id.includes("kbd"));
const defaultDevice = backlight || nonKbdDevice || devices[0]; const defaultDevice = backlight || nonKbdDevice || devices[0];
setCurrentDevice(defaultDevice.id, false); setCurrentDevice(defaultDevice.id, false);
@@ -363,12 +363,21 @@ Singleton {
return Math.round(normalizedPercent * 100.0); return Math.round(normalizedPercent * 100.0);
} }
function internalPanelActive() {
return Quickshell.screens.some(s => /^(eDP|LVDS|DSI)/i.test(s.name));
}
function getDefaultDevice() { function getDefaultDevice() {
for (const device of devices) { if (internalPanelActive()) {
if (device.class === "backlight") { for (const device of devices) {
return device.id; if (device.class === "backlight") {
return device.id;
}
} }
} }
const nonKbdDevice = devices.find(d => d.class !== "backlight" && !d.id.includes("kbd"));
if (nonKbdDevice)
return nonKbdDevice.id;
return devices.length > 0 ? devices[0].id : ""; return devices.length > 0 ? devices[0].id : "";
} }