feat: cleanup + move to debug logs again after reading docs
This commit is contained in:
@@ -14,7 +14,7 @@ This project aims to be a simple and easy to use DDC brightness control plugin f
|
|||||||
|
|
||||||
## Planned Features?
|
## 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)
|
- Support for direct i2c or better ddc controllers (not ddcutil)
|
||||||
- You tell me
|
- You tell me
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ export interface ParsedDisplay {
|
|||||||
// Run a command asynchronously, capturing stdout. The callback always fires:
|
// Run a command asynchronously, capturing stdout. The callback always fires:
|
||||||
// with stdout on success, or an empty string on failure.
|
// with stdout on success, or an empty string on failure.
|
||||||
export function runCommandAsync(args: string[], callback: (stdout: string) => void): void {
|
export function runCommandAsync(args: string[], callback: (stdout: string) => void): void {
|
||||||
|
console.debug(`${LOG_PREFIX} Running: ${args.join(' ')}`);
|
||||||
try {
|
try {
|
||||||
const subprocess = new Gio.Subprocess({
|
const subprocess = new Gio.Subprocess({
|
||||||
argv: args,
|
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) => {
|
subprocess.communicate_utf8_async(null, null, (proc: Gio.Subprocess | null, result: Gio.AsyncResult) => {
|
||||||
try {
|
try {
|
||||||
const [, stdout] = (proc ?? subprocess).communicate_utf8_finish(result);
|
const [, stdout] = (proc ?? subprocess).communicate_utf8_finish(result);
|
||||||
|
console.debug(`${LOG_PREFIX} Done: ${stdout.trim().substring(0, 80)}`);
|
||||||
callback(stdout);
|
callback(stdout);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(`${LOG_PREFIX} Command failed: ${e}`);
|
console.error(`${LOG_PREFIX} Command failed: ${e}`);
|
||||||
@@ -29,6 +31,7 @@ export function runCommandAsync(args: string[], callback: (stdout: string) => vo
|
|||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(`${LOG_PREFIX} Failed to spawn: ${e}`);
|
console.error(`${LOG_PREFIX} Failed to spawn: ${e}`);
|
||||||
|
callback('');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-2
@@ -53,6 +53,7 @@ export class DisplayController {
|
|||||||
|
|
||||||
detect(): void {
|
detect(): void {
|
||||||
Ddcutil.detectDisplays((parsed) => {
|
Ddcutil.detectDisplays((parsed) => {
|
||||||
|
if (this._disposed) return;
|
||||||
this._displays = parsed.map((p) => ({
|
this._displays = parsed.map((p) => ({
|
||||||
bus: p.bus,
|
bus: p.bus,
|
||||||
name: p.name,
|
name: p.name,
|
||||||
@@ -67,7 +68,7 @@ export class DisplayController {
|
|||||||
updatingFromCode: false,
|
updatingFromCode: false,
|
||||||
}));
|
}));
|
||||||
this._detectComplete = true;
|
this._detectComplete = true;
|
||||||
console.log(`${LOG_PREFIX} Found ${this._displays.length} displays`);
|
console.debug(`${LOG_PREFIX} Found ${this._displays.length} displays`);
|
||||||
|
|
||||||
this._mapMonitorsToDisplays();
|
this._mapMonitorsToDisplays();
|
||||||
this.onDetectComplete?.();
|
this.onDetectComplete?.();
|
||||||
@@ -87,7 +88,7 @@ export class DisplayController {
|
|||||||
const idx = monitorManager.get_monitor_for_connector(display.connector);
|
const idx = monitorManager.get_monitor_for_connector(display.connector);
|
||||||
if (idx >= 0) {
|
if (idx >= 0) {
|
||||||
display.monitorIndex = idx;
|
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) => {
|
Ddcutil.readBrightness(display.bus, this._vcpCode, (value) => {
|
||||||
display.reading = false;
|
display.reading = false;
|
||||||
|
if (this._disposed) return;
|
||||||
if (value !== null) {
|
if (value !== null) {
|
||||||
display.sentValue = value;
|
display.sentValue = value;
|
||||||
this._setTarget(display, value);
|
this._setTarget(display, value);
|
||||||
|
|||||||
@@ -100,6 +100,7 @@ export class BrightnessIndicator {
|
|||||||
menu.addMenuItem(labelRow);
|
menu.addMenuItem(labelRow);
|
||||||
|
|
||||||
const sliderRow = new PopupMenu.PopupBaseMenuItem({activate: false});
|
const sliderRow = new PopupMenu.PopupBaseMenuItem({activate: false});
|
||||||
|
sliderRow.add_style_class_name('ddc-brightness-slider');
|
||||||
|
|
||||||
const slider = new Slider.Slider(display.currentValue / 100);
|
const slider = new Slider.Slider(display.currentValue / 100);
|
||||||
|
|
||||||
|
|||||||
+1
-20
@@ -1,23 +1,4 @@
|
|||||||
.ddc-brightness-slider-box {
|
.ddc-brightness-slider .slider {
|
||||||
padding: 8px 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ddc-brightness-value-label {
|
|
||||||
font-size: 12px;
|
|
||||||
font-weight: bold;
|
|
||||||
color: #ffffff;
|
|
||||||
min-width: 40px;
|
|
||||||
text-align: right;
|
|
||||||
}
|
|
||||||
|
|
||||||
.slider {
|
|
||||||
height: 24px;
|
height: 24px;
|
||||||
border-radius: 12px;
|
border-radius: 12px;
|
||||||
background-color: rgba(255, 255, 255, 0.2);
|
|
||||||
}
|
|
||||||
|
|
||||||
.slider .fill-level {
|
|
||||||
height: 24px;
|
|
||||||
border-radius: 12px;
|
|
||||||
background-color: white;
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user