mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
54 lines
1.6 KiB
TypeScript
54 lines
1.6 KiB
TypeScript
declare const imports: any;
|
|
|
|
import { Platform } from "../dbus/platform";
|
|
import { addQuickSettingsItems } from "../helpers";
|
|
|
|
const { GObject, Gio } = imports.gi;
|
|
const ExtensionUtils = imports.misc.extensionUtils;
|
|
|
|
const { QuickToggle } = imports.ui.quickSettings;
|
|
|
|
export const QuickMiniLed = GObject.registerClass(
|
|
class QuickMiniLed extends QuickToggle {
|
|
private _dbus_platform: Platform;
|
|
|
|
constructor(dbus_platform: Platform) {
|
|
super({
|
|
title: "MiniLED",
|
|
iconName: "selection-mode-symbolic",
|
|
toggleMode: true,
|
|
});
|
|
this._dbus_platform = dbus_platform;
|
|
this.label = "MiniLED";
|
|
this._settings = ExtensionUtils.getSettings();
|
|
|
|
this.connectObject(
|
|
"destroy", () => this._settings.run_dispose(),
|
|
"clicked", () => this._toggleMode(),
|
|
this);
|
|
|
|
this.connect("destroy", () => {
|
|
this.destroy();
|
|
});
|
|
|
|
this._settings.bind("mini-led-enabled",
|
|
this, "checked",
|
|
Gio.SettingsBindFlags.DEFAULT);
|
|
|
|
this.sync();
|
|
|
|
addQuickSettingsItems([this]);
|
|
}
|
|
|
|
_toggleMode() {
|
|
const checked = this._dbus_platform.getMiniLedMode();
|
|
if (this.checked !== checked)
|
|
this._dbus_platform.setMiniLedMode(this.checked);
|
|
}
|
|
|
|
sync() {
|
|
const checked = this._dbus_platform.getMiniLedMode();
|
|
if (this.checked !== checked)
|
|
this.set({ checked });
|
|
}
|
|
}); |