mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Update readme, slash configs
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use log::error;
|
||||
use rog_platform::firmware_attributes::{
|
||||
AttrValue, Attribute, FirmwareAttribute, FirmwareAttributes,
|
||||
AttrValue, Attribute, FirmwareAttribute, FirmwareAttributes
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use zbus::zvariant::{ObjectPath, OwnedObjectPath, OwnedValue, Type, Value};
|
||||
@@ -14,7 +14,7 @@ const MOD_NAME: &str = "asus_armoury";
|
||||
#[derive(Debug, Default, Clone, Deserialize, Serialize, Type, Value, OwnedValue)]
|
||||
pub struct PossibleValues {
|
||||
strings: Vec<String>,
|
||||
nums: Vec<i32>,
|
||||
nums: Vec<i32>
|
||||
}
|
||||
|
||||
fn dbus_path_for_attr(attr_name: &str) -> OwnedObjectPath {
|
||||
@@ -87,7 +87,7 @@ impl AsusArmouryAttribute {
|
||||
async fn default_value(&self) -> i32 {
|
||||
match self.0.default_value() {
|
||||
AttrValue::Integer(i) => *i,
|
||||
_ => -1,
|
||||
_ => -1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ impl AsusArmouryAttribute {
|
||||
async fn min_value(&self) -> i32 {
|
||||
match self.0.min_value() {
|
||||
AttrValue::Integer(i) => *i,
|
||||
_ => -1,
|
||||
_ => -1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ impl AsusArmouryAttribute {
|
||||
async fn max_value(&self) -> i32 {
|
||||
match self.0.max_value() {
|
||||
AttrValue::Integer(i) => *i,
|
||||
_ => -1,
|
||||
_ => -1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ impl AsusArmouryAttribute {
|
||||
async fn scalar_increment(&self) -> i32 {
|
||||
match self.0.scalar_increment() {
|
||||
AttrValue::Integer(i) => *i,
|
||||
_ => -1,
|
||||
_ => -1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ impl AsusArmouryAttribute {
|
||||
async fn possible_values(&self) -> Vec<i32> {
|
||||
match self.0.possible_values() {
|
||||
AttrValue::EnumInt(i) => i.clone(),
|
||||
_ => Vec::default(),
|
||||
_ => Vec::default()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ impl AsusArmouryAttribute {
|
||||
return Ok(i);
|
||||
}
|
||||
Err(fdo::Error::Failed(
|
||||
"Could not read current value".to_string(),
|
||||
"Could not read current value".to_string()
|
||||
))
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ use config_traits::{StdConfig, StdConfigLoad};
|
||||
use rog_anime::error::AnimeError;
|
||||
use rog_anime::usb::Brightness;
|
||||
use rog_anime::{
|
||||
ActionData, ActionLoader, AnimTime, Animations, AnimeType, DeviceState, Fade, Vec2,
|
||||
ActionData, ActionLoader, AnimTime, Animations, AnimeType, DeviceState, Fade, Vec2
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@@ -15,14 +15,14 @@ pub struct AniMeConfigCached {
|
||||
pub system: Vec<ActionData>,
|
||||
pub boot: Vec<ActionData>,
|
||||
pub wake: Vec<ActionData>,
|
||||
pub shutdown: Vec<ActionData>,
|
||||
pub shutdown: Vec<ActionData>
|
||||
}
|
||||
|
||||
impl AniMeConfigCached {
|
||||
pub fn init_from_config(
|
||||
&mut self,
|
||||
config: &AniMeConfig,
|
||||
anime_type: AnimeType,
|
||||
anime_type: AnimeType
|
||||
) -> Result<(), AnimeError> {
|
||||
let mut sys = Vec::with_capacity(config.system.len());
|
||||
for ani in &config.system {
|
||||
@@ -68,7 +68,7 @@ pub struct AniMeConfig {
|
||||
pub off_when_suspended: bool,
|
||||
pub off_when_lid_closed: bool,
|
||||
pub brightness_on_battery: Brightness,
|
||||
pub builtin_anims: Animations,
|
||||
pub builtin_anims: Animations
|
||||
}
|
||||
|
||||
impl Default for AniMeConfig {
|
||||
@@ -87,7 +87,7 @@ impl Default for AniMeConfig {
|
||||
off_when_suspended: true,
|
||||
off_when_lid_closed: true,
|
||||
brightness_on_battery: Brightness::Low,
|
||||
builtin_anims: Animations::default(),
|
||||
builtin_anims: Animations::default()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -118,7 +118,7 @@ impl From<&AniMeConfig> for DeviceState {
|
||||
off_when_unplugged: config.off_when_unplugged,
|
||||
off_when_suspended: config.off_when_suspended,
|
||||
off_when_lid_closed: config.off_when_lid_closed,
|
||||
brightness_on_battery: config.brightness_on_battery,
|
||||
brightness_on_battery: config.brightness_on_battery
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -138,38 +138,44 @@ impl AniMeConfig {
|
||||
// create a default config here
|
||||
AniMeConfig {
|
||||
system: vec![],
|
||||
boot: vec![ActionLoader::ImageAnimation {
|
||||
file: "/usr/share/asusd/anime/custom/sonic-run.gif".into(),
|
||||
scale: 0.9,
|
||||
angle: 0.65,
|
||||
translation: Vec2::default(),
|
||||
brightness: 1.0,
|
||||
time: AnimTime::Fade(Fade::new(
|
||||
Duration::from_secs(2),
|
||||
Some(Duration::from_secs(2)),
|
||||
Duration::from_secs(2),
|
||||
)),
|
||||
}],
|
||||
wake: vec![ActionLoader::ImageAnimation {
|
||||
file: "/usr/share/asusd/anime/custom/sonic-run.gif".into(),
|
||||
scale: 0.9,
|
||||
angle: 0.65,
|
||||
translation: Vec2::default(),
|
||||
brightness: 1.0,
|
||||
time: AnimTime::Fade(Fade::new(
|
||||
Duration::from_secs(2),
|
||||
Some(Duration::from_secs(2)),
|
||||
Duration::from_secs(2),
|
||||
)),
|
||||
}],
|
||||
shutdown: vec![ActionLoader::ImageAnimation {
|
||||
file: "/usr/share/asusd/anime/custom/sonic-wait.gif".into(),
|
||||
scale: 0.9,
|
||||
angle: 0.0,
|
||||
translation: Vec2::new(3.0, 2.0),
|
||||
brightness: 1.0,
|
||||
time: AnimTime::Infinite,
|
||||
}],
|
||||
boot: vec![
|
||||
ActionLoader::ImageAnimation {
|
||||
file: "/usr/share/asusd/anime/custom/sonic-run.gif".into(),
|
||||
scale: 0.9,
|
||||
angle: 0.65,
|
||||
translation: Vec2::default(),
|
||||
brightness: 1.0,
|
||||
time: AnimTime::Fade(Fade::new(
|
||||
Duration::from_secs(2),
|
||||
Some(Duration::from_secs(2)),
|
||||
Duration::from_secs(2)
|
||||
))
|
||||
},
|
||||
],
|
||||
wake: vec![
|
||||
ActionLoader::ImageAnimation {
|
||||
file: "/usr/share/asusd/anime/custom/sonic-run.gif".into(),
|
||||
scale: 0.9,
|
||||
angle: 0.65,
|
||||
translation: Vec2::default(),
|
||||
brightness: 1.0,
|
||||
time: AnimTime::Fade(Fade::new(
|
||||
Duration::from_secs(2),
|
||||
Some(Duration::from_secs(2)),
|
||||
Duration::from_secs(2)
|
||||
))
|
||||
},
|
||||
],
|
||||
shutdown: vec![
|
||||
ActionLoader::ImageAnimation {
|
||||
file: "/usr/share/asusd/anime/custom/sonic-wait.gif".into(),
|
||||
scale: 0.9,
|
||||
angle: 0.0,
|
||||
translation: Vec2::new(3.0, 2.0),
|
||||
brightness: 1.0,
|
||||
time: AnimTime::Infinite
|
||||
},
|
||||
],
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ use config_traits::StdConfig;
|
||||
use log::{error, info, warn};
|
||||
use rog_anime::usb::{
|
||||
pkt_flush, pkt_set_brightness, pkt_set_enable_display, pkt_set_enable_powersave_anim,
|
||||
pkts_for_init, Brightness,
|
||||
pkts_for_init, Brightness
|
||||
};
|
||||
use rog_anime::{ActionData, AnimeDataBuffer, AnimePacketType};
|
||||
use rog_platform::hid_raw::HidRaw;
|
||||
@@ -30,14 +30,14 @@ pub struct AniMe {
|
||||
// set to force thread to exit
|
||||
thread_exit: Arc<AtomicBool>,
|
||||
// Set to false when the thread exits
|
||||
thread_running: Arc<AtomicBool>,
|
||||
thread_running: Arc<AtomicBool>
|
||||
}
|
||||
|
||||
impl AniMe {
|
||||
pub fn new(
|
||||
hid: Option<Arc<Mutex<HidRaw>>>,
|
||||
usb: Option<Arc<Mutex<USBRaw>>>,
|
||||
config: Arc<Mutex<AniMeConfig>>,
|
||||
config: Arc<Mutex<AniMeConfig>>
|
||||
) -> Self {
|
||||
Self {
|
||||
hid,
|
||||
@@ -45,7 +45,7 @@ impl AniMe {
|
||||
config,
|
||||
cache: AniMeConfigCached::default(),
|
||||
thread_exit: Arc::new(AtomicBool::new(false)),
|
||||
thread_running: Arc::new(AtomicBool::new(false)),
|
||||
thread_running: Arc::new(AtomicBool::new(false))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ impl AniMe {
|
||||
pub async fn set_builtins_enabled(
|
||||
&self,
|
||||
enabled: bool,
|
||||
bright: Brightness,
|
||||
bright: Brightness
|
||||
) -> Result<(), RogError> {
|
||||
self.write_bytes(&pkt_set_enable_powersave_anim(enabled))
|
||||
.await?;
|
||||
@@ -229,7 +229,7 @@ impl AniMe {
|
||||
}
|
||||
inner
|
||||
.write_bytes(&pkt_set_enable_powersave_anim(
|
||||
inner.config.lock().await.builtin_anims_enabled,
|
||||
inner.config.lock().await.builtin_anims_enabled
|
||||
))
|
||||
.await
|
||||
.map_err(|err| {
|
||||
|
||||
@@ -5,7 +5,7 @@ use log::{error, warn};
|
||||
use logind_zbus::manager::ManagerProxy;
|
||||
use rog_anime::usb::{
|
||||
pkt_set_brightness, pkt_set_builtin_animations, pkt_set_enable_display,
|
||||
pkt_set_enable_powersave_anim, Brightness,
|
||||
pkt_set_enable_powersave_anim, Brightness
|
||||
};
|
||||
use rog_anime::{Animations, AnimeDataBuffer, DeviceState};
|
||||
use zbus::object_server::SignalEmitter;
|
||||
@@ -41,7 +41,7 @@ impl AniMeZbus {
|
||||
pub async fn start_tasks(
|
||||
mut self,
|
||||
connection: &Connection,
|
||||
path: OwnedObjectPath,
|
||||
path: OwnedObjectPath
|
||||
) -> Result<(), RogError> {
|
||||
// let task = zbus.clone();
|
||||
self.reload()
|
||||
@@ -166,10 +166,7 @@ impl AniMeZbus {
|
||||
async fn set_builtin_animations(&self, settings: Animations) {
|
||||
self.0
|
||||
.write_bytes(&pkt_set_builtin_animations(
|
||||
settings.boot,
|
||||
settings.awake,
|
||||
settings.sleep,
|
||||
settings.shutdown,
|
||||
settings.boot, settings.awake, settings.sleep, settings.shutdown
|
||||
))
|
||||
.await
|
||||
.map_err(|err| {
|
||||
@@ -319,7 +316,7 @@ impl crate::CtrlTask for AniMeZbus {
|
||||
|
||||
inner
|
||||
.write_bytes(&pkt_set_enable_display(
|
||||
!(sleeping && config.off_when_suspended),
|
||||
!(sleeping && config.off_when_suspended)
|
||||
))
|
||||
.await
|
||||
.map_err(|err| {
|
||||
@@ -330,7 +327,7 @@ impl crate::CtrlTask for AniMeZbus {
|
||||
if config.builtin_anims_enabled {
|
||||
inner
|
||||
.write_bytes(&pkt_set_enable_powersave_anim(
|
||||
!(sleeping && config.off_when_suspended),
|
||||
!(sleeping && config.off_when_suspended)
|
||||
))
|
||||
.await
|
||||
.map_err(|err| {
|
||||
@@ -433,7 +430,7 @@ impl crate::CtrlTask for AniMeZbus {
|
||||
.ok();
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
)
|
||||
.await;
|
||||
|
||||
@@ -449,10 +446,7 @@ impl crate::Reloadable for AniMeZbus {
|
||||
if config.builtin_anims_enabled {
|
||||
self.0
|
||||
.write_bytes(&pkt_set_builtin_animations(
|
||||
anim.boot,
|
||||
anim.awake,
|
||||
anim.sleep,
|
||||
anim.shutdown,
|
||||
anim.boot, anim.awake, anim.sleep, anim.shutdown
|
||||
))
|
||||
.await?;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ use log::{debug, info, warn};
|
||||
use rog_aura::aura_detection::LedSupportData;
|
||||
use rog_aura::keyboard::LaptopAuraPower;
|
||||
use rog_aura::{
|
||||
AuraDeviceType, AuraEffect, AuraModeNum, AuraZone, Direction, LedBrightness, Speed, GRADIENT,
|
||||
AuraDeviceType, AuraEffect, AuraModeNum, AuraZone, Direction, LedBrightness, Speed, GRADIENT
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@@ -29,7 +29,7 @@ pub struct AuraConfig {
|
||||
pub multizone_on: bool,
|
||||
pub enabled: LaptopAuraPower,
|
||||
#[serde(skip)]
|
||||
pub per_key_mode_active: bool,
|
||||
pub per_key_mode_active: bool
|
||||
}
|
||||
|
||||
impl StdConfig for AuraConfig {
|
||||
@@ -74,7 +74,7 @@ impl AuraConfig {
|
||||
multizone: None,
|
||||
multizone_on: false,
|
||||
enabled,
|
||||
per_key_mode_active: false,
|
||||
per_key_mode_active: false
|
||||
};
|
||||
|
||||
for n in &config.support_data.basic_modes {
|
||||
@@ -92,7 +92,7 @@ impl AuraConfig {
|
||||
colour1: *GRADIENT.get(i).unwrap_or(&GRADIENT[0]),
|
||||
colour2: *GRADIENT.get(GRADIENT.len() - i).unwrap_or(&GRADIENT[6]),
|
||||
speed: Speed::Med,
|
||||
direction: Direction::Left,
|
||||
direction: Direction::Left
|
||||
});
|
||||
}
|
||||
if let Some(m) = config.multizone.as_mut() {
|
||||
@@ -156,7 +156,7 @@ impl AuraConfig {
|
||||
colour1: *GRADIENT.get(i).unwrap_or(&GRADIENT[0]),
|
||||
colour2: *GRADIENT.get(GRADIENT.len() - i).unwrap_or(&GRADIENT[6]),
|
||||
speed: Speed::Med,
|
||||
direction: Direction::Left,
|
||||
direction: Direction::Left
|
||||
});
|
||||
}
|
||||
if default.is_empty() {
|
||||
@@ -232,7 +232,7 @@ impl AuraConfig {
|
||||
mod tests {
|
||||
use rog_aura::keyboard::AuraPowerState;
|
||||
use rog_aura::{
|
||||
AuraEffect, AuraModeNum, AuraZone, Colour, Direction, LedBrightness, PowerZones, Speed,
|
||||
AuraEffect, AuraModeNum, AuraZone, Colour, Direction, LedBrightness, PowerZones, Speed
|
||||
};
|
||||
|
||||
use super::AuraConfig;
|
||||
@@ -246,7 +246,7 @@ mod tests {
|
||||
colour1: Colour {
|
||||
r: 0xff,
|
||||
g: 0x00,
|
||||
b: 0xff,
|
||||
b: 0xff
|
||||
},
|
||||
zone: AuraZone::Key1,
|
||||
..Default::default()
|
||||
@@ -259,7 +259,7 @@ mod tests {
|
||||
colour1: Colour {
|
||||
r: 0x00,
|
||||
g: 0xff,
|
||||
b: 0xff,
|
||||
b: 0xff
|
||||
},
|
||||
zone: AuraZone::Key2,
|
||||
..Default::default()
|
||||
@@ -270,7 +270,7 @@ mod tests {
|
||||
colour1: Colour {
|
||||
r: 0xff,
|
||||
g: 0xff,
|
||||
b: 0x00,
|
||||
b: 0x00
|
||||
},
|
||||
zone: AuraZone::Key3,
|
||||
..Default::default()
|
||||
@@ -281,7 +281,7 @@ mod tests {
|
||||
colour1: Colour {
|
||||
r: 0x00,
|
||||
g: 0xff,
|
||||
b: 0x00,
|
||||
b: 0x00
|
||||
},
|
||||
zone: AuraZone::Key4,
|
||||
..Default::default()
|
||||
@@ -294,38 +294,26 @@ mod tests {
|
||||
let res = config.multizone.unwrap();
|
||||
let sta = res.get(&AuraModeNum::Static).unwrap();
|
||||
assert_eq!(sta.len(), 4);
|
||||
assert_eq!(
|
||||
sta[0].colour1,
|
||||
Colour {
|
||||
r: 0xff,
|
||||
g: 0x00,
|
||||
b: 0xff
|
||||
}
|
||||
);
|
||||
assert_eq!(
|
||||
sta[1].colour1,
|
||||
Colour {
|
||||
r: 0x00,
|
||||
g: 0xff,
|
||||
b: 0xff
|
||||
}
|
||||
);
|
||||
assert_eq!(
|
||||
sta[2].colour1,
|
||||
Colour {
|
||||
r: 0xff,
|
||||
g: 0xff,
|
||||
b: 0x00
|
||||
}
|
||||
);
|
||||
assert_eq!(
|
||||
sta[3].colour1,
|
||||
Colour {
|
||||
r: 0x00,
|
||||
g: 0xff,
|
||||
b: 0x00
|
||||
}
|
||||
);
|
||||
assert_eq!(sta[0].colour1, Colour {
|
||||
r: 0xff,
|
||||
g: 0x00,
|
||||
b: 0xff
|
||||
});
|
||||
assert_eq!(sta[1].colour1, Colour {
|
||||
r: 0x00,
|
||||
g: 0xff,
|
||||
b: 0xff
|
||||
});
|
||||
assert_eq!(sta[2].colour1, Colour {
|
||||
r: 0xff,
|
||||
g: 0xff,
|
||||
b: 0x00
|
||||
});
|
||||
assert_eq!(sta[3].colour1, Colour {
|
||||
r: 0x00,
|
||||
g: 0xff,
|
||||
b: 0x00
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -383,28 +371,22 @@ mod tests {
|
||||
|
||||
assert_eq!(config.brightness, LedBrightness::Med);
|
||||
assert_eq!(config.builtins.len(), 5);
|
||||
assert_eq!(
|
||||
config.builtins.first_entry().unwrap().get(),
|
||||
&AuraEffect {
|
||||
mode: AuraModeNum::Static,
|
||||
zone: AuraZone::None,
|
||||
colour1: Colour { r: 166, g: 0, b: 0 },
|
||||
colour2: Colour { r: 0, g: 0, b: 0 },
|
||||
speed: Speed::Med,
|
||||
direction: Direction::Right
|
||||
}
|
||||
);
|
||||
assert_eq!(config.builtins.first_entry().unwrap().get(), &AuraEffect {
|
||||
mode: AuraModeNum::Static,
|
||||
zone: AuraZone::None,
|
||||
colour1: Colour { r: 166, g: 0, b: 0 },
|
||||
colour2: Colour { r: 0, g: 0, b: 0 },
|
||||
speed: Speed::Med,
|
||||
direction: Direction::Right
|
||||
});
|
||||
assert_eq!(config.enabled.states.len(), 1);
|
||||
assert_eq!(
|
||||
config.enabled.states[0],
|
||||
AuraPowerState {
|
||||
zone: PowerZones::KeyboardAndLightbar,
|
||||
boot: true,
|
||||
awake: true,
|
||||
sleep: true,
|
||||
shutdown: true
|
||||
}
|
||||
);
|
||||
assert_eq!(config.enabled.states[0], AuraPowerState {
|
||||
zone: PowerZones::KeyboardAndLightbar,
|
||||
boot: true,
|
||||
awake: true,
|
||||
sleep: true,
|
||||
shutdown: true
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -414,27 +396,21 @@ mod tests {
|
||||
|
||||
assert_eq!(config.brightness, LedBrightness::Med);
|
||||
assert_eq!(config.builtins.len(), 12);
|
||||
assert_eq!(
|
||||
config.builtins.first_entry().unwrap().get(),
|
||||
&AuraEffect {
|
||||
mode: AuraModeNum::Static,
|
||||
zone: AuraZone::None,
|
||||
colour1: Colour { r: 166, g: 0, b: 0 },
|
||||
colour2: Colour { r: 0, g: 0, b: 0 },
|
||||
speed: Speed::Med,
|
||||
direction: Direction::Right
|
||||
}
|
||||
);
|
||||
assert_eq!(config.builtins.first_entry().unwrap().get(), &AuraEffect {
|
||||
mode: AuraModeNum::Static,
|
||||
zone: AuraZone::None,
|
||||
colour1: Colour { r: 166, g: 0, b: 0 },
|
||||
colour2: Colour { r: 0, g: 0, b: 0 },
|
||||
speed: Speed::Med,
|
||||
direction: Direction::Right
|
||||
});
|
||||
assert_eq!(config.enabled.states.len(), 4);
|
||||
assert_eq!(
|
||||
config.enabled.states[0],
|
||||
AuraPowerState {
|
||||
zone: PowerZones::Keyboard,
|
||||
boot: true,
|
||||
awake: true,
|
||||
sleep: true,
|
||||
shutdown: true
|
||||
}
|
||||
);
|
||||
assert_eq!(config.enabled.states[0], AuraPowerState {
|
||||
zone: PowerZones::Keyboard,
|
||||
boot: true,
|
||||
awake: true,
|
||||
sleep: true,
|
||||
shutdown: true
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ pub mod trait_impls;
|
||||
pub struct Aura {
|
||||
pub hid: Option<Arc<Mutex<HidRaw>>>,
|
||||
pub backlight: Option<Arc<Mutex<KeyboardBacklight>>>,
|
||||
pub config: Arc<Mutex<AuraConfig>>,
|
||||
pub config: Arc<Mutex<AuraConfig>>
|
||||
}
|
||||
|
||||
impl Aura {
|
||||
@@ -91,17 +91,13 @@ impl Aura {
|
||||
pub async fn write_effect_and_apply(
|
||||
&self,
|
||||
dev_type: AuraDeviceType,
|
||||
mode: &AuraEffect,
|
||||
mode: &AuraEffect
|
||||
) -> Result<(), RogError> {
|
||||
if matches!(dev_type, AuraDeviceType::LaptopKeyboardTuf) {
|
||||
if let Some(platform) = &self.backlight {
|
||||
let buf = [
|
||||
1,
|
||||
mode.mode as u8,
|
||||
mode.colour1.r,
|
||||
mode.colour1.g,
|
||||
mode.colour1.b,
|
||||
mode.speed as u8,
|
||||
1, mode.mode as u8, mode.colour1.r, mode.colour1.g, mode.colour1.b,
|
||||
mode.speed as u8
|
||||
];
|
||||
platform.lock().await.set_kbd_rgb_mode(&buf)?;
|
||||
}
|
||||
@@ -125,7 +121,7 @@ impl Aura {
|
||||
return Ok(());
|
||||
}
|
||||
Err(RogError::MissingFunction(
|
||||
"No LED backlight control available".to_string(),
|
||||
"No LED backlight control available".to_string()
|
||||
))
|
||||
}
|
||||
|
||||
@@ -142,14 +138,24 @@ impl Aura {
|
||||
let hid_raw = hid_raw.lock().await;
|
||||
if let Some(p) = config.enabled.states.first() {
|
||||
if p.zone == PowerZones::Ally {
|
||||
let msg = [0x5d, 0xd1, 0x09, 0x01, p.new_to_byte() as u8, 0x0, 0x0];
|
||||
let msg = [
|
||||
0x5d,
|
||||
0xd1,
|
||||
0x09,
|
||||
0x01,
|
||||
p.new_to_byte() as u8,
|
||||
0x0,
|
||||
0x0
|
||||
];
|
||||
hid_raw.write_bytes(&msg)?;
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
|
||||
let bytes = config.enabled.to_bytes(config.led_type);
|
||||
let msg = [0x5d, 0xbd, 0x01, bytes[0], bytes[1], bytes[2], bytes[3]];
|
||||
let msg = [
|
||||
0x5d, 0xbd, 0x01, bytes[0], bytes[1], bytes[2], bytes[3]
|
||||
];
|
||||
hid_raw.write_bytes(&msg)?;
|
||||
}
|
||||
Ok(())
|
||||
@@ -161,7 +167,7 @@ impl Aura {
|
||||
pub async fn write_effect_block(
|
||||
&self,
|
||||
config: &mut AuraConfig,
|
||||
effect: &AuraLaptopUsbPackets,
|
||||
effect: &AuraLaptopUsbPackets
|
||||
) -> Result<(), RogError> {
|
||||
if config.brightness == LedBrightness::Off {
|
||||
config.brightness = LedBrightness::Med;
|
||||
@@ -194,7 +200,9 @@ impl Aura {
|
||||
let r = row[9];
|
||||
let g = row[10];
|
||||
let b = row[11];
|
||||
tuf.lock().await.set_kbd_rgb_mode(&[0, 0, r, g, b, 0])?;
|
||||
tuf.lock().await.set_kbd_rgb_mode(&[
|
||||
0, 0, r, g, b, 0
|
||||
])?;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -206,7 +214,9 @@ impl Aura {
|
||||
if let Some(hid_raw) = &self.hid {
|
||||
let mut config = self.config.lock().await;
|
||||
if config.ally_fix.is_none() {
|
||||
let msg = [0x5d, 0xbd, 0x01, 0xff, 0xff, 0xff, 0xff];
|
||||
let msg = [
|
||||
0x5d, 0xbd, 0x01, 0xff, 0xff, 0xff, 0xff
|
||||
];
|
||||
hid_raw.lock().await.write_bytes(&msg)?;
|
||||
info!("Reset Ally power settings to base");
|
||||
config.ally_fix = Some(true);
|
||||
|
||||
@@ -28,7 +28,7 @@ impl AuraZbus {
|
||||
mut self,
|
||||
connection: &Connection,
|
||||
// _signal_ctx: SignalEmitter<'static>,
|
||||
path: OwnedObjectPath,
|
||||
path: OwnedObjectPath
|
||||
) -> Result<(), RogError> {
|
||||
// let task = zbus.clone();
|
||||
// let signal_ctx = signal_ctx.clone();
|
||||
@@ -144,7 +144,7 @@ impl AuraZbus {
|
||||
let mode = config.current_mode;
|
||||
match config.builtins.get(&mode) {
|
||||
Some(effect) => Ok(effect.clone()),
|
||||
None => Err(ZbErr::Failed("Could not get the current effect".into())),
|
||||
None => Err(ZbErr::Failed("Could not get the current effect".into()))
|
||||
}
|
||||
} else {
|
||||
Err(ZbErr::Failed("Aura control couldn't lock self".to_string()))
|
||||
@@ -297,7 +297,7 @@ impl CtrlTask for AuraZbus {
|
||||
move |_power_plugged| {
|
||||
// power change
|
||||
async move {}
|
||||
},
|
||||
}
|
||||
)
|
||||
.await;
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ fn dbus_path_for_dev(parent: &Device) -> Option<OwnedObjectPath> {
|
||||
if let Some(filename) = filename_partial(parent) {
|
||||
return Some(
|
||||
ObjectPath::from_str_unchecked(&format!("{ASUS_ZBUS_PATH}/{MOD_NAME}/{filename}"))
|
||||
.into(),
|
||||
.into()
|
||||
);
|
||||
}
|
||||
None
|
||||
@@ -91,17 +91,17 @@ fn dev_prop_matches(dev: &Device, prop: &str, value: &str) -> bool {
|
||||
/// required.
|
||||
pub struct AsusDevice {
|
||||
device: DeviceHandle,
|
||||
dbus_path: OwnedObjectPath,
|
||||
dbus_path: OwnedObjectPath
|
||||
}
|
||||
|
||||
pub struct DeviceManager {
|
||||
_dbus_connection: Connection,
|
||||
_dbus_connection: Connection
|
||||
}
|
||||
|
||||
impl DeviceManager {
|
||||
async fn init_hid_devices(
|
||||
connection: &Connection,
|
||||
device: Device,
|
||||
device: Device
|
||||
) -> Result<Vec<AsusDevice>, RogError> {
|
||||
let mut devices = Vec::new();
|
||||
if let Some(usb_device) = device.parent_with_subsystem_devtype("usb", "usb_device")? {
|
||||
@@ -122,7 +122,7 @@ impl DeviceManager {
|
||||
// SLASH DEVICE
|
||||
if let Ok(dev_type) = DeviceHandle::new_slash_hid(
|
||||
dev.clone(),
|
||||
usb_id.to_str().unwrap_or_default(),
|
||||
usb_id.to_str().unwrap_or_default()
|
||||
)
|
||||
.await
|
||||
{
|
||||
@@ -133,14 +133,14 @@ impl DeviceManager {
|
||||
ctrl.start_tasks(connection, path.clone()).await.unwrap();
|
||||
devices.push(AsusDevice {
|
||||
device: dev_type,
|
||||
dbus_path: path,
|
||||
dbus_path: path
|
||||
});
|
||||
}
|
||||
}
|
||||
// ANIME MATRIX DEVICE
|
||||
if let Ok(dev_type) = DeviceHandle::maybe_anime_hid(
|
||||
dev.clone(),
|
||||
usb_id.to_str().unwrap_or_default(),
|
||||
usb_id.to_str().unwrap_or_default()
|
||||
)
|
||||
.await
|
||||
{
|
||||
@@ -151,14 +151,14 @@ impl DeviceManager {
|
||||
ctrl.start_tasks(connection, path.clone()).await.unwrap();
|
||||
devices.push(AsusDevice {
|
||||
device: dev_type,
|
||||
dbus_path: path,
|
||||
dbus_path: path
|
||||
});
|
||||
}
|
||||
}
|
||||
// AURA LAPTOP DEVICE
|
||||
if let Ok(dev_type) = DeviceHandle::maybe_laptop_aura(
|
||||
Some(dev),
|
||||
usb_id.to_str().unwrap_or_default(),
|
||||
usb_id.to_str().unwrap_or_default()
|
||||
)
|
||||
.await
|
||||
{
|
||||
@@ -169,7 +169,7 @@ impl DeviceManager {
|
||||
ctrl.start_tasks(connection, path.clone()).await.unwrap();
|
||||
devices.push(AsusDevice {
|
||||
device: dev_type,
|
||||
dbus_path: path,
|
||||
dbus_path: path
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -209,7 +209,7 @@ impl DeviceManager {
|
||||
async fn init_scsi(
|
||||
connection: &Connection,
|
||||
device: &Device,
|
||||
path: OwnedObjectPath,
|
||||
path: OwnedObjectPath
|
||||
) -> Option<AsusDevice> {
|
||||
// "ID_MODEL_ID" "1932"
|
||||
// "ID_VENDOR_ID" "0b05"
|
||||
@@ -227,7 +227,7 @@ impl DeviceManager {
|
||||
ctrl.start_tasks(connection, path.clone()).await.unwrap();
|
||||
return Some(AsusDevice {
|
||||
device: dev_type,
|
||||
dbus_path: path,
|
||||
dbus_path: path
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -305,7 +305,7 @@ impl DeviceManager {
|
||||
ctrl.start_tasks(connection, path.clone()).await.unwrap();
|
||||
devices.push(AsusDevice {
|
||||
device: dev_type,
|
||||
dbus_path: path,
|
||||
dbus_path: path
|
||||
});
|
||||
}
|
||||
} else {
|
||||
@@ -322,7 +322,7 @@ impl DeviceManager {
|
||||
ctrl.start_tasks(connection, path.clone()).await.unwrap();
|
||||
devices.push(AsusDevice {
|
||||
device: dev_type,
|
||||
dbus_path: path,
|
||||
dbus_path: path
|
||||
});
|
||||
}
|
||||
} else {
|
||||
@@ -348,7 +348,7 @@ impl DeviceManager {
|
||||
ctrl.start_tasks(connection, path.clone()).await.unwrap();
|
||||
devices.push(AsusDevice {
|
||||
device: dev_type,
|
||||
dbus_path: path,
|
||||
dbus_path: path
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -366,7 +366,7 @@ impl DeviceManager {
|
||||
let conn_copy = connection.clone();
|
||||
let devices = Arc::new(Mutex::new(Self::find_all_devices(&conn_copy).await));
|
||||
let manager = Self {
|
||||
_dbus_connection: connection,
|
||||
_dbus_connection: connection
|
||||
};
|
||||
|
||||
// TODO: The /sysfs/ LEDs don't cause events, so they need to be manually
|
||||
@@ -500,7 +500,7 @@ impl DeviceManager {
|
||||
.remove::<ScsiZbus, _>(&path)
|
||||
.await?
|
||||
}
|
||||
_ => todo!(),
|
||||
_ => todo!()
|
||||
};
|
||||
info!("AuraManager removed: {path:?}, {res}");
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ pub struct ScsiConfig {
|
||||
pub dev_type: AuraDeviceType,
|
||||
pub enabled: bool,
|
||||
pub current_mode: AuraMode,
|
||||
pub modes: BTreeMap<AuraMode, AuraEffect>,
|
||||
pub modes: BTreeMap<AuraMode, AuraEffect>
|
||||
}
|
||||
|
||||
impl ScsiConfig {
|
||||
@@ -38,61 +38,61 @@ impl Default for ScsiConfig {
|
||||
(AuraMode::Off, AuraEffect::default_with_mode(AuraMode::Off)),
|
||||
(
|
||||
AuraMode::Static,
|
||||
AuraEffect::default_with_mode(AuraMode::Static),
|
||||
AuraEffect::default_with_mode(AuraMode::Static)
|
||||
),
|
||||
(
|
||||
AuraMode::Breathe,
|
||||
AuraEffect::default_with_mode(AuraMode::Breathe),
|
||||
AuraEffect::default_with_mode(AuraMode::Breathe)
|
||||
),
|
||||
(
|
||||
AuraMode::Flashing,
|
||||
AuraEffect::default_with_mode(AuraMode::Flashing),
|
||||
AuraEffect::default_with_mode(AuraMode::Flashing)
|
||||
),
|
||||
(
|
||||
AuraMode::RainbowCycle,
|
||||
AuraEffect::default_with_mode(AuraMode::RainbowCycle),
|
||||
AuraEffect::default_with_mode(AuraMode::RainbowCycle)
|
||||
),
|
||||
(
|
||||
AuraMode::RainbowWave,
|
||||
AuraEffect::default_with_mode(AuraMode::RainbowWave),
|
||||
AuraEffect::default_with_mode(AuraMode::RainbowWave)
|
||||
),
|
||||
(
|
||||
AuraMode::RainbowCycleBreathe,
|
||||
AuraEffect::default_with_mode(AuraMode::RainbowCycleBreathe),
|
||||
AuraEffect::default_with_mode(AuraMode::RainbowCycleBreathe)
|
||||
),
|
||||
(
|
||||
AuraMode::ChaseFade,
|
||||
AuraEffect::default_with_mode(AuraMode::ChaseFade),
|
||||
AuraEffect::default_with_mode(AuraMode::ChaseFade)
|
||||
),
|
||||
(
|
||||
AuraMode::RainbowCycleChaseFade,
|
||||
AuraEffect::default_with_mode(AuraMode::RainbowCycleChaseFade),
|
||||
AuraEffect::default_with_mode(AuraMode::RainbowCycleChaseFade)
|
||||
),
|
||||
(
|
||||
AuraMode::Chase,
|
||||
AuraEffect::default_with_mode(AuraMode::Chase),
|
||||
AuraEffect::default_with_mode(AuraMode::Chase)
|
||||
),
|
||||
(
|
||||
AuraMode::RainbowCycleChase,
|
||||
AuraEffect::default_with_mode(AuraMode::RainbowCycleChase),
|
||||
AuraEffect::default_with_mode(AuraMode::RainbowCycleChase)
|
||||
),
|
||||
(
|
||||
AuraMode::RainbowCycleWave,
|
||||
AuraEffect::default_with_mode(AuraMode::RainbowCycleWave),
|
||||
AuraEffect::default_with_mode(AuraMode::RainbowCycleWave)
|
||||
),
|
||||
(
|
||||
AuraMode::RainbowPulseChase,
|
||||
AuraEffect::default_with_mode(AuraMode::RainbowPulseChase),
|
||||
AuraEffect::default_with_mode(AuraMode::RainbowPulseChase)
|
||||
),
|
||||
(
|
||||
AuraMode::RandomFlicker,
|
||||
AuraEffect::default_with_mode(AuraMode::RandomFlicker),
|
||||
AuraEffect::default_with_mode(AuraMode::RandomFlicker)
|
||||
),
|
||||
(
|
||||
AuraMode::DoubleFade,
|
||||
AuraEffect::default_with_mode(AuraMode::DoubleFade),
|
||||
),
|
||||
]),
|
||||
AuraEffect::default_with_mode(AuraMode::DoubleFade)
|
||||
)
|
||||
])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ pub mod trait_impls;
|
||||
#[derive(Clone)]
|
||||
pub struct ScsiAura {
|
||||
device: Arc<Mutex<Device>>,
|
||||
config: Arc<Mutex<ScsiConfig>>,
|
||||
config: Arc<Mutex<ScsiConfig>>
|
||||
}
|
||||
|
||||
impl ScsiAura {
|
||||
|
||||
@@ -22,7 +22,7 @@ impl ScsiZbus {
|
||||
pub async fn start_tasks(
|
||||
self,
|
||||
connection: &Connection,
|
||||
path: OwnedObjectPath,
|
||||
path: OwnedObjectPath
|
||||
) -> Result<(), RogError> {
|
||||
connection
|
||||
.object_server()
|
||||
@@ -87,7 +87,7 @@ impl ScsiZbus {
|
||||
let mode = config.current_mode;
|
||||
match config.modes.get(&mode) {
|
||||
Some(effect) => Ok(effect.clone()),
|
||||
None => Err(ZbErr::Failed("Could not get the current effect".into())),
|
||||
None => Err(ZbErr::Failed("Could not get the current effect".into()))
|
||||
}
|
||||
} else {
|
||||
Err(ZbErr::Failed("Aura control couldn't lock self".to_string()))
|
||||
|
||||
@@ -9,20 +9,30 @@ const CONFIG_FILE: &str = "slash.ron";
|
||||
pub struct SlashConfig {
|
||||
#[serde(skip)]
|
||||
pub slash_type: SlashType,
|
||||
pub slash_enabled: bool,
|
||||
pub slash_brightness: u8,
|
||||
pub slash_interval: u8,
|
||||
pub slash_mode: SlashMode,
|
||||
pub enabled: bool,
|
||||
pub brightness: u8,
|
||||
pub display_interval: u8,
|
||||
pub display_mode: SlashMode,
|
||||
pub show_on_boot: bool,
|
||||
pub show_on_shutdown: bool,
|
||||
pub show_on_sleep: bool,
|
||||
pub show_on_battery: bool,
|
||||
pub show_battery_warning: bool
|
||||
}
|
||||
|
||||
impl Default for SlashConfig {
|
||||
fn default() -> Self {
|
||||
SlashConfig {
|
||||
slash_enabled: true,
|
||||
slash_brightness: 255,
|
||||
slash_interval: 0,
|
||||
slash_mode: SlashMode::Bounce,
|
||||
enabled: true,
|
||||
brightness: 255,
|
||||
display_interval: 0,
|
||||
display_mode: SlashMode::Bounce,
|
||||
slash_type: SlashType::Unsupported,
|
||||
show_on_boot: true,
|
||||
show_on_shutdown: true,
|
||||
show_on_sleep: true,
|
||||
show_on_battery: true,
|
||||
show_battery_warning: true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -45,10 +55,10 @@ impl StdConfigLoad for SlashConfig {}
|
||||
impl From<&SlashConfig> for DeviceState {
|
||||
fn from(config: &SlashConfig) -> Self {
|
||||
DeviceState {
|
||||
slash_enabled: config.slash_enabled,
|
||||
slash_brightness: config.slash_brightness,
|
||||
slash_interval: config.slash_interval,
|
||||
slash_mode: config.slash_mode,
|
||||
slash_enabled: config.enabled,
|
||||
slash_brightness: config.brightness,
|
||||
slash_interval: config.display_interval,
|
||||
slash_mode: config.display_mode
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::sync::Arc;
|
||||
use config::SlashConfig;
|
||||
use rog_platform::hid_raw::HidRaw;
|
||||
use rog_platform::usb_raw::USBRaw;
|
||||
use rog_slash::usb::{pkt_set_mode, pkt_set_options, pkts_for_init};
|
||||
use rog_slash::usb::{get_options_packet, pkt_set_mode, pkts_for_init};
|
||||
use rog_slash::SlashType;
|
||||
use tokio::sync::{Mutex, MutexGuard};
|
||||
|
||||
@@ -16,14 +16,14 @@ pub mod trait_impls;
|
||||
pub struct Slash {
|
||||
hid: Option<Arc<Mutex<HidRaw>>>,
|
||||
usb: Option<Arc<Mutex<USBRaw>>>,
|
||||
config: Arc<Mutex<SlashConfig>>,
|
||||
config: Arc<Mutex<SlashConfig>>
|
||||
}
|
||||
|
||||
impl Slash {
|
||||
pub fn new(
|
||||
hid: Option<Arc<Mutex<HidRaw>>>,
|
||||
usb: Option<Arc<Mutex<USBRaw>>>,
|
||||
config: Arc<Mutex<SlashConfig>>,
|
||||
config: Arc<Mutex<SlashConfig>>
|
||||
) -> Self {
|
||||
Self { hid, usb, config }
|
||||
}
|
||||
@@ -53,15 +53,15 @@ impl Slash {
|
||||
}
|
||||
|
||||
// Apply config upon initialization
|
||||
let option_packets = pkt_set_options(
|
||||
let option_packets = get_options_packet(
|
||||
config.slash_type,
|
||||
config.slash_enabled,
|
||||
config.slash_brightness,
|
||||
config.slash_interval,
|
||||
config.enabled,
|
||||
config.brightness,
|
||||
config.display_interval
|
||||
);
|
||||
self.write_bytes(&option_packets).await?;
|
||||
|
||||
let mode_packets = pkt_set_mode(config.slash_type, config.slash_mode);
|
||||
let mode_packets = pkt_set_mode(config.slash_type, config.display_mode);
|
||||
// self.node.write_bytes(&mode_packets[0])?;
|
||||
self.write_bytes(&mode_packets[1]).await?;
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
use config_traits::StdConfig;
|
||||
use log::{debug, error, warn};
|
||||
use rog_slash::usb::{pkt_save, pkt_set_mode, pkt_set_options};
|
||||
use rog_slash::usb::{
|
||||
get_battery_saver_packet, get_boot_packet, get_low_battery_packet, get_options_packet,
|
||||
get_shutdown_packet, get_sleep_packet, pkt_save, pkt_set_mode
|
||||
};
|
||||
use rog_slash::{DeviceState, SlashMode};
|
||||
use zbus::zvariant::OwnedObjectPath;
|
||||
use zbus::{interface, Connection};
|
||||
@@ -20,7 +23,7 @@ impl SlashZbus {
|
||||
pub async fn start_tasks(
|
||||
mut self,
|
||||
connection: &Connection,
|
||||
path: OwnedObjectPath,
|
||||
path: OwnedObjectPath
|
||||
) -> Result<(), RogError> {
|
||||
// let task = zbus.clone();
|
||||
self.reload()
|
||||
@@ -42,24 +45,24 @@ impl SlashZbus {
|
||||
#[zbus(property)]
|
||||
async fn enabled(&self) -> bool {
|
||||
let lock = self.0.lock_config().await;
|
||||
lock.slash_enabled
|
||||
lock.enabled
|
||||
}
|
||||
|
||||
/// Set enabled true or false
|
||||
#[zbus(property)]
|
||||
async fn set_enabled(&self, enabled: bool) {
|
||||
let mut config = self.0.lock_config().await;
|
||||
let brightness = if enabled && config.slash_brightness == 0 {
|
||||
let brightness = if enabled && config.brightness == 0 {
|
||||
0x88
|
||||
} else {
|
||||
config.slash_brightness
|
||||
config.brightness
|
||||
};
|
||||
self.0
|
||||
.write_bytes(&pkt_set_options(
|
||||
.write_bytes(&get_options_packet(
|
||||
config.slash_type,
|
||||
enabled,
|
||||
brightness,
|
||||
config.slash_interval,
|
||||
config.display_interval
|
||||
))
|
||||
.await
|
||||
.map_err(|err| {
|
||||
@@ -67,8 +70,8 @@ impl SlashZbus {
|
||||
})
|
||||
.ok();
|
||||
|
||||
config.slash_enabled = enabled;
|
||||
config.slash_brightness = brightness;
|
||||
config.enabled = enabled;
|
||||
config.brightness = brightness;
|
||||
config.write();
|
||||
}
|
||||
|
||||
@@ -76,7 +79,7 @@ impl SlashZbus {
|
||||
#[zbus(property)]
|
||||
async fn brightness(&self) -> u8 {
|
||||
let config = self.0.lock_config().await;
|
||||
config.slash_brightness
|
||||
config.brightness
|
||||
}
|
||||
|
||||
/// Set brightness level
|
||||
@@ -85,11 +88,11 @@ impl SlashZbus {
|
||||
let mut config = self.0.lock_config().await;
|
||||
let enabled = brightness > 0;
|
||||
self.0
|
||||
.write_bytes(&pkt_set_options(
|
||||
.write_bytes(&get_options_packet(
|
||||
config.slash_type,
|
||||
enabled,
|
||||
brightness,
|
||||
config.slash_interval,
|
||||
config.display_interval
|
||||
))
|
||||
.await
|
||||
.map_err(|err| {
|
||||
@@ -97,15 +100,15 @@ impl SlashZbus {
|
||||
})
|
||||
.ok();
|
||||
|
||||
config.slash_enabled = enabled;
|
||||
config.slash_brightness = brightness;
|
||||
config.enabled = enabled;
|
||||
config.brightness = brightness;
|
||||
config.write();
|
||||
}
|
||||
|
||||
#[zbus(property)]
|
||||
async fn interval(&self) -> u8 {
|
||||
let config = self.0.lock_config().await;
|
||||
config.slash_interval
|
||||
config.display_interval
|
||||
}
|
||||
|
||||
/// Set interval between slash animations (0-255)
|
||||
@@ -113,11 +116,8 @@ impl SlashZbus {
|
||||
async fn set_interval(&self, interval: u8) {
|
||||
let mut config = self.0.lock_config().await;
|
||||
self.0
|
||||
.write_bytes(&pkt_set_options(
|
||||
config.slash_type,
|
||||
config.slash_enabled,
|
||||
config.slash_brightness,
|
||||
interval,
|
||||
.write_bytes(&get_options_packet(
|
||||
config.slash_type, config.enabled, config.brightness, interval
|
||||
))
|
||||
.await
|
||||
.map_err(|err| {
|
||||
@@ -125,40 +125,29 @@ impl SlashZbus {
|
||||
})
|
||||
.ok();
|
||||
|
||||
config.slash_interval = interval;
|
||||
config.display_interval = interval;
|
||||
config.write();
|
||||
}
|
||||
|
||||
#[zbus(property)]
|
||||
async fn slash_mode(&self) -> u8 {
|
||||
async fn mode(&self) -> zbus::fdo::Result<u8> {
|
||||
let config = self.0.lock_config().await;
|
||||
config.slash_interval
|
||||
Ok(config.display_interval)
|
||||
}
|
||||
|
||||
/// Set interval between slash animations (0-255)
|
||||
#[zbus(property)]
|
||||
async fn set_slash_mode(&self, slash_mode: SlashMode) {
|
||||
async fn set_mode(&self, mode: SlashMode) -> zbus::Result<()> {
|
||||
let mut config = self.0.lock_config().await;
|
||||
|
||||
let command_packets = pkt_set_mode(config.slash_type, slash_mode);
|
||||
let command_packets = pkt_set_mode(config.slash_type, mode);
|
||||
// self.node.write_bytes(&command_packets[0])?;
|
||||
self.0
|
||||
.write_bytes(&command_packets[1])
|
||||
.await
|
||||
.map_err(|err| {
|
||||
warn!("ctrl_slash::set_options {}", err);
|
||||
})
|
||||
.ok();
|
||||
self.0
|
||||
.write_bytes(&pkt_save(config.slash_type))
|
||||
.await
|
||||
.map_err(|err| {
|
||||
warn!("ctrl_slash::set_options {}", err);
|
||||
})
|
||||
.ok();
|
||||
self.0.write_bytes(&command_packets[1]).await?;
|
||||
self.0.write_bytes(&pkt_save(config.slash_type)).await?;
|
||||
|
||||
config.slash_mode = slash_mode;
|
||||
config.display_mode = mode;
|
||||
config.write();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Get the device state as stored by asusd
|
||||
@@ -167,6 +156,91 @@ impl SlashZbus {
|
||||
let config = self.0.lock_config().await;
|
||||
DeviceState::from(&*config)
|
||||
}
|
||||
|
||||
#[zbus(property)]
|
||||
async fn show_on_boot(&self) -> zbus::fdo::Result<bool> {
|
||||
let config = self.0.lock_config().await;
|
||||
Ok(config.show_on_boot)
|
||||
}
|
||||
|
||||
#[zbus(property)]
|
||||
async fn set_show_on_boot(&self, enable: bool) -> zbus::Result<()> {
|
||||
let mut config = self.0.lock_config().await;
|
||||
self.0
|
||||
.write_bytes(&get_boot_packet(config.slash_type, enable))
|
||||
.await?;
|
||||
config.show_on_boot = enable;
|
||||
config.write();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[zbus(property)]
|
||||
async fn show_on_sleep(&self) -> zbus::fdo::Result<bool> {
|
||||
let config = self.0.lock_config().await;
|
||||
Ok(config.show_on_sleep)
|
||||
}
|
||||
|
||||
#[zbus(property)]
|
||||
async fn set_show_on_sleep(&self, enable: bool) -> zbus::Result<()> {
|
||||
let mut config = self.0.lock_config().await;
|
||||
self.0
|
||||
.write_bytes(&get_sleep_packet(config.slash_type, enable))
|
||||
.await?;
|
||||
config.show_on_sleep = enable;
|
||||
config.write();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[zbus(property)]
|
||||
async fn show_on_shutdown(&self) -> zbus::fdo::Result<bool> {
|
||||
let config = self.0.lock_config().await;
|
||||
Ok(config.show_on_shutdown)
|
||||
}
|
||||
|
||||
#[zbus(property)]
|
||||
async fn set_show_on_shutdown(&self, enable: bool) -> zbus::Result<()> {
|
||||
let mut config = self.0.lock_config().await;
|
||||
self.0
|
||||
.write_bytes(&get_shutdown_packet(config.slash_type, enable))
|
||||
.await?;
|
||||
config.show_on_shutdown = enable;
|
||||
config.write();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[zbus(property)]
|
||||
async fn show_on_battery(&self) -> zbus::fdo::Result<bool> {
|
||||
let config = self.0.lock_config().await;
|
||||
Ok(config.show_on_battery)
|
||||
}
|
||||
|
||||
#[zbus(property)]
|
||||
async fn set_show_on_battery(&self, enable: bool) -> zbus::Result<()> {
|
||||
let mut config = self.0.lock_config().await;
|
||||
self.0
|
||||
.write_bytes(&get_battery_saver_packet(config.slash_type, enable))
|
||||
.await?;
|
||||
config.show_on_battery = enable;
|
||||
config.write();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[zbus(property)]
|
||||
async fn show_battery_warning(&self) -> zbus::fdo::Result<bool> {
|
||||
let config = self.0.lock_config().await;
|
||||
Ok(config.show_battery_warning)
|
||||
}
|
||||
|
||||
#[zbus(property)]
|
||||
async fn set_show_battery_warning(&self, enable: bool) -> zbus::Result<()> {
|
||||
let mut config = self.0.lock_config().await;
|
||||
self.0
|
||||
.write_bytes(&get_low_battery_packet(config.slash_type, enable))
|
||||
.await?;
|
||||
config.show_battery_warning = enable;
|
||||
config.write();
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Reloadable for SlashZbus {
|
||||
@@ -174,17 +248,40 @@ impl Reloadable for SlashZbus {
|
||||
debug!("reloading slash settings");
|
||||
let config = self.0.lock_config().await;
|
||||
self.0
|
||||
.write_bytes(&pkt_set_options(
|
||||
.write_bytes(&get_options_packet(
|
||||
config.slash_type,
|
||||
config.slash_enabled,
|
||||
config.slash_brightness,
|
||||
config.slash_interval,
|
||||
config.enabled,
|
||||
config.brightness,
|
||||
config.display_interval
|
||||
))
|
||||
.await
|
||||
.map_err(|err| {
|
||||
warn!("ctrl_slash::set_options {}", err);
|
||||
warn!("set_options {}", err);
|
||||
})
|
||||
.ok();
|
||||
|
||||
macro_rules! write_bytes_with_warning {
|
||||
($packet_fn:expr, $cfg:ident, $warn_msg:expr) => {
|
||||
self.0
|
||||
.write_bytes(&$packet_fn(config.slash_type, config.$cfg))
|
||||
.await
|
||||
.map_err(|err| {
|
||||
warn!("{} {}", $warn_msg, err);
|
||||
})
|
||||
.ok();
|
||||
};
|
||||
}
|
||||
|
||||
write_bytes_with_warning!(get_boot_packet, show_on_boot, "show_on_boot");
|
||||
write_bytes_with_warning!(get_sleep_packet, show_on_sleep, "show_on_sleep");
|
||||
write_bytes_with_warning!(get_shutdown_packet, show_on_shutdown, "show_on_shutdown");
|
||||
write_bytes_with_warning!(get_battery_saver_packet, show_on_battery, "show_on_battery");
|
||||
write_bytes_with_warning!(
|
||||
get_low_battery_packet,
|
||||
show_battery_warning,
|
||||
"show_battery_warning"
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ pub enum _DeviceHandle {
|
||||
LedClass(KeyboardBacklight),
|
||||
/// TODO
|
||||
MulticolourLed,
|
||||
None,
|
||||
None
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
@@ -47,14 +47,14 @@ pub enum DeviceHandle {
|
||||
TufLedClass(Arc<Mutex<HidRaw>>),
|
||||
/// TODO
|
||||
MulticolourLed,
|
||||
None,
|
||||
None
|
||||
}
|
||||
|
||||
impl DeviceHandle {
|
||||
/// Try Slash HID. If one exists it is initialsed and returned.
|
||||
pub async fn new_slash_hid(
|
||||
device: Arc<Mutex<HidRaw>>,
|
||||
prod_id: &str,
|
||||
prod_id: &str
|
||||
) -> Result<Self, RogError> {
|
||||
debug!("Testing for HIDRAW Slash");
|
||||
let slash_type = SlashType::from_dmi();
|
||||
@@ -93,7 +93,7 @@ impl DeviceHandle {
|
||||
let slash = Slash::new(
|
||||
None,
|
||||
Some(Arc::new(Mutex::new(usb))),
|
||||
Arc::new(Mutex::new(config)),
|
||||
Arc::new(Mutex::new(config))
|
||||
);
|
||||
slash.do_initialization().await?;
|
||||
Ok(Self::Slash(slash))
|
||||
@@ -105,7 +105,7 @@ impl DeviceHandle {
|
||||
/// Try AniMe Matrix HID. If one exists it is initialsed and returned.
|
||||
pub async fn maybe_anime_hid(
|
||||
device: Arc<Mutex<HidRaw>>,
|
||||
prod_id: &str,
|
||||
prod_id: &str
|
||||
) -> Result<Self, RogError> {
|
||||
debug!("Testing for HIDRAW AniMe");
|
||||
let anime_type = AnimeType::from_dmi();
|
||||
@@ -139,13 +139,13 @@ impl DeviceHandle {
|
||||
let mut anime = AniMe::new(
|
||||
None,
|
||||
Some(Arc::new(Mutex::new(usb))),
|
||||
Arc::new(Mutex::new(config)),
|
||||
Arc::new(Mutex::new(config))
|
||||
);
|
||||
anime.do_initialization().await?;
|
||||
Ok(Self::AniMe(anime))
|
||||
} else {
|
||||
Err(RogError::NotFound(
|
||||
"No AnimeMatrix device found".to_string(),
|
||||
"No AnimeMatrix device found".to_string()
|
||||
))
|
||||
}
|
||||
}
|
||||
@@ -169,7 +169,7 @@ impl DeviceHandle {
|
||||
|
||||
pub async fn maybe_laptop_aura(
|
||||
device: Option<Arc<Mutex<HidRaw>>>,
|
||||
prod_id: &str,
|
||||
prod_id: &str
|
||||
) -> Result<Self, RogError> {
|
||||
debug!("Testing for laptop aura");
|
||||
let aura_type = AuraDeviceType::from(prod_id);
|
||||
@@ -196,7 +196,7 @@ impl DeviceHandle {
|
||||
let aura = Aura {
|
||||
hid: device,
|
||||
backlight,
|
||||
config: Arc::new(Mutex::new(config)),
|
||||
config: Arc::new(Mutex::new(config))
|
||||
};
|
||||
aura.do_initialization().await?;
|
||||
Ok(Self::Aura(aura))
|
||||
|
||||
@@ -60,7 +60,7 @@ pub struct Config {
|
||||
pub nv_temp_target: Option<u8>,
|
||||
/// Temporary state for AC/Batt
|
||||
#[serde(skip)]
|
||||
pub last_power_plugged: u8,
|
||||
pub last_power_plugged: u8
|
||||
}
|
||||
|
||||
impl Default for Config {
|
||||
@@ -89,7 +89,7 @@ impl Default for Config {
|
||||
ppt_platform_sppt: Default::default(),
|
||||
nv_dynamic_boost: Default::default(),
|
||||
nv_temp_target: Default::default(),
|
||||
last_power_plugged: Default::default(),
|
||||
last_power_plugged: Default::default()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -137,7 +137,7 @@ pub struct Config507 {
|
||||
pub ppt_apu_sppt: Option<u8>,
|
||||
pub ppt_platform_sppt: Option<u8>,
|
||||
pub nv_dynamic_boost: Option<u8>,
|
||||
pub nv_temp_target: Option<u8>,
|
||||
pub nv_temp_target: Option<u8>
|
||||
}
|
||||
|
||||
impl From<Config507> for Config {
|
||||
@@ -167,7 +167,7 @@ impl From<Config507> for Config {
|
||||
ppt_platform_sppt: c.ppt_platform_sppt,
|
||||
nv_dynamic_boost: c.nv_dynamic_boost,
|
||||
nv_temp_target: c.nv_temp_target,
|
||||
last_power_plugged: 0,
|
||||
last_power_plugged: 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ pub const FAN_CURVE_ZBUS_PATH: &str = "/xyz/ljones";
|
||||
pub struct FanCurveConfig {
|
||||
pub profiles: FanCurveProfiles,
|
||||
#[serde(skip)]
|
||||
pub current: u8,
|
||||
pub current: u8
|
||||
}
|
||||
|
||||
impl StdConfig for FanCurveConfig {
|
||||
@@ -47,7 +47,7 @@ impl StdConfigLoad for FanCurveConfig {}
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct CtrlFanCurveZbus {
|
||||
config: Arc<Mutex<FanCurveConfig>>,
|
||||
platform: RogPlatform,
|
||||
platform: RogPlatform
|
||||
}
|
||||
|
||||
// Non-zbus-derive impl
|
||||
@@ -69,7 +69,7 @@ impl CtrlFanCurveZbus {
|
||||
for this in [
|
||||
ThrottlePolicy::Balanced,
|
||||
ThrottlePolicy::Performance,
|
||||
ThrottlePolicy::Quiet,
|
||||
ThrottlePolicy::Quiet
|
||||
] {
|
||||
// For each profile we need to switch to it before we
|
||||
// can read the existing values from hardware. The ACPI method used
|
||||
@@ -93,7 +93,7 @@ impl CtrlFanCurveZbus {
|
||||
|
||||
return Ok(Self {
|
||||
config: Arc::new(Mutex::new(config)),
|
||||
platform,
|
||||
platform
|
||||
});
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ impl CtrlFanCurveZbus {
|
||||
async fn set_fan_curves_enabled(
|
||||
&mut self,
|
||||
profile: ThrottlePolicy,
|
||||
enabled: bool,
|
||||
enabled: bool
|
||||
) -> zbus::fdo::Result<()> {
|
||||
self.config
|
||||
.lock()
|
||||
@@ -130,7 +130,7 @@ impl CtrlFanCurveZbus {
|
||||
&mut self,
|
||||
profile: ThrottlePolicy,
|
||||
fan: FanCurvePU,
|
||||
enabled: bool,
|
||||
enabled: bool
|
||||
) -> zbus::fdo::Result<()> {
|
||||
self.config
|
||||
.lock()
|
||||
@@ -149,7 +149,7 @@ impl CtrlFanCurveZbus {
|
||||
/// Get the fan-curve data for the currently active ThrottlePolicy
|
||||
async fn fan_curve_data(
|
||||
&mut self,
|
||||
profile: ThrottlePolicy,
|
||||
profile: ThrottlePolicy
|
||||
) -> zbus::fdo::Result<Vec<CurveData>> {
|
||||
let curve = self
|
||||
.config
|
||||
@@ -166,7 +166,7 @@ impl CtrlFanCurveZbus {
|
||||
async fn set_fan_curve(
|
||||
&mut self,
|
||||
profile: ThrottlePolicy,
|
||||
curve: CurveData,
|
||||
curve: CurveData
|
||||
) -> zbus::fdo::Result<()> {
|
||||
self.config
|
||||
.lock()
|
||||
@@ -256,7 +256,7 @@ impl CtrlTask for CtrlFanCurveZbus {
|
||||
.profiles
|
||||
.write_profile_curve_to_platform(
|
||||
profile.into(),
|
||||
&mut find_fan_curve_node().unwrap(),
|
||||
&mut find_fan_curve_node().unwrap()
|
||||
)
|
||||
.map_err(|e| warn!("write_profile_curve_to_platform, {}", e))
|
||||
.ok();
|
||||
|
||||
@@ -86,14 +86,14 @@ pub struct CtrlPlatform {
|
||||
power: AsusPower,
|
||||
platform: RogPlatform,
|
||||
cpu_control: Option<CPUControl>,
|
||||
config: Arc<Mutex<Config>>,
|
||||
config: Arc<Mutex<Config>>
|
||||
}
|
||||
|
||||
impl CtrlPlatform {
|
||||
pub fn new(
|
||||
config: Arc<Mutex<Config>>,
|
||||
config_path: &Path,
|
||||
signal_context: SignalEmitter<'static>,
|
||||
signal_context: SignalEmitter<'static>
|
||||
) -> Result<Self, RogError> {
|
||||
let platform = RogPlatform::new()?;
|
||||
let power = AsusPower::new()?;
|
||||
@@ -112,7 +112,7 @@ impl CtrlPlatform {
|
||||
config,
|
||||
cpu_control: CPUControl::new()
|
||||
.map_err(|e| error!("Couldn't get CPU control sysfs: {e}"))
|
||||
.ok(),
|
||||
.ok()
|
||||
};
|
||||
let mut inotify_self = ret_self.clone();
|
||||
|
||||
@@ -131,7 +131,7 @@ impl CtrlPlatform {
|
||||
inotify::WatchMask::MODIFY
|
||||
| inotify::WatchMask::CLOSE_WRITE
|
||||
| inotify::WatchMask::ATTRIB
|
||||
| inotify::WatchMask::CREATE,
|
||||
| inotify::WatchMask::CREATE
|
||||
)
|
||||
.inspect_err(|e| {
|
||||
if e.kind() == std::io::ErrorKind::NotFound {
|
||||
@@ -184,7 +184,7 @@ impl CtrlPlatform {
|
||||
if limit > 0
|
||||
&& std::mem::replace(
|
||||
&mut self.config.lock().await.charge_control_end_threshold,
|
||||
limit,
|
||||
limit
|
||||
) != limit
|
||||
{
|
||||
self.power
|
||||
@@ -266,7 +266,7 @@ impl CtrlPlatform {
|
||||
match throttle {
|
||||
ThrottlePolicy::Balanced => self.config.lock().await.throttle_balanced_epp,
|
||||
ThrottlePolicy::Performance => self.config.lock().await.throttle_performance_epp,
|
||||
ThrottlePolicy::Quiet => self.config.lock().await.throttle_quiet_epp,
|
||||
ThrottlePolicy::Quiet => self.config.lock().await.throttle_quiet_epp
|
||||
}
|
||||
}
|
||||
|
||||
@@ -377,7 +377,7 @@ impl CtrlPlatform {
|
||||
async fn one_shot_full_charge(&self) -> Result<(), FdoErr> {
|
||||
let base_limit = std::mem::replace(
|
||||
&mut self.config.lock().await.charge_control_end_threshold,
|
||||
100,
|
||||
100
|
||||
);
|
||||
if base_limit != 100 {
|
||||
self.power.set_charge_control_end_threshold(100)?;
|
||||
@@ -405,7 +405,7 @@ impl CtrlPlatform {
|
||||
self.config.lock().await.write();
|
||||
} else {
|
||||
return Err(FdoErr::NotSupported(
|
||||
"RogPlatform: set_gpu_mux_mode not supported".to_owned(),
|
||||
"RogPlatform: set_gpu_mux_mode not supported".to_owned()
|
||||
));
|
||||
}
|
||||
Ok(())
|
||||
@@ -415,7 +415,7 @@ impl CtrlPlatform {
|
||||
/// If fan-curves are supported will also activate a fan curve for profile.
|
||||
async fn next_throttle_thermal_policy(
|
||||
&mut self,
|
||||
#[zbus(signal_context)] ctxt: SignalEmitter<'_>,
|
||||
#[zbus(signal_context)] ctxt: SignalEmitter<'_>
|
||||
) -> Result<(), FdoErr> {
|
||||
let policy: ThrottlePolicy =
|
||||
platform_get_value!(self, throttle_thermal_policy, "throttle_thermal_policy")
|
||||
@@ -435,7 +435,7 @@ impl CtrlPlatform {
|
||||
Ok(self.throttle_thermal_policy_changed(&ctxt).await?)
|
||||
} else {
|
||||
Err(FdoErr::NotSupported(
|
||||
"RogPlatform: throttle_thermal_policy not supported".to_owned(),
|
||||
"RogPlatform: throttle_thermal_policy not supported".to_owned()
|
||||
))
|
||||
}
|
||||
}
|
||||
@@ -462,7 +462,7 @@ impl CtrlPlatform {
|
||||
})
|
||||
} else {
|
||||
Err(FdoErr::NotSupported(
|
||||
"RogPlatform: throttle_thermal_policy not supported".to_owned(),
|
||||
"RogPlatform: throttle_thermal_policy not supported".to_owned()
|
||||
))
|
||||
}
|
||||
}
|
||||
@@ -487,7 +487,7 @@ impl CtrlPlatform {
|
||||
#[zbus(property)]
|
||||
async fn set_throttle_policy_on_battery(
|
||||
&mut self,
|
||||
policy: ThrottlePolicy,
|
||||
policy: ThrottlePolicy
|
||||
) -> Result<(), FdoErr> {
|
||||
self.config.lock().await.throttle_policy_on_battery = policy;
|
||||
self.set_throttle_thermal_policy(policy).await?;
|
||||
@@ -747,7 +747,7 @@ impl ReloadAndNotify for CtrlPlatform {
|
||||
async fn reload_and_notify(
|
||||
&mut self,
|
||||
signal_context: &SignalEmitter<'static>,
|
||||
data: Self::Data,
|
||||
data: Self::Data
|
||||
) -> Result<(), RogError> {
|
||||
let mut config = self.config.lock().await;
|
||||
if *config != data {
|
||||
@@ -949,7 +949,7 @@ impl CtrlTask for CtrlPlatform {
|
||||
platform1
|
||||
.power
|
||||
.set_charge_control_end_threshold(
|
||||
platform1.config.lock().await.charge_control_end_threshold,
|
||||
platform1.config.lock().await.charge_control_end_threshold
|
||||
)
|
||||
.ok();
|
||||
}
|
||||
@@ -994,7 +994,7 @@ impl CtrlTask for CtrlPlatform {
|
||||
platform2
|
||||
.power
|
||||
.set_charge_control_end_threshold(
|
||||
lock.base_charge_control_end_threshold,
|
||||
lock.base_charge_control_end_threshold
|
||||
)
|
||||
.map_err(|err| {
|
||||
warn!("CtrlCharge: charge_control_end_threshold {}", err);
|
||||
@@ -1024,7 +1024,7 @@ impl CtrlTask for CtrlPlatform {
|
||||
platform3.restore_charge_limit().await;
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
)
|
||||
.await;
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
let is_service = match env::var_os("IS_SERVICE") {
|
||||
Some(val) => val == "1",
|
||||
None => true,
|
||||
None => true
|
||||
};
|
||||
|
||||
if !is_service {
|
||||
@@ -80,7 +80,7 @@ async fn start_daemon() -> Result<(), Box<dyn Error>> {
|
||||
match CtrlPlatform::new(
|
||||
config.clone(),
|
||||
&cfg_path,
|
||||
CtrlPlatform::signal_context(&server)?,
|
||||
CtrlPlatform::signal_context(&server)?
|
||||
) {
|
||||
Ok(ctrl) => {
|
||||
let sig_ctx = CtrlPlatform::signal_context(&server)?;
|
||||
|
||||
@@ -37,7 +37,7 @@ pub enum RogError {
|
||||
SystemdUnitAction(String),
|
||||
SystemdUnitWaitTimeout(String),
|
||||
Command(String, std::io::Error),
|
||||
ParseRon(ron::Error),
|
||||
ParseRon(ron::Error)
|
||||
}
|
||||
|
||||
impl fmt::Display for RogError {
|
||||
@@ -87,7 +87,7 @@ impl fmt::Display for RogError {
|
||||
)
|
||||
}
|
||||
RogError::Command(func, error) => write!(f, "Command exec error: {}: {}", func, error),
|
||||
RogError::ParseRon(error) => write!(f, "Parse config error: {}", error),
|
||||
RogError::ParseRon(error) => write!(f, "Parse config error: {}", error)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -142,3 +142,10 @@ impl From<RogError> for zbus::fdo::Error {
|
||||
zbus::fdo::Error::Failed(format!("{}", err))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<RogError> for zbus::Error {
|
||||
#[inline]
|
||||
fn from(err: RogError) -> Self {
|
||||
zbus::Error::Failure(format!("{}", err))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ pub trait ReloadAndNotify {
|
||||
fn reload_and_notify(
|
||||
&mut self,
|
||||
signal_context: &SignalEmitter<'static>,
|
||||
data: Self::Data,
|
||||
data: Self::Data
|
||||
) -> impl Future<Output = Result<(), RogError>> + Send;
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ pub trait ZbusRun {
|
||||
fn add_to_server_helper(
|
||||
iface: impl Interface,
|
||||
path: &str,
|
||||
server: &mut Connection,
|
||||
server: &mut Connection
|
||||
) -> impl Future<Output = ()> + Send {
|
||||
async move {
|
||||
server
|
||||
@@ -188,7 +188,7 @@ pub trait CtrlTask {
|
||||
/// separate thread.
|
||||
fn create_tasks(
|
||||
&self,
|
||||
signal: SignalEmitter<'static>,
|
||||
signal: SignalEmitter<'static>
|
||||
) -> impl Future<Output = Result<(), RogError>> + Send;
|
||||
|
||||
// /// Create a timed repeating task
|
||||
@@ -212,7 +212,7 @@ pub trait CtrlTask {
|
||||
mut on_prepare_for_sleep: F1,
|
||||
mut on_prepare_for_shutdown: F2,
|
||||
mut on_lid_change: F3,
|
||||
mut on_external_power_change: F4,
|
||||
mut on_external_power_change: F4
|
||||
) -> impl Future<Output = ()> + Send
|
||||
where
|
||||
F1: FnMut(bool) -> Fut1 + Send + 'static,
|
||||
@@ -222,7 +222,7 @@ pub trait CtrlTask {
|
||||
Fut1: Future<Output = ()> + Send,
|
||||
Fut2: Future<Output = ()> + Send,
|
||||
Fut3: Future<Output = ()> + Send,
|
||||
Fut4: Future<Output = ()> + Send,
|
||||
Fut4: Future<Output = ()> + Send
|
||||
{
|
||||
async {
|
||||
let connection = Connection::system()
|
||||
@@ -302,10 +302,10 @@ pub trait GetSupported {
|
||||
pub async fn start_tasks<T>(
|
||||
mut zbus: T,
|
||||
connection: &mut Connection,
|
||||
signal_ctx: SignalEmitter<'static>,
|
||||
signal_ctx: SignalEmitter<'static>
|
||||
) -> Result<(), RogError>
|
||||
where
|
||||
T: ZbusRun + Reloadable + CtrlTask + Clone,
|
||||
T: ZbusRun + Reloadable + CtrlTask + Clone
|
||||
{
|
||||
let zbus_clone = zbus.clone();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user