From 03bc2fb12beff444d097c6f1b365378903fb785e Mon Sep 17 00:00:00 2001 From: Moeta Yuko Date: Sun, 23 Feb 2025 17:27:49 +0800 Subject: [PATCH] ags: fix parsing `ddcutil detect --brief` Recent update introduced a new `drm_connector_id` line, so it's no longer feasible to hardcode the line numbers. --- .config/ags/services/brightness.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/.config/ags/services/brightness.js b/.config/ags/services/brightness.js index b76ef755d..4f0e59761 100644 --- a/.config/ags/services/brightness.js +++ b/.config/ags/services/brightness.js @@ -97,9 +97,17 @@ async function listDdcMonitorsSnBus() { if (!reg.test(display)) return; const lines = display.split('\n'); - const sn = lines[3].split(':')[3]; - const busNum = lines[1].split('/dev/i2c-')[1]; - ddcSnBus[sn] = busNum; + let sn, busNum; + for (let line of lines) { + line = line.trim() + if (line.startsWith('Monitor:')) { + sn = line.split(':')[3]; + } else if (line.startsWith('I2C bus:')) { + busNum = line.split('/dev/i2c-')[1]; + } + } + if (sn && busNum) + ddcSnBus[sn] = busNum; }); } catch (err) { print(err);