mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-01-22 09:23:19 +01:00
Anime: add dbus methods
This commit is contained in:
@@ -10,6 +10,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Support for G513RW LED modes
|
||||
- Support Rog Ally LED modes (basic)
|
||||
- Add on_lid_closed and on_external_power_changed events for running certain tasks
|
||||
- Anime dbus: add:
|
||||
- SetOffWhenUnplugged
|
||||
- SetOffWhenSuspended
|
||||
- SetOffWhenLidClosed
|
||||
|
||||
### Changed
|
||||
- asusd: remove set_image_brightness for anime
|
||||
|
||||
@@ -3,7 +3,9 @@ use std::time::Duration;
|
||||
use config_traits::{StdConfig, StdConfigLoad2};
|
||||
use rog_anime::error::AnimeError;
|
||||
use rog_anime::usb::Brightness;
|
||||
use rog_anime::{ActionData, ActionLoader, AnimTime, Animations, AnimeType, Fade, Vec2, DeviceState};
|
||||
use rog_anime::{
|
||||
ActionData, ActionLoader, AnimTime, Animations, AnimeType, DeviceState, Fade, Vec2,
|
||||
};
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
|
||||
const CONFIG_FILE: &str = "anime.ron";
|
||||
|
||||
@@ -33,7 +33,8 @@ impl crate::ZbusRun for CtrlAnimeZbus {
|
||||
// grab it until we finish.
|
||||
#[dbus_interface(name = "org.asuslinux.Daemon")]
|
||||
impl CtrlAnimeZbus {
|
||||
/// Writes a data stream of length. Will force system thread to exit until it is restarted
|
||||
/// Writes a data stream of length. Will force system thread to exit until
|
||||
/// it is restarted
|
||||
async fn write(&self, input: AnimeDataBuffer) -> zbus::fdo::Result<()> {
|
||||
let lock = self.0.lock().await;
|
||||
lock.thread_exit.store(true, Ordering::SeqCst);
|
||||
@@ -169,6 +170,48 @@ impl CtrlAnimeZbus {
|
||||
.ok();
|
||||
}
|
||||
|
||||
/// Set if to turn the AniMe Matrix off when external power is unplugged
|
||||
async fn set_off_when_unplugged(
|
||||
&self,
|
||||
#[zbus(signal_context)] ctxt: SignalContext<'_>,
|
||||
enabled: bool,
|
||||
) {
|
||||
let mut lock = self.0.lock().await;
|
||||
lock.config.off_when_unplugged = enabled;
|
||||
lock.config.write();
|
||||
Self::notify_device_state(&ctxt, DeviceState::from(&lock.config))
|
||||
.await
|
||||
.ok();
|
||||
}
|
||||
|
||||
/// Set if to turn the AniMe Matrix off when the laptop is suspended
|
||||
async fn set_off_when_suspended(
|
||||
&self,
|
||||
#[zbus(signal_context)] ctxt: SignalContext<'_>,
|
||||
enabled: bool,
|
||||
) {
|
||||
let mut lock = self.0.lock().await;
|
||||
lock.config.off_when_suspended = enabled;
|
||||
lock.config.write();
|
||||
Self::notify_device_state(&ctxt, DeviceState::from(&lock.config))
|
||||
.await
|
||||
.ok();
|
||||
}
|
||||
|
||||
/// Set if to turn the AniMe Matrix off when the lid is closed
|
||||
async fn set_off_when_lid_closed(
|
||||
&self,
|
||||
#[zbus(signal_context)] ctxt: SignalContext<'_>,
|
||||
enabled: bool,
|
||||
) {
|
||||
let mut lock = self.0.lock().await;
|
||||
lock.config.off_when_lid_closed = enabled;
|
||||
lock.config.write();
|
||||
Self::notify_device_state(&ctxt, DeviceState::from(&lock.config))
|
||||
.await
|
||||
.ok();
|
||||
}
|
||||
|
||||
/// The main loop is the base system set action if the user isn't running
|
||||
/// the user daemon
|
||||
async fn run_main_loop(&self, start: bool) {
|
||||
|
||||
@@ -2,18 +2,11 @@
|
||||
<node>
|
||||
<interface name="org.asuslinux.Daemon">
|
||||
<!--
|
||||
Writes a data stream of length. Will force system thread to exit until
|
||||
it is restarted
|
||||
Writes a data stream of length. Will force system thread to exit until it is restarted
|
||||
-->
|
||||
<method name="Write">
|
||||
<arg name="input" type="(ays)" direction="in"/>
|
||||
</method>
|
||||
<!--
|
||||
Set the global AniMe brightness
|
||||
-->
|
||||
<method name="SetImageBrightness">
|
||||
<arg name="bright" type="d" direction="in"/>
|
||||
</method>
|
||||
<!--
|
||||
Set base brightness level
|
||||
-->
|
||||
@@ -21,7 +14,8 @@
|
||||
<arg name="brightness" type="s" direction="in"/>
|
||||
</method>
|
||||
<!--
|
||||
Enable the builtin animations or not
|
||||
Enable the builtin animations or not. This is quivalent to "Powersave
|
||||
animations" in Armory crate
|
||||
-->
|
||||
<method name="SetBuiltinsEnabled">
|
||||
<arg name="enabled" type="b" direction="in"/>
|
||||
@@ -41,6 +35,24 @@
|
||||
<method name="SetEnableDisplay">
|
||||
<arg name="enabled" type="b" direction="in"/>
|
||||
</method>
|
||||
<!--
|
||||
Set if to turn the AniMe Matrix off when external power is unplugged
|
||||
-->
|
||||
<method name="SetOffWhenUnplugged">
|
||||
<arg name="enabled" type="b" direction="in"/>
|
||||
</method>
|
||||
<!--
|
||||
Set if to turn the AniMe Matrix off when the laptop is suspended
|
||||
-->
|
||||
<method name="SetOffWhenSuspended">
|
||||
<arg name="enabled" type="b" direction="in"/>
|
||||
</method>
|
||||
<!--
|
||||
Set if to turn the AniMe Matrix off when the lid is closed
|
||||
-->
|
||||
<method name="SetOffWhenLidClosed">
|
||||
<arg name="enabled" type="b" direction="in"/>
|
||||
</method>
|
||||
<!--
|
||||
The main loop is the base system set action if the user isn't running
|
||||
the user daemon
|
||||
@@ -52,14 +64,14 @@
|
||||
Get the device state as stored by asusd
|
||||
-->
|
||||
<method name="DeviceState">
|
||||
<arg type="bsb(ssss)" direction="out"/>
|
||||
<arg type="bsb(ssss)bbb" direction="out"/>
|
||||
</method>
|
||||
<!--
|
||||
Notify listeners of the status of AniMe LED power and factory
|
||||
system-status animations
|
||||
-->
|
||||
<signal name="NotifyDeviceState">
|
||||
<arg name="data" type="(bsb(ssss))"/>
|
||||
<arg name="data" type="(bsb(ssss)bbb)"/>
|
||||
</signal>
|
||||
</interface>
|
||||
</node>
|
||||
|
||||
@@ -4,6 +4,7 @@ use zbus::dbus_proxy;
|
||||
|
||||
#[dbus_proxy(
|
||||
interface = "org.asuslinux.Daemon",
|
||||
default_service = "org.asuslinux.Daemon",
|
||||
default_path = "/org/asuslinux/Anime"
|
||||
)]
|
||||
trait Anime {
|
||||
@@ -25,6 +26,15 @@ trait Anime {
|
||||
/// Set whether the AniMe is displaying images/data
|
||||
fn set_enable_display(&self, status: bool) -> zbus::Result<()>;
|
||||
|
||||
/// SetOffWhenLidClosed method
|
||||
fn set_off_when_lid_closed(&self, enabled: bool) -> zbus::Result<()>;
|
||||
|
||||
/// SetOffWhenSuspended method
|
||||
fn set_off_when_suspended(&self, enabled: bool) -> zbus::Result<()>;
|
||||
|
||||
/// SetOffWhenUnplugged method
|
||||
fn set_off_when_unplugged(&self, enabled: bool) -> zbus::Result<()>;
|
||||
|
||||
/// Writes a data stream of length. Will force system thread to exit until
|
||||
/// it is restarted
|
||||
fn write(&self, input: AnimeDataBuffer) -> zbus::Result<()>;
|
||||
@@ -32,8 +42,10 @@ trait Anime {
|
||||
// #[dbus_proxy(property)]
|
||||
fn device_state(&self) -> zbus::Result<AnimeDeviceState>;
|
||||
|
||||
/// Notify listeners of the status of AniMe LED power and factory
|
||||
/// system-status animations
|
||||
/// NotifyDeviceState signal
|
||||
#[dbus_proxy(signal)]
|
||||
fn device_state(&self, data: AnimeDeviceState) -> zbus::Result<()>;
|
||||
fn notify_device_state(
|
||||
&self,
|
||||
data: (bool, &str, bool, (&str, &str, &str, &str)),
|
||||
) -> zbus::Result<()>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user