mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
gex: update laptop feature toggle to switch primary
This commit is contained in:
7
Cargo.lock
generated
7
Cargo.lock
generated
@@ -609,12 +609,6 @@ version = "1.4.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be"
|
checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "c_vec"
|
|
||||||
version = "2.0.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "fdd7a427adc0135366d99db65b36dae9237130997e560ed61118041fb72be6e8"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cairo-rs"
|
name = "cairo-rs"
|
||||||
version = "0.16.7"
|
version = "0.16.7"
|
||||||
@@ -2893,7 +2887,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "f7959277b623f1fb9e04aea73686c3ca52f01b2145f8ea16f4ff30d8b7623b1a"
|
checksum = "f7959277b623f1fb9e04aea73686c3ca52f01b2145f8ea16f4ff30d8b7623b1a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 1.3.2",
|
"bitflags 1.3.2",
|
||||||
"c_vec",
|
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"libc",
|
"libc",
|
||||||
"sdl2-sys",
|
"sdl2-sys",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<schemalist>
|
<schemalist gettext-domain="AsusctlGnomeExtension">
|
||||||
<schema id="org.gnome.shell.extensions.asusctl-gnome" path="/org/gnome/shell/extensions/asusctl-gnome/" >
|
<schema id="org.gnome.shell.extensions.asusctl-gnome" path="/org/gnome/shell/extensions/asusctl-gnome/" >
|
||||||
<key type="b" name="mini-led-enabled">
|
<key type="b" name="mini-led-enabled">
|
||||||
<default>false</default>
|
<default>false</default>
|
||||||
@@ -9,6 +9,7 @@ const PopupMenu = imports.ui.popupMenu;
|
|||||||
export const MenuToggleAnimePower = GObject.registerClass(
|
export const MenuToggleAnimePower = GObject.registerClass(
|
||||||
class MenuToggleAnimePower extends PopupMenu.PopupSwitchMenuItem {
|
class MenuToggleAnimePower extends PopupMenu.PopupSwitchMenuItem {
|
||||||
private _dbus_anime: AnimeDbus;
|
private _dbus_anime: AnimeDbus;
|
||||||
|
public toggle_callback = () => {};
|
||||||
|
|
||||||
constructor(dbus_anime: AnimeDbus) {
|
constructor(dbus_anime: AnimeDbus) {
|
||||||
super(
|
super(
|
||||||
@@ -34,6 +35,7 @@ export const MenuToggleAnimePower = GObject.registerClass(
|
|||||||
this._dbus_anime.getDeviceState();
|
this._dbus_anime.getDeviceState();
|
||||||
if (this.state !== this._dbus_anime.deviceState.display_enabled)
|
if (this.state !== this._dbus_anime.deviceState.display_enabled)
|
||||||
this._dbus_anime.setEnableDisplay(this.state);
|
this._dbus_anime.setEnableDisplay(this.state);
|
||||||
|
this.toggle_callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
sync() {
|
sync() {
|
||||||
@@ -47,6 +49,7 @@ export const MenuToggleAnimePower = GObject.registerClass(
|
|||||||
export const MenuToggleAnimeBuiltins = GObject.registerClass(
|
export const MenuToggleAnimeBuiltins = GObject.registerClass(
|
||||||
class MenuToggleAnimeBuiltins extends PopupMenu.PopupSwitchMenuItem {
|
class MenuToggleAnimeBuiltins extends PopupMenu.PopupSwitchMenuItem {
|
||||||
private _dbus_anime: AnimeDbus;
|
private _dbus_anime: AnimeDbus;
|
||||||
|
public toggle_callback = () => {};
|
||||||
|
|
||||||
constructor(dbus_anime: AnimeDbus) {
|
constructor(dbus_anime: AnimeDbus) {
|
||||||
super(
|
super(
|
||||||
@@ -72,6 +75,7 @@ export const MenuToggleAnimeBuiltins = GObject.registerClass(
|
|||||||
this._dbus_anime.getDeviceState();
|
this._dbus_anime.getDeviceState();
|
||||||
if (this.state !== this._dbus_anime.deviceState.builtin_anims_enabled)
|
if (this.state !== this._dbus_anime.deviceState.builtin_anims_enabled)
|
||||||
this._dbus_anime.setPowersaveAnim(this.state);
|
this._dbus_anime.setPowersaveAnim(this.state);
|
||||||
|
this.toggle_callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
sync() {
|
sync() {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ const PopupMenu = imports.ui.popupMenu;
|
|||||||
export const MenuToggleMiniLed = GObject.registerClass(
|
export const MenuToggleMiniLed = GObject.registerClass(
|
||||||
class MenuToggleMiniLed extends PopupMenu.PopupSwitchMenuItem {
|
class MenuToggleMiniLed extends PopupMenu.PopupSwitchMenuItem {
|
||||||
private _dbus_platform: Platform;
|
private _dbus_platform: Platform;
|
||||||
|
public toggle_callback = () => {};
|
||||||
|
|
||||||
constructor(dbus_platform: Platform) {
|
constructor(dbus_platform: Platform) {
|
||||||
super("MiniLED", dbus_platform.bios.mini_led_mode);
|
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;
|
const state = this._dbus_platform.bios.mini_led_mode;
|
||||||
if (this.state !== state)
|
if (this.state !== state)
|
||||||
this._dbus_platform.setMiniLedMode(this.state);
|
this._dbus_platform.setMiniLedMode(this.state);
|
||||||
|
this.toggle_callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
sync() {
|
sync() {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ const PopupMenu = imports.ui.popupMenu;
|
|||||||
export const MenuTogglePanelOd = GObject.registerClass(
|
export const MenuTogglePanelOd = GObject.registerClass(
|
||||||
class MenuTogglePanelOd extends PopupMenu.PopupSwitchMenuItem {
|
class MenuTogglePanelOd extends PopupMenu.PopupSwitchMenuItem {
|
||||||
private _dbus_platform: Platform;
|
private _dbus_platform: Platform;
|
||||||
|
public toggle_callback = () => {};
|
||||||
|
|
||||||
constructor(dbus_platform: Platform) {
|
constructor(dbus_platform: Platform) {
|
||||||
super("Panel Overdrive", dbus_platform.bios.panel_overdrive);
|
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;
|
const state = this._dbus_platform.bios.panel_overdrive;
|
||||||
if (this.state !== state)
|
if (this.state !== state)
|
||||||
this._dbus_platform.setPanelOd(this.state);
|
this._dbus_platform.setPanelOd(this.state);
|
||||||
|
this.toggle_callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
sync() {
|
sync() {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ declare const imports: any;
|
|||||||
|
|
||||||
import { addQuickSettingsItems } from "../helpers";
|
import { addQuickSettingsItems } from "../helpers";
|
||||||
import { AuraDbus } from "../dbus/aura";
|
import { AuraDbus } from "../dbus/aura";
|
||||||
import { AuraModeNum } from "../../bindings/aura";
|
import { AuraEffect, AuraModeNum } from "../../bindings/aura";
|
||||||
|
|
||||||
const { GObject } = imports.gi;
|
const { GObject } = imports.gi;
|
||||||
const ExtensionUtils = imports.misc.extensionUtils;
|
const ExtensionUtils = imports.misc.extensionUtils;
|
||||||
@@ -15,6 +15,7 @@ const QuickSettings = imports.ui.quickSettings;
|
|||||||
export const AuraMenuToggle = GObject.registerClass(
|
export const AuraMenuToggle = GObject.registerClass(
|
||||||
class AuraMenuToggle extends QuickSettings.QuickMenuToggle {
|
class AuraMenuToggle extends QuickSettings.QuickMenuToggle {
|
||||||
private _dbus_aura: AuraDbus;
|
private _dbus_aura: AuraDbus;
|
||||||
|
private _last_mode: AuraModeNum = AuraModeNum.Static;
|
||||||
|
|
||||||
constructor(dbus_aura: AuraDbus) {
|
constructor(dbus_aura: AuraDbus) {
|
||||||
super({
|
super({
|
||||||
@@ -35,7 +36,7 @@ export const AuraMenuToggle = GObject.registerClass(
|
|||||||
this._itemsSection = new PopupMenu.PopupMenuSection();
|
this._itemsSection = new PopupMenu.PopupMenuSection();
|
||||||
|
|
||||||
this._dbus_aura.aura_modes.forEach((mode, key) => {
|
this._dbus_aura.aura_modes.forEach((mode, key) => {
|
||||||
this._itemsSection.addAction(key, ()=>{
|
this._itemsSection.addAction(key, () => {
|
||||||
this._dbus_aura.setLedMode(mode);
|
this._dbus_aura.setLedMode(mode);
|
||||||
this.sync();
|
this.sync();
|
||||||
}, "");
|
}, "");
|
||||||
@@ -53,8 +54,16 @@ export const AuraMenuToggle = GObject.registerClass(
|
|||||||
|
|
||||||
this.connectObject(
|
this.connectObject(
|
||||||
"clicked", () => {
|
"clicked", () => {
|
||||||
// TODO: open a configuration tool
|
let mode: AuraEffect | undefined;
|
||||||
this.sync();
|
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);
|
this);
|
||||||
|
|
||||||
@@ -67,6 +76,9 @@ export const AuraMenuToggle = GObject.registerClass(
|
|||||||
sync() {
|
sync() {
|
||||||
const checked = this._dbus_aura.current_aura_mode != AuraModeNum.Static;
|
const checked = this._dbus_aura.current_aura_mode != AuraModeNum.Static;
|
||||||
this.title = this._dbus_aura.current_aura_mode;
|
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)
|
if (this.checked !== checked)
|
||||||
this.set({ checked });
|
this.set({ checked });
|
||||||
|
|||||||
@@ -41,10 +41,6 @@ export const FeatureMenuToggle = GObject.registerClass(
|
|||||||
this._dbus_platform = dbus_platform;
|
this._dbus_platform = dbus_platform;
|
||||||
this._dbus_anime = dbus_anime;
|
this._dbus_anime = dbus_anime;
|
||||||
|
|
||||||
this.connectObject(
|
|
||||||
"destroy", () => this._settings.run_dispose(),
|
|
||||||
this);
|
|
||||||
|
|
||||||
this.menu.setHeader("selection-mode-symbolic", "Laptop features");
|
this.menu.setHeader("selection-mode-symbolic", "Laptop features");
|
||||||
|
|
||||||
this._settings = ExtensionUtils.getSettings();
|
this._settings = ExtensionUtils.getSettings();
|
||||||
@@ -60,29 +56,24 @@ export const FeatureMenuToggle = GObject.registerClass(
|
|||||||
} else if (this.primary.length == 0) {
|
} else if (this.primary.length == 0) {
|
||||||
this.primary = "panel-od";
|
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._settings.set_string("primary-quickmenu-toggle", this.primary);
|
||||||
|
|
||||||
this._itemsSection = new PopupMenu.PopupMenuSection();
|
this._itemsSection = new PopupMenu.PopupMenuSection();
|
||||||
|
|
||||||
if (this._dbus_supported.supported.rog_bios_ctrl.mini_led_mode) {
|
if (this._dbus_supported.supported.rog_bios_ctrl.mini_led_mode) {
|
||||||
if (this.miniLed == null) {
|
if (this.miniLed == null) {
|
||||||
this.miniLed = new MenuToggleMiniLed(this._dbus_platform);
|
this.miniLed = new MenuToggleMiniLed(this._dbus_platform);
|
||||||
this._dbus_platform.notifyMiniLedSubscribers.push(this.miniLed);
|
this._dbus_platform.notifyMiniLedSubscribers.push(this.miniLed);
|
||||||
this._itemsSection.addMenuItem(this.miniLed);
|
this._itemsSection.addMenuItem(this.miniLed);
|
||||||
|
this._dbus_platform.notifyMiniLedSubscribers.push(this);
|
||||||
if (this.primary == "mini-led") {
|
this.miniLed.toggle_callback = () => {
|
||||||
// Set the togglemenu title and action
|
this.primary = "mini-led";
|
||||||
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.sync();
|
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.panelOd = new MenuTogglePanelOd(this._dbus_platform);
|
||||||
this._dbus_platform.notifyPanelOdSubscribers.push(this.panelOd);
|
this._dbus_platform.notifyPanelOdSubscribers.push(this.panelOd);
|
||||||
this._itemsSection.addMenuItem(this.panelOd);
|
this._itemsSection.addMenuItem(this.panelOd);
|
||||||
|
this._dbus_platform.notifyPanelOdSubscribers.push(this);
|
||||||
if (this.primary == "panel-od") {
|
this.panelOd.toggle_callback = () => {
|
||||||
// Set the togglemenu title and action
|
this.primary = "panel-od";
|
||||||
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.sync();
|
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.animeDisplayPower = new MenuToggleAnimePower(this._dbus_anime);
|
||||||
this._dbus_anime.notifyAnimeStateSubscribers.push(this.animeDisplayPower);
|
this._dbus_anime.notifyAnimeStateSubscribers.push(this.animeDisplayPower);
|
||||||
this._itemsSection.addMenuItem(this.animeDisplayPower);
|
this._itemsSection.addMenuItem(this.animeDisplayPower);
|
||||||
|
this._dbus_anime.notifyAnimeStateSubscribers.push(this);
|
||||||
if (this.primary == "anime-power") {
|
this.animeDisplayPower.toggle_callback = () => {
|
||||||
// Set the togglemenu title and action
|
this.primary = "anime-power";
|
||||||
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.sync();
|
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);
|
this.menu.addMenuItem(this._itemsSection);
|
||||||
|
|
||||||
// // Add an entry-point for more settings
|
// // Add an entry-point for more settings
|
||||||
@@ -150,26 +126,53 @@ export const FeatureMenuToggle = GObject.registerClass(
|
|||||||
// settingsItem.visible = Main.sessionMode.allowSettings;
|
// settingsItem.visible = Main.sessionMode.allowSettings;
|
||||||
// this.menu._settingsActions[Me.uuid] = settingsItem;
|
// this.menu._settingsActions[Me.uuid] = settingsItem;
|
||||||
|
|
||||||
|
this.sync();
|
||||||
addQuickSettingsItems([this]);
|
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() {
|
sync() {
|
||||||
let checked = false;
|
let checked = false;
|
||||||
switch (this.primary) {
|
if (this.primary == "mini-led" && this.miniLed != null) {
|
||||||
case "mini-led":
|
this.title = this.miniLed.label;
|
||||||
checked = this._dbus_platform.getMiniLedMode();
|
checked = this._dbus_platform.bios.mini_led_mode;
|
||||||
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 == "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)
|
if (this.checked !== checked)
|
||||||
this.set({ checked });
|
this.set({ checked });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,4 +27,4 @@ rog_anime = { path = "../rog-anime", features = ["dbus"] }
|
|||||||
[dependencies.sdl2]
|
[dependencies.sdl2]
|
||||||
version = "0.35"
|
version = "0.35"
|
||||||
default-features = false
|
default-features = false
|
||||||
features = ["gfx"]
|
# features = ["gfx"]
|
||||||
Reference in New Issue
Block a user