diff --git a/Cargo.lock b/Cargo.lock index a96c90c3..486f75a3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -609,12 +609,6 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" -[[package]] -name = "c_vec" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdd7a427adc0135366d99db65b36dae9237130997e560ed61118041fb72be6e8" - [[package]] name = "cairo-rs" version = "0.16.7" @@ -2893,7 +2887,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7959277b623f1fb9e04aea73686c3ca52f01b2145f8ea16f4ff30d8b7623b1a" dependencies = [ "bitflags 1.3.2", - "c_vec", "lazy_static", "libc", "sdl2-sys", diff --git a/desktop-extensions/gnome/schemas/org.gnome.shell.extensions.asusctl-gex.gschema.xml b/desktop-extensions/gnome/schemas/org.gnome.shell.extensions.asusctl-gnome.gschema.xml similarity index 92% rename from desktop-extensions/gnome/schemas/org.gnome.shell.extensions.asusctl-gex.gschema.xml rename to desktop-extensions/gnome/schemas/org.gnome.shell.extensions.asusctl-gnome.gschema.xml index 002253a2..a531874b 100644 --- a/desktop-extensions/gnome/schemas/org.gnome.shell.extensions.asusctl-gex.gschema.xml +++ b/desktop-extensions/gnome/schemas/org.gnome.shell.extensions.asusctl-gnome.gschema.xml @@ -1,5 +1,5 @@ - + false diff --git a/desktop-extensions/gnome/src/modules/menu_toggles/anime.ts b/desktop-extensions/gnome/src/modules/menu_toggles/anime.ts index 6aa04577..54d25085 100644 --- a/desktop-extensions/gnome/src/modules/menu_toggles/anime.ts +++ b/desktop-extensions/gnome/src/modules/menu_toggles/anime.ts @@ -9,6 +9,7 @@ const PopupMenu = imports.ui.popupMenu; export const MenuToggleAnimePower = GObject.registerClass( class MenuToggleAnimePower extends PopupMenu.PopupSwitchMenuItem { private _dbus_anime: AnimeDbus; + public toggle_callback = () => {}; constructor(dbus_anime: AnimeDbus) { super( @@ -34,6 +35,7 @@ export const MenuToggleAnimePower = GObject.registerClass( this._dbus_anime.getDeviceState(); if (this.state !== this._dbus_anime.deviceState.display_enabled) this._dbus_anime.setEnableDisplay(this.state); + this.toggle_callback(); } sync() { @@ -47,6 +49,7 @@ export const MenuToggleAnimePower = GObject.registerClass( export const MenuToggleAnimeBuiltins = GObject.registerClass( class MenuToggleAnimeBuiltins extends PopupMenu.PopupSwitchMenuItem { private _dbus_anime: AnimeDbus; + public toggle_callback = () => {}; constructor(dbus_anime: AnimeDbus) { super( @@ -72,6 +75,7 @@ export const MenuToggleAnimeBuiltins = GObject.registerClass( this._dbus_anime.getDeviceState(); if (this.state !== this._dbus_anime.deviceState.builtin_anims_enabled) this._dbus_anime.setPowersaveAnim(this.state); + this.toggle_callback(); } sync() { diff --git a/desktop-extensions/gnome/src/modules/menu_toggles/mini_led.ts b/desktop-extensions/gnome/src/modules/menu_toggles/mini_led.ts index ae18d0ce..4bdcebec 100644 --- a/desktop-extensions/gnome/src/modules/menu_toggles/mini_led.ts +++ b/desktop-extensions/gnome/src/modules/menu_toggles/mini_led.ts @@ -9,6 +9,7 @@ const PopupMenu = imports.ui.popupMenu; export const MenuToggleMiniLed = GObject.registerClass( class MenuToggleMiniLed extends PopupMenu.PopupSwitchMenuItem { private _dbus_platform: Platform; + public toggle_callback = () => {}; constructor(dbus_platform: Platform) { super("MiniLED", dbus_platform.bios.mini_led_mode); @@ -34,6 +35,7 @@ export const MenuToggleMiniLed = GObject.registerClass( const state = this._dbus_platform.bios.mini_led_mode; if (this.state !== state) this._dbus_platform.setMiniLedMode(this.state); + this.toggle_callback(); } sync() { diff --git a/desktop-extensions/gnome/src/modules/menu_toggles/panel_od.ts b/desktop-extensions/gnome/src/modules/menu_toggles/panel_od.ts index c31452d3..2ca8a3ca 100644 --- a/desktop-extensions/gnome/src/modules/menu_toggles/panel_od.ts +++ b/desktop-extensions/gnome/src/modules/menu_toggles/panel_od.ts @@ -9,6 +9,7 @@ const PopupMenu = imports.ui.popupMenu; export const MenuTogglePanelOd = GObject.registerClass( class MenuTogglePanelOd extends PopupMenu.PopupSwitchMenuItem { private _dbus_platform: Platform; + public toggle_callback = () => {}; constructor(dbus_platform: Platform) { super("Panel Overdrive", dbus_platform.bios.panel_overdrive); @@ -34,6 +35,7 @@ export const MenuTogglePanelOd = GObject.registerClass( const state = this._dbus_platform.bios.panel_overdrive; if (this.state !== state) this._dbus_platform.setPanelOd(this.state); + this.toggle_callback(); } sync() { diff --git a/desktop-extensions/gnome/src/modules/quick_menus/aura.ts b/desktop-extensions/gnome/src/modules/quick_menus/aura.ts index a5347514..2df2eb76 100644 --- a/desktop-extensions/gnome/src/modules/quick_menus/aura.ts +++ b/desktop-extensions/gnome/src/modules/quick_menus/aura.ts @@ -3,7 +3,7 @@ declare const imports: any; import { addQuickSettingsItems } from "../helpers"; import { AuraDbus } from "../dbus/aura"; -import { AuraModeNum } from "../../bindings/aura"; +import { AuraEffect, AuraModeNum } from "../../bindings/aura"; const { GObject } = imports.gi; const ExtensionUtils = imports.misc.extensionUtils; @@ -15,6 +15,7 @@ const QuickSettings = imports.ui.quickSettings; export const AuraMenuToggle = GObject.registerClass( class AuraMenuToggle extends QuickSettings.QuickMenuToggle { private _dbus_aura: AuraDbus; + private _last_mode: AuraModeNum = AuraModeNum.Static; constructor(dbus_aura: AuraDbus) { super({ @@ -35,7 +36,7 @@ export const AuraMenuToggle = GObject.registerClass( this._itemsSection = new PopupMenu.PopupMenuSection(); this._dbus_aura.aura_modes.forEach((mode, key) => { - this._itemsSection.addAction(key, ()=>{ + this._itemsSection.addAction(key, () => { this._dbus_aura.setLedMode(mode); this.sync(); }, ""); @@ -53,8 +54,16 @@ export const AuraMenuToggle = GObject.registerClass( this.connectObject( "clicked", () => { - // TODO: open a configuration tool - this.sync(); + let mode: AuraEffect | undefined; + if (this._dbus_aura.current_aura_mode == AuraModeNum.Static) { + mode = this._dbus_aura.aura_modes.get(this._last_mode); + } else { + mode = this._dbus_aura.aura_modes.get(AuraModeNum.Static); + } + if (mode != undefined) { + this._dbus_aura.setLedMode(mode); + this.sync(); + } }, this); @@ -67,6 +76,9 @@ export const AuraMenuToggle = GObject.registerClass( sync() { const checked = this._dbus_aura.current_aura_mode != AuraModeNum.Static; this.title = this._dbus_aura.current_aura_mode; + if (this._last_mode != this._dbus_aura.current_aura_mode && this._dbus_aura.current_aura_mode != AuraModeNum.Static) { + this._last_mode = this._dbus_aura.current_aura_mode; + } if (this.checked !== checked) this.set({ checked }); diff --git a/desktop-extensions/gnome/src/modules/quick_menus/laptop_features.ts b/desktop-extensions/gnome/src/modules/quick_menus/laptop_features.ts index b0bdbe32..71014e43 100644 --- a/desktop-extensions/gnome/src/modules/quick_menus/laptop_features.ts +++ b/desktop-extensions/gnome/src/modules/quick_menus/laptop_features.ts @@ -41,10 +41,6 @@ export const FeatureMenuToggle = GObject.registerClass( this._dbus_platform = dbus_platform; this._dbus_anime = dbus_anime; - this.connectObject( - "destroy", () => this._settings.run_dispose(), - this); - this.menu.setHeader("selection-mode-symbolic", "Laptop features"); this._settings = ExtensionUtils.getSettings(); @@ -60,29 +56,24 @@ export const FeatureMenuToggle = GObject.registerClass( } else if (this.primary.length == 0) { this.primary = "panel-od"; } + + this.connectObject( + "destroy", () => this._settings.run_dispose(), + this); + this._settings.connect('changed::primary-quickmenu-toggle', + this.sync); this._settings.set_string("primary-quickmenu-toggle", this.primary); this._itemsSection = new PopupMenu.PopupMenuSection(); - if (this._dbus_supported.supported.rog_bios_ctrl.mini_led_mode) { if (this.miniLed == null) { this.miniLed = new MenuToggleMiniLed(this._dbus_platform); this._dbus_platform.notifyMiniLedSubscribers.push(this.miniLed); this._itemsSection.addMenuItem(this.miniLed); - - if (this.primary == "mini-led") { - // Set the togglemenu title and action - this.title = this.miniLed.label; - - this.connectObject( - "clicked", () => { - const checked = this._dbus_platform.getMiniLedMode(); - if (this.checked !== checked) - this._dbus_platform.setMiniLedMode(this.checked); - }, - this); + this._dbus_platform.notifyMiniLedSubscribers.push(this); + this.miniLed.toggle_callback = () => { + this.primary = "mini-led"; this.sync(); - this._dbus_platform.notifyMiniLedSubscribers.push(this); } } } @@ -92,20 +83,10 @@ export const FeatureMenuToggle = GObject.registerClass( this.panelOd = new MenuTogglePanelOd(this._dbus_platform); this._dbus_platform.notifyPanelOdSubscribers.push(this.panelOd); this._itemsSection.addMenuItem(this.panelOd); - - if (this.primary == "panel-od") { - // Set the togglemenu title and action - this.title = this.panelOd.label; - - this.connectObject( - "clicked", () => { - const checked = this._dbus_platform.getPanelOd(); - if (this.checked !== checked) - this._dbus_platform.setPanelOd(this.checked); - }, - this); + this._dbus_platform.notifyPanelOdSubscribers.push(this); + this.panelOd.toggle_callback = () => { + this.primary = "panel-od"; this.sync(); - this._dbus_platform.notifyPanelOdSubscribers.push(this); } } } @@ -115,21 +96,10 @@ export const FeatureMenuToggle = GObject.registerClass( this.animeDisplayPower = new MenuToggleAnimePower(this._dbus_anime); this._dbus_anime.notifyAnimeStateSubscribers.push(this.animeDisplayPower); this._itemsSection.addMenuItem(this.animeDisplayPower); - - if (this.primary == "anime-power") { - // Set the togglemenu title and action - this.title = this.animeDisplayPower.label; - - this.connectObject( - "clicked", () => { - this._dbus_anime.getDeviceState(); - const checked = this._dbus_anime.deviceState.display_enabled; - if (this.checked !== checked) - this._dbus_anime.setEnableDisplay(this.checked); - }, - this); + this._dbus_anime.notifyAnimeStateSubscribers.push(this); + this.animeDisplayPower.toggle_callback = () => { + this.primary = "anime-power"; this.sync(); - this._dbus_anime.notifyAnimeStateSubscribers.push(this); } } @@ -140,6 +110,12 @@ export const FeatureMenuToggle = GObject.registerClass( } } + this.connectObject( + "clicked", () => { + this._toggle(); + }, + this); + this.menu.addMenuItem(this._itemsSection); // // Add an entry-point for more settings @@ -150,26 +126,53 @@ export const FeatureMenuToggle = GObject.registerClass( // settingsItem.visible = Main.sessionMode.allowSettings; // this.menu._settingsActions[Me.uuid] = settingsItem; + this.sync(); addQuickSettingsItems([this]); } + _toggle() { + if (this.primary == "mini-led" && this.miniLed != null) { + this._dbus_platform.getMiniLedMode(); + const checked = this._dbus_platform.bios.mini_led_mode; + if (this.checked !== checked) + this._dbus_platform.setMiniLedMode(this.checked); + } + + if (this.primary == "panel-od" && this.panelOd != null) { + this._dbus_platform.getPanelOd(); + const checked = this._dbus_platform.bios.panel_overdrive; + if (this.checked !== checked) + this._dbus_platform.setPanelOd(this.checked); + } + + if (this.primary == "anime-power" && this.animeDisplayPower != null) { + this._dbus_anime.getDeviceState(); + const checked = this._dbus_anime.deviceState.display_enabled; + if (this.checked !== checked) + this._dbus_anime.setEnableDisplay(this.checked); + } + } + sync() { let checked = false; - switch (this.primary) { - case "mini-led": - checked = this._dbus_platform.getMiniLedMode(); - break; - case "panel-od": - checked = this._dbus_platform.getPanelOd(); - break; - case "anime-power": - this._dbus_anime.getDeviceState(); - checked = this._dbus_anime.deviceState.display_enabled; - break; - default: - return; + if (this.primary == "mini-led" && this.miniLed != null) { + this.title = this.miniLed.label; + checked = this._dbus_platform.bios.mini_led_mode; } + if (this.primary == "panel-od" && this.panelOd != null) { + this.title = this.panelOd.label; + checked = this._dbus_platform.bios.panel_overdrive; + } + + if (this.primary == "anime-power" && this.animeDisplayPower != null) { + this.title = this.animeDisplayPower.label; + checked = this._dbus_anime.deviceState.display_enabled; + } + + // if (this.animePowersaveAnim != null) { + // } + if (this.checked !== checked) this.set({ checked }); } diff --git a/simulators/Cargo.toml b/simulators/Cargo.toml index b98f88da..323d1000 100644 --- a/simulators/Cargo.toml +++ b/simulators/Cargo.toml @@ -27,4 +27,4 @@ rog_anime = { path = "../rog-anime", features = ["dbus"] } [dependencies.sdl2] version = "0.35" default-features = false -features = ["gfx"] \ No newline at end of file +# features = ["gfx"] \ No newline at end of file