mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-01-22 17:33:19 +01:00
gex: add keyboard LED mode setting
This commit is contained in:
@@ -12,6 +12,7 @@ import { SliderChargeLevel } from "./modules/sliders/charge";
|
||||
import { QuickAnimePower } from "./modules/quick_toggles/anime_power";
|
||||
import { FeatureMenuToggle } from "./modules/quick_menus/laptop_features";
|
||||
import { AuraDbus } from "./modules/dbus/aura";
|
||||
import { AuraMenuToggle } from "./modules/quick_menus/aura";
|
||||
|
||||
class Extension {
|
||||
private _indicateMiniLed: typeof IndicateMiniLed;
|
||||
@@ -19,6 +20,7 @@ class Extension {
|
||||
private _quickPanelOd: typeof QuickPanelOd;
|
||||
private _quickAnimePower: typeof QuickAnimePower;
|
||||
private _featureMenuToggle: typeof FeatureMenuToggle;
|
||||
private _auraModeMenuToggle: typeof AuraMenuToggle;
|
||||
private _sliderCharge: typeof SliderChargeLevel;
|
||||
|
||||
public dbus_supported: Supported = new Supported;
|
||||
@@ -46,6 +48,9 @@ class Extension {
|
||||
if (this._featureMenuToggle == null) {
|
||||
this._featureMenuToggle = new FeatureMenuToggle(this.dbus_supported, this.dbus_platform, this.dbus_anime);
|
||||
}
|
||||
if (this._auraModeMenuToggle == null) {
|
||||
this._auraModeMenuToggle = new AuraMenuToggle(this.dbus_aura);
|
||||
}
|
||||
if (this.dbus_supported.supported.rog_bios_ctrl.mini_led_mode) {
|
||||
// if (this._quickMiniLed == null) {
|
||||
// this._quickMiniLed = new QuickMiniLed(this.dbus_platform);
|
||||
|
||||
@@ -85,7 +85,13 @@ export class AuraDbus extends DbusBase {
|
||||
public setLedMode(mode: AuraEffect) {
|
||||
if (this.isRunning()) {
|
||||
try {
|
||||
this.dbus_proxy.SetLedModeSync(mode);
|
||||
this.dbus_proxy.SetLedModeSync([
|
||||
mode.mode,
|
||||
mode.zone,
|
||||
[mode.colour1.r, mode.colour1.g, mode.colour1.b],
|
||||
[mode.colour2.r, mode.colour2.g, mode.colour2.b],
|
||||
mode.speed,
|
||||
mode.direction]);
|
||||
} catch (e) {
|
||||
//@ts-ignore
|
||||
log("Failed to fetch supported functionalities", e);
|
||||
|
||||
@@ -3,12 +3,12 @@ declare const imports: any;
|
||||
|
||||
import { addQuickSettingsItems } from "../helpers";
|
||||
import { AuraDbus } from "../dbus/aura";
|
||||
import { AuraModeNum } from "../../bindings/aura";
|
||||
|
||||
const { GObject } = imports.gi;
|
||||
const ExtensionUtils = imports.misc.extensionUtils;
|
||||
const Me = ExtensionUtils.getCurrentExtension();
|
||||
|
||||
const Main = imports.ui.main;
|
||||
// const Me = ExtensionUtils.getCurrentExtension();
|
||||
// const Main = imports.ui.main;
|
||||
const PopupMenu = imports.ui.popupMenu;
|
||||
const QuickSettings = imports.ui.quickSettings;
|
||||
|
||||
@@ -34,26 +34,39 @@ export const AuraMenuToggle = GObject.registerClass(
|
||||
|
||||
this._itemsSection = new PopupMenu.PopupMenuSection();
|
||||
|
||||
this._dbus_aura.aura_modes.forEach((mode, key) => {
|
||||
this._itemsSection.addAction(key, ()=>{
|
||||
this._dbus_aura.setLedMode(mode);
|
||||
this.sync();
|
||||
}, "");
|
||||
});
|
||||
|
||||
this.menu.addMenuItem(this._itemsSection);
|
||||
|
||||
// Add an entry-point for more settings
|
||||
this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
|
||||
const settingsItem = this.menu.addAction("More Settings",
|
||||
() => ExtensionUtils.openPrefs());
|
||||
// this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
|
||||
// const settingsItem = this.menu.addAction("More Settings",
|
||||
// () => ExtensionUtils.openPrefs());
|
||||
// // Ensure the settings are unavailable when the screen is locked
|
||||
// settingsItem.visible = Main.sessionMode.allowSettings;
|
||||
// this.menu._settingsActions[Me.uuid] = settingsItem;
|
||||
|
||||
// Ensure the settings are unavailable when the screen is locked
|
||||
settingsItem.visible = Main.sessionMode.allowSettings;
|
||||
this.menu._settingsActions[Me.uuid] = settingsItem;
|
||||
this.connectObject(
|
||||
"clicked", () => {
|
||||
// TODO: open a configuration tool
|
||||
this.sync();
|
||||
},
|
||||
this);
|
||||
|
||||
this._dbus_aura.notifyAuraModeSubscribers.push(this);
|
||||
this.sync();
|
||||
|
||||
addQuickSettingsItems([this]);
|
||||
}
|
||||
|
||||
sync() {
|
||||
const checked = false;
|
||||
switch (this.primary) {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
const checked = this._dbus_aura.current_aura_mode != AuraModeNum.Static;
|
||||
this.title = this._dbus_aura.current_aura_mode;
|
||||
|
||||
if (this.checked !== checked)
|
||||
this.set({ checked });
|
||||
|
||||
@@ -14,9 +14,8 @@ import { MenuToggleMiniLed } from "../menu_toggles/mini_led";
|
||||
const { GObject } = imports.gi;
|
||||
|
||||
const ExtensionUtils = imports.misc.extensionUtils;
|
||||
const Me = ExtensionUtils.getCurrentExtension();
|
||||
|
||||
const Main = imports.ui.main;
|
||||
// const Me = ExtensionUtils.getCurrentExtension();
|
||||
// const Main = imports.ui.main;
|
||||
const PopupMenu = imports.ui.popupMenu;
|
||||
const QuickSettings = imports.ui.quickSettings;
|
||||
|
||||
@@ -143,14 +142,13 @@ export const FeatureMenuToggle = GObject.registerClass(
|
||||
|
||||
this.menu.addMenuItem(this._itemsSection);
|
||||
|
||||
// Add an entry-point for more settings
|
||||
this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
|
||||
const settingsItem = this.menu.addAction("More Settings",
|
||||
() => ExtensionUtils.openPrefs());
|
||||
|
||||
// Ensure the settings are unavailable when the screen is locked
|
||||
settingsItem.visible = Main.sessionMode.allowSettings;
|
||||
this.menu._settingsActions[Me.uuid] = settingsItem;
|
||||
// // Add an entry-point for more settings
|
||||
// this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
|
||||
// const settingsItem = this.menu.addAction("More Settings",
|
||||
// () => ExtensionUtils.openPrefs());
|
||||
// // Ensure the settings are unavailable when the screen is locked
|
||||
// settingsItem.visible = Main.sessionMode.allowSettings;
|
||||
// this.menu._settingsActions[Me.uuid] = settingsItem;
|
||||
|
||||
addQuickSettingsItems([this]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user