From bf162f0433cef8674a9811ab354cc7c974f567d8 Mon Sep 17 00:00:00 2001 From: Lucas Oskorep Date: Mon, 29 Jun 2026 22:19:29 -0400 Subject: [PATCH] feat: cleanup + move to debug logs again after reading docs --- README.md | 2 +- src/ddcutil.ts | 3 +++ src/displays.ts | 6 ++++-- src/indicator.ts | 1 + stylesheet.css | 21 +-------------------- 5 files changed, 10 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 8c27fc0..d1c1d82 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ This project aims to be a simple and easy to use DDC brightness control plugin f ## Planned Features? -- Would be nice to get this added to the system status menu at some point isntead of its own dot +- Would be nice to get this added to the system status menu at some point instead of its own dot - Support for direct i2c or better ddc controllers (not ddcutil) - You tell me diff --git a/src/ddcutil.ts b/src/ddcutil.ts index 03a7f6d..660f523 100644 --- a/src/ddcutil.ts +++ b/src/ddcutil.ts @@ -11,6 +11,7 @@ export interface ParsedDisplay { // Run a command asynchronously, capturing stdout. The callback always fires: // with stdout on success, or an empty string on failure. export function runCommandAsync(args: string[], callback: (stdout: string) => void): void { + console.debug(`${LOG_PREFIX} Running: ${args.join(' ')}`); try { const subprocess = new Gio.Subprocess({ argv: args, @@ -21,6 +22,7 @@ export function runCommandAsync(args: string[], callback: (stdout: string) => vo subprocess.communicate_utf8_async(null, null, (proc: Gio.Subprocess | null, result: Gio.AsyncResult) => { try { const [, stdout] = (proc ?? subprocess).communicate_utf8_finish(result); + console.debug(`${LOG_PREFIX} Done: ${stdout.trim().substring(0, 80)}`); callback(stdout); } catch (e) { console.error(`${LOG_PREFIX} Command failed: ${e}`); @@ -29,6 +31,7 @@ export function runCommandAsync(args: string[], callback: (stdout: string) => vo }); } catch (e) { console.error(`${LOG_PREFIX} Failed to spawn: ${e}`); + callback(''); } } diff --git a/src/displays.ts b/src/displays.ts index 13b3570..1895c02 100644 --- a/src/displays.ts +++ b/src/displays.ts @@ -53,6 +53,7 @@ export class DisplayController { detect(): void { Ddcutil.detectDisplays((parsed) => { + if (this._disposed) return; this._displays = parsed.map((p) => ({ bus: p.bus, name: p.name, @@ -67,7 +68,7 @@ export class DisplayController { updatingFromCode: false, })); this._detectComplete = true; - console.log(`${LOG_PREFIX} Found ${this._displays.length} displays`); + console.debug(`${LOG_PREFIX} Found ${this._displays.length} displays`); this._mapMonitorsToDisplays(); this.onDetectComplete?.(); @@ -87,7 +88,7 @@ export class DisplayController { const idx = monitorManager.get_monitor_for_connector(display.connector); if (idx >= 0) { display.monitorIndex = idx; - console.log(`${LOG_PREFIX} Mapped ${display.name} connector=${display.connector} -> monitor ${idx}`); + console.debug(`${LOG_PREFIX} Mapped ${display.name} connector=${display.connector} -> monitor ${idx}`); } } } @@ -196,6 +197,7 @@ export class DisplayController { Ddcutil.readBrightness(display.bus, this._vcpCode, (value) => { display.reading = false; + if (this._disposed) return; if (value !== null) { display.sentValue = value; this._setTarget(display, value); diff --git a/src/indicator.ts b/src/indicator.ts index b814ce5..183c98b 100644 --- a/src/indicator.ts +++ b/src/indicator.ts @@ -100,6 +100,7 @@ export class BrightnessIndicator { menu.addMenuItem(labelRow); const sliderRow = new PopupMenu.PopupBaseMenuItem({activate: false}); + sliderRow.add_style_class_name('ddc-brightness-slider'); const slider = new Slider.Slider(display.currentValue / 100); diff --git a/stylesheet.css b/stylesheet.css index ddb3922..542bc80 100644 --- a/stylesheet.css +++ b/stylesheet.css @@ -1,23 +1,4 @@ -.ddc-brightness-slider-box { - padding: 8px 12px; -} - -.ddc-brightness-value-label { - font-size: 12px; - font-weight: bold; - color: #ffffff; - min-width: 40px; - text-align: right; -} - -.slider { +.ddc-brightness-slider .slider { height: 24px; border-radius: 12px; - background-color: rgba(255, 255, 255, 0.2); -} - -.slider .fill-level { - height: 24px; - border-radius: 12px; - background-color: white; }