mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
gex: add toggle for anime powersave anim
This commit is contained in:
@@ -88,7 +88,8 @@ impl CtrlAnimeZbus {
|
|||||||
.ok();
|
.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Enable the builtin animations or not
|
/// Enable the builtin animations or not. This is quivalent to "Powersave
|
||||||
|
/// animations" in Armory crate
|
||||||
async fn set_builtins_enabled(
|
async fn set_builtins_enabled(
|
||||||
&self,
|
&self,
|
||||||
#[zbus(signal_context)] ctxt: SignalContext<'_>,
|
#[zbus(signal_context)] ctxt: SignalContext<'_>,
|
||||||
|
|||||||
@@ -38,6 +38,23 @@ export class AnimeDbus extends DbusBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public setPowersaveAnim(state: boolean | null) {
|
||||||
|
if (this.isRunning()) {
|
||||||
|
try {
|
||||||
|
// if null, toggle the current state
|
||||||
|
state = (state == null ? !this.deviceState.builtin_anims_enabled : state);
|
||||||
|
|
||||||
|
if (this.deviceState.builtin_anims_enabled !== state) {
|
||||||
|
this.deviceState.builtin_anims_enabled = state;
|
||||||
|
}
|
||||||
|
return this.dbus_proxy.SetEnableBuiltinsSync(state);
|
||||||
|
} catch (e) {
|
||||||
|
//@ts-ignore
|
||||||
|
log("AniMe DBus set builtins failed!", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public setBrightness(brightness: Brightness) {
|
public setBrightness(brightness: Brightness) {
|
||||||
if (this.isRunning()) {
|
if (this.isRunning()) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
82
desktop-extensions/gnome/src/modules/menu_toggles/anime.ts
Normal file
82
desktop-extensions/gnome/src/modules/menu_toggles/anime.ts
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
declare const imports: any;
|
||||||
|
|
||||||
|
import { AnimeDbus } from "../dbus/animatrix";
|
||||||
|
|
||||||
|
const { GObject } = imports.gi;
|
||||||
|
const ExtensionUtils = imports.misc.extensionUtils;
|
||||||
|
const PopupMenu = imports.ui.popupMenu;
|
||||||
|
|
||||||
|
export const MenuToggleAnimePower = GObject.registerClass(
|
||||||
|
class MenuToggleAnimePower extends PopupMenu.PopupSwitchMenuItem {
|
||||||
|
private _dbus_anime: AnimeDbus;
|
||||||
|
|
||||||
|
constructor(dbus_anime: AnimeDbus) {
|
||||||
|
super(
|
||||||
|
"AniMatrix Display Power", dbus_anime.deviceState.display_enabled
|
||||||
|
);
|
||||||
|
this._dbus_anime = dbus_anime;
|
||||||
|
this.label = "AniMatrix Display Power";
|
||||||
|
this._settings = ExtensionUtils.getSettings();
|
||||||
|
|
||||||
|
this.connectObject(
|
||||||
|
"destroy", () => this._settings.run_dispose(),
|
||||||
|
"toggled", () => this._toggleMode(),
|
||||||
|
this);
|
||||||
|
|
||||||
|
this.connect("destroy", () => {
|
||||||
|
this.destroy();
|
||||||
|
});
|
||||||
|
|
||||||
|
this.sync();
|
||||||
|
}
|
||||||
|
|
||||||
|
_toggleMode() {
|
||||||
|
this._dbus_anime.getDeviceState();
|
||||||
|
if (this.state !== this._dbus_anime.deviceState.display_enabled)
|
||||||
|
this._dbus_anime.setEnableDisplay(this.state);
|
||||||
|
}
|
||||||
|
|
||||||
|
sync() {
|
||||||
|
this._dbus_anime.getDeviceState();
|
||||||
|
const checked = this._dbus_anime.deviceState.display_enabled;
|
||||||
|
this.setToggleState(checked);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
export const MenuToggleAnimeBuiltins = GObject.registerClass(
|
||||||
|
class MenuToggleAnimeBuiltins extends PopupMenu.PopupSwitchMenuItem {
|
||||||
|
private _dbus_anime: AnimeDbus;
|
||||||
|
|
||||||
|
constructor(dbus_anime: AnimeDbus) {
|
||||||
|
super(
|
||||||
|
"AniMatrix Powersave Animation", dbus_anime.deviceState.builtin_anims_enabled
|
||||||
|
);
|
||||||
|
this._dbus_anime = dbus_anime;
|
||||||
|
this.label = "AniMatrix Powersave Animation";
|
||||||
|
this._settings = ExtensionUtils.getSettings();
|
||||||
|
|
||||||
|
this.connectObject(
|
||||||
|
"destroy", () => this._settings.run_dispose(),
|
||||||
|
"toggled", () => this._toggleMode(),
|
||||||
|
this);
|
||||||
|
|
||||||
|
this.connect("destroy", () => {
|
||||||
|
this.destroy();
|
||||||
|
});
|
||||||
|
|
||||||
|
this.sync();
|
||||||
|
}
|
||||||
|
|
||||||
|
_toggleMode() {
|
||||||
|
this._dbus_anime.getDeviceState();
|
||||||
|
if (this.state !== this._dbus_anime.deviceState.builtin_anims_enabled)
|
||||||
|
this._dbus_anime.setPowersaveAnim(this.state);
|
||||||
|
}
|
||||||
|
|
||||||
|
sync() {
|
||||||
|
this._dbus_anime.getDeviceState();
|
||||||
|
const checked = this._dbus_anime.deviceState.display_enabled;
|
||||||
|
this.setToggleState(checked);
|
||||||
|
}
|
||||||
|
});
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
declare const imports: any;
|
|
||||||
|
|
||||||
import { AnimeDbus } from "../dbus/animatrix";
|
|
||||||
|
|
||||||
const { GObject, Gio } = imports.gi;
|
|
||||||
const ExtensionUtils = imports.misc.extensionUtils;
|
|
||||||
const PopupMenu = imports.ui.popupMenu;
|
|
||||||
|
|
||||||
export const MenuToggleAnimePower = GObject.registerClass(
|
|
||||||
class MenuToggleAnimePower extends PopupMenu.PopupSwitchMenuItem {
|
|
||||||
private _dbus_anime: AnimeDbus;
|
|
||||||
|
|
||||||
constructor(dbus_anime: AnimeDbus) {
|
|
||||||
super(
|
|
||||||
"AniMatrix Power", dbus_anime.deviceState.display_enabled
|
|
||||||
);
|
|
||||||
this._dbus_anime = dbus_anime;
|
|
||||||
this.label = "AniMatrix Power";
|
|
||||||
this._settings = ExtensionUtils.getSettings();
|
|
||||||
|
|
||||||
this.connectObject(
|
|
||||||
"destroy", () => this._settings.run_dispose(),
|
|
||||||
"toggled", () => this._toggleMode(),
|
|
||||||
this);
|
|
||||||
|
|
||||||
this.connect("destroy", () => {
|
|
||||||
this.destroy();
|
|
||||||
});
|
|
||||||
|
|
||||||
this.sync();
|
|
||||||
}
|
|
||||||
|
|
||||||
_toggleMode() {
|
|
||||||
if (this.state !== this._dbus_anime.getDeviceState())
|
|
||||||
this._dbus_anime.setEnableDisplay(this.state);
|
|
||||||
}
|
|
||||||
|
|
||||||
sync() {
|
|
||||||
this._dbus_anime.getDeviceState();
|
|
||||||
const checked = this._dbus_anime.deviceState.display_enabled;
|
|
||||||
this.setToggleState(checked);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
@@ -6,7 +6,7 @@ import { Supported } from "./dbus/supported";
|
|||||||
import { Platform } from "./dbus/platform";
|
import { Platform } from "./dbus/platform";
|
||||||
|
|
||||||
import { addQuickSettingsItems } from "./helpers";
|
import { addQuickSettingsItems } from "./helpers";
|
||||||
import { MenuToggleAnimePower } from "./menu_toggles/anime_power";
|
import { MenuToggleAnimeBuiltins, MenuToggleAnimePower } from "./menu_toggles/anime";
|
||||||
import { MenuTogglePanelOd } from "./menu_toggles/panel_od";
|
import { MenuTogglePanelOd } from "./menu_toggles/panel_od";
|
||||||
import { MenuToggleMiniLed } from "./menu_toggles/mini_led";
|
import { MenuToggleMiniLed } from "./menu_toggles/mini_led";
|
||||||
|
|
||||||
@@ -28,7 +28,8 @@ export const FeatureMenuToggle = GObject.registerClass(
|
|||||||
|
|
||||||
public miniLed: typeof MenuToggleMiniLed;
|
public miniLed: typeof MenuToggleMiniLed;
|
||||||
public panelOd: typeof MenuTogglePanelOd;
|
public panelOd: typeof MenuTogglePanelOd;
|
||||||
public animePower: typeof MenuToggleAnimePower;
|
public animeDisplayPower: typeof MenuToggleAnimePower;
|
||||||
|
public animePowersaveAnim: typeof MenuToggleAnimeBuiltins;
|
||||||
private primary = "mini-led";
|
private primary = "mini-led";
|
||||||
|
|
||||||
constructor(dbus_supported: Supported, dbus_platform: Platform, dbus_anime: AnimeDbus) {
|
constructor(dbus_supported: Supported, dbus_platform: Platform, dbus_anime: AnimeDbus) {
|
||||||
@@ -111,14 +112,14 @@ export const FeatureMenuToggle = GObject.registerClass(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this._dbus_supported.supported.anime_ctrl) {
|
if (this._dbus_supported.supported.anime_ctrl) {
|
||||||
if (this.animePower == null) {
|
if (this.animeDisplayPower == null) {
|
||||||
this.animePower = new MenuToggleAnimePower(this._dbus_anime);
|
this.animeDisplayPower = new MenuToggleAnimePower(this._dbus_anime);
|
||||||
this._dbus_anime.notifyAnimeStateSubscribers.push(this.animePower);
|
this._dbus_anime.notifyAnimeStateSubscribers.push(this.animeDisplayPower);
|
||||||
this._itemsSection.addMenuItem(this.animePower);
|
this._itemsSection.addMenuItem(this.animeDisplayPower);
|
||||||
|
|
||||||
if (this.primary == "anime-power") {
|
if (this.primary == "anime-power") {
|
||||||
// Set the togglemenu title and action
|
// Set the togglemenu title and action
|
||||||
this.title = this.animePower.label;
|
this.title = this.animeDisplayPower.label;
|
||||||
|
|
||||||
this.connectObject(
|
this.connectObject(
|
||||||
"clicked", () => {
|
"clicked", () => {
|
||||||
@@ -132,6 +133,12 @@ export const FeatureMenuToggle = GObject.registerClass(
|
|||||||
this._dbus_anime.notifyAnimeStateSubscribers.push(this);
|
this._dbus_anime.notifyAnimeStateSubscribers.push(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.animePowersaveAnim == null) {
|
||||||
|
this.animePowersaveAnim = new MenuToggleAnimeBuiltins(this._dbus_anime);
|
||||||
|
this._dbus_anime.notifyAnimeStateSubscribers.push(this.animePowersaveAnim);
|
||||||
|
this._itemsSection.addMenuItem(this.animePowersaveAnim);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.menu.addMenuItem(this._itemsSection);
|
this.menu.addMenuItem(this._itemsSection);
|
||||||
|
|||||||
Reference in New Issue
Block a user