mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-01-22 09:23:19 +01:00
Reformat with trailing comma
This commit is contained in:
@@ -20,7 +20,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 {
|
||||
@@ -33,7 +33,7 @@ pub struct AsusArmouryAttribute {
|
||||
config: Arc<Mutex<Config>>,
|
||||
/// platform control required here for access to PPD or Throttle profile
|
||||
platform: RogPlatform,
|
||||
power: AsusPower
|
||||
power: AsusPower,
|
||||
}
|
||||
|
||||
impl AsusArmouryAttribute {
|
||||
@@ -41,13 +41,13 @@ impl AsusArmouryAttribute {
|
||||
attr: Attribute,
|
||||
platform: RogPlatform,
|
||||
power: AsusPower,
|
||||
config: Arc<Mutex<Config>>
|
||||
config: Arc<Mutex<Config>>,
|
||||
) -> Self {
|
||||
Self {
|
||||
attr,
|
||||
config,
|
||||
platform,
|
||||
power
|
||||
power,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ impl AsusArmouryAttribute {
|
||||
|
||||
async fn watch_and_notify(
|
||||
&mut self,
|
||||
signal_ctxt: SignalEmitter<'static>
|
||||
signal_ctxt: SignalEmitter<'static>,
|
||||
) -> Result<(), RogError> {
|
||||
use futures_util::StreamExt;
|
||||
|
||||
@@ -92,7 +92,7 @@ impl AsusArmouryAttribute {
|
||||
"inotify watch failed: {}. You can ignore this if your device does not \
|
||||
support the feature",
|
||||
e
|
||||
)
|
||||
),
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -187,7 +187,7 @@ impl AsusArmouryAttribute {
|
||||
async fn default_value(&self) -> i32 {
|
||||
match self.attr.default_value() {
|
||||
AttrValue::Integer(i) => *i,
|
||||
_ => -1
|
||||
_ => -1,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,7 +228,7 @@ impl AsusArmouryAttribute {
|
||||
async fn min_value(&self) -> i32 {
|
||||
match self.attr.min_value() {
|
||||
AttrValue::Integer(i) => *i,
|
||||
_ => -1
|
||||
_ => -1,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,7 +236,7 @@ impl AsusArmouryAttribute {
|
||||
async fn max_value(&self) -> i32 {
|
||||
match self.attr.max_value() {
|
||||
AttrValue::Integer(i) => *i,
|
||||
_ => -1
|
||||
_ => -1,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -244,7 +244,7 @@ impl AsusArmouryAttribute {
|
||||
async fn scalar_increment(&self) -> i32 {
|
||||
match self.attr.scalar_increment() {
|
||||
AttrValue::Integer(i) => *i,
|
||||
_ => -1
|
||||
_ => -1,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,7 +252,7 @@ impl AsusArmouryAttribute {
|
||||
async fn possible_values(&self) -> Vec<i32> {
|
||||
match self.attr.possible_values() {
|
||||
AttrValue::EnumInt(i) => i.clone(),
|
||||
_ => Vec::default()
|
||||
_ => Vec::default(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -276,7 +276,7 @@ impl AsusArmouryAttribute {
|
||||
return Ok(*i);
|
||||
}
|
||||
return Err(fdo::Error::Failed(
|
||||
"Could not read current value".to_string()
|
||||
"Could not read current value".to_string(),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -284,7 +284,7 @@ impl AsusArmouryAttribute {
|
||||
return Ok(i);
|
||||
}
|
||||
Err(fdo::Error::Failed(
|
||||
"Could not read current value".to_string()
|
||||
"Could not read current value".to_string(),
|
||||
))
|
||||
}
|
||||
|
||||
@@ -362,14 +362,14 @@ pub async fn start_attributes_zbus(
|
||||
platform: RogPlatform,
|
||||
power: AsusPower,
|
||||
attributes: FirmwareAttributes,
|
||||
config: Arc<Mutex<Config>>
|
||||
config: Arc<Mutex<Config>>,
|
||||
) -> Result<(), RogError> {
|
||||
for attr in attributes.attributes() {
|
||||
let mut attr = AsusArmouryAttribute::new(
|
||||
attr.clone(),
|
||||
platform.clone(),
|
||||
power.clone(),
|
||||
config.clone()
|
||||
config.clone(),
|
||||
);
|
||||
attr.reload().await?;
|
||||
|
||||
@@ -386,7 +386,7 @@ pub async fn set_config_or_default(
|
||||
attrs: &FirmwareAttributes,
|
||||
config: &mut Config,
|
||||
power_plugged: bool,
|
||||
profile: PlatformProfile
|
||||
profile: PlatformProfile,
|
||||
) {
|
||||
for attr in attrs.attributes().iter() {
|
||||
let name: FirmwareAttribute = attr.name().into();
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -148,8 +148,8 @@ impl AniMeConfig {
|
||||
time: AnimTime::Fade(Fade::new(
|
||||
Duration::from_secs(2),
|
||||
Some(Duration::from_secs(2)),
|
||||
Duration::from_secs(2)
|
||||
))
|
||||
Duration::from_secs(2),
|
||||
)),
|
||||
},
|
||||
],
|
||||
wake: vec![
|
||||
@@ -162,8 +162,8 @@ impl AniMeConfig {
|
||||
time: AnimTime::Fade(Fade::new(
|
||||
Duration::from_secs(2),
|
||||
Some(Duration::from_secs(2)),
|
||||
Duration::from_secs(2)
|
||||
))
|
||||
Duration::from_secs(2),
|
||||
)),
|
||||
},
|
||||
],
|
||||
shutdown: vec![
|
||||
@@ -173,7 +173,7 @@ impl AniMeConfig {
|
||||
angle: 0.0,
|
||||
translation: Vec2::new(3.0, 2.0),
|
||||
brightness: 1.0,
|
||||
time: AnimTime::Infinite
|
||||
time: AnimTime::Infinite,
|
||||
},
|
||||
],
|
||||
..Default::default()
|
||||
|
||||
@@ -12,7 +12,7 @@ use futures_util::lock::Mutex;
|
||||
use log::{debug, 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?;
|
||||
|
||||
@@ -5,7 +5,7 @@ use log::{debug, 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()
|
||||
@@ -169,7 +169,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 +319,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 +330,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 +433,7 @@ impl crate::CtrlTask for AniMeZbus {
|
||||
.ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
.await;
|
||||
|
||||
@@ -460,7 +460,7 @@ impl crate::Reloadable for AniMeZbus {
|
||||
builtin_anims.boot,
|
||||
builtin_anims.awake,
|
||||
builtin_anims.sleep,
|
||||
builtin_anims.shutdown
|
||||
builtin_anims.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()
|
||||
|
||||
@@ -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,13 +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
|
||||
mode.speed as u8,
|
||||
];
|
||||
platform.lock().await.set_kbd_rgb_mode(&buf)?;
|
||||
}
|
||||
@@ -121,7 +121,7 @@ impl Aura {
|
||||
return Ok(());
|
||||
}
|
||||
Err(RogError::MissingFunction(
|
||||
"No LED backlight control available".to_string()
|
||||
"No LED backlight control available".to_string(),
|
||||
))
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ impl Aura {
|
||||
0x01,
|
||||
p.new_to_byte() as u8,
|
||||
0x0,
|
||||
0x0
|
||||
0x0,
|
||||
];
|
||||
hid_raw.write_bytes(&msg)?;
|
||||
return Ok(());
|
||||
@@ -154,7 +154,7 @@ impl Aura {
|
||||
|
||||
let bytes = config.enabled.to_bytes(config.led_type);
|
||||
let msg = [
|
||||
0x5d, 0xbd, 0x01, bytes[0], bytes[1], bytes[2], bytes[3]
|
||||
0x5d, 0xbd, 0x01, bytes[0], bytes[1], bytes[2], bytes[3],
|
||||
];
|
||||
hid_raw.write_bytes(&msg)?;
|
||||
}
|
||||
@@ -167,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;
|
||||
@@ -201,7 +201,7 @@ impl Aura {
|
||||
let g = row[10];
|
||||
let b = row[11];
|
||||
tuf.lock().await.set_kbd_rgb_mode(&[
|
||||
0, 0, r, g, b, 0
|
||||
0, 0, r, g, b, 0,
|
||||
])?;
|
||||
}
|
||||
}
|
||||
@@ -215,7 +215,7 @@ impl Aura {
|
||||
let mut config = self.config.lock().await;
|
||||
if config.ally_fix.is_none() {
|
||||
let msg = [
|
||||
0x5d, 0xbd, 0x01, 0xff, 0xff, 0xff, 0xff
|
||||
0x5d, 0xbd, 0x01, 0xff, 0xff, 0xff, 0xff,
|
||||
];
|
||||
hid_raw.lock().await.write_bytes(&msg)?;
|
||||
info!("Reset Ally power settings to base");
|
||||
|
||||
@@ -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 {
|
||||
@@ -327,7 +327,7 @@ impl DeviceManager {
|
||||
{
|
||||
devices.push(AsusDevice {
|
||||
device: dev_type,
|
||||
dbus_path: path
|
||||
dbus_path: path,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -354,7 +354,7 @@ impl DeviceManager {
|
||||
ctrl.start_tasks(connection, path.clone()).await.unwrap();
|
||||
devices.push(AsusDevice {
|
||||
device: dev_type,
|
||||
dbus_path: path
|
||||
dbus_path: path,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -374,7 +374,7 @@ impl DeviceManager {
|
||||
info!("Found {} valid devices on startup", devices.len());
|
||||
let devices = Arc::new(Mutex::new(devices));
|
||||
let manager = Self {
|
||||
_dbus_connection: connection
|
||||
_dbus_connection: connection,
|
||||
};
|
||||
|
||||
// TODO: The /sysfs/ LEDs don't cause events, so they need to be manually
|
||||
@@ -509,7 +509,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()))
|
||||
|
||||
@@ -17,7 +17,7 @@ pub struct SlashConfig {
|
||||
pub show_on_shutdown: bool,
|
||||
pub show_on_sleep: bool,
|
||||
pub show_on_battery: bool,
|
||||
pub show_battery_warning: bool
|
||||
pub show_battery_warning: bool,
|
||||
}
|
||||
|
||||
impl Default for SlashConfig {
|
||||
@@ -32,7 +32,7 @@ impl Default for SlashConfig {
|
||||
show_on_shutdown: true,
|
||||
show_on_sleep: true,
|
||||
show_on_battery: true,
|
||||
show_battery_warning: true
|
||||
show_battery_warning: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -58,7 +58,7 @@ impl From<&SlashConfig> for DeviceState {
|
||||
slash_enabled: config.enabled,
|
||||
slash_brightness: config.brightness,
|
||||
slash_interval: config.display_interval,
|
||||
slash_mode: config.display_mode
|
||||
slash_mode: config.display_mode,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 }
|
||||
}
|
||||
@@ -57,7 +57,7 @@ impl Slash {
|
||||
config.slash_type,
|
||||
config.enabled,
|
||||
config.brightness,
|
||||
config.display_interval
|
||||
config.display_interval,
|
||||
);
|
||||
self.write_bytes(&option_packets).await?;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ use config_traits::StdConfig;
|
||||
use log::{debug, error, warn};
|
||||
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
|
||||
get_shutdown_packet, get_sleep_packet, pkt_save, pkt_set_mode,
|
||||
};
|
||||
use rog_slash::{DeviceState, SlashMode};
|
||||
use zbus::zvariant::OwnedObjectPath;
|
||||
@@ -23,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()
|
||||
@@ -62,7 +62,7 @@ impl SlashZbus {
|
||||
config.slash_type,
|
||||
enabled,
|
||||
brightness,
|
||||
config.display_interval
|
||||
config.display_interval,
|
||||
))
|
||||
.await
|
||||
.map_err(|err| {
|
||||
@@ -92,7 +92,7 @@ impl SlashZbus {
|
||||
config.slash_type,
|
||||
enabled,
|
||||
brightness,
|
||||
config.display_interval
|
||||
config.display_interval,
|
||||
))
|
||||
.await
|
||||
.map_err(|err| {
|
||||
@@ -117,7 +117,7 @@ impl SlashZbus {
|
||||
let mut config = self.0.lock_config().await;
|
||||
self.0
|
||||
.write_bytes(&get_options_packet(
|
||||
config.slash_type, config.enabled, config.brightness, interval
|
||||
config.slash_type, config.enabled, config.brightness, interval,
|
||||
))
|
||||
.await
|
||||
.map_err(|err| {
|
||||
@@ -252,7 +252,7 @@ impl Reloadable for SlashZbus {
|
||||
config.slash_type,
|
||||
config.enabled,
|
||||
config.brightness,
|
||||
config.display_interval
|
||||
config.display_interval,
|
||||
))
|
||||
.await
|
||||
.map_err(|err| {
|
||||
|
||||
@@ -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,11 +105,11 @@ 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> {
|
||||
// TODO: can't use HIDRAW for anime at the moment
|
||||
Err(RogError::NotFound(
|
||||
"Can't use anime over hidraw yet. Skip.".to_string()
|
||||
"Can't use anime over hidraw yet. Skip.".to_string(),
|
||||
))
|
||||
|
||||
// debug!("Testing for HIDRAW AniMe");
|
||||
@@ -144,13 +144,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(),
|
||||
))
|
||||
}
|
||||
}
|
||||
@@ -174,7 +174,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);
|
||||
@@ -201,7 +201,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))
|
||||
|
||||
@@ -11,7 +11,7 @@ const CONFIG_FILE: &str = "asusd.ron";
|
||||
#[derive(Default, Clone, Deserialize, Serialize, PartialEq)]
|
||||
pub struct Tuning {
|
||||
pub enabled: bool,
|
||||
pub group: HashMap<FirmwareAttribute, i32>
|
||||
pub group: HashMap<FirmwareAttribute, i32>,
|
||||
}
|
||||
type Tunings = HashMap<PlatformProfile, Tuning>;
|
||||
|
||||
@@ -49,7 +49,7 @@ pub struct Config {
|
||||
pub armoury_settings: HashMap<FirmwareAttribute, i32>,
|
||||
/// Temporary state for AC/Batt
|
||||
#[serde(skip)]
|
||||
pub last_power_plugged: u8
|
||||
pub last_power_plugged: u8,
|
||||
}
|
||||
|
||||
impl Config {
|
||||
@@ -82,7 +82,7 @@ impl Default for Config {
|
||||
ac_profile_tunings: HashMap::default(),
|
||||
dc_profile_tunings: HashMap::default(),
|
||||
armoury_settings: HashMap::default(),
|
||||
last_power_plugged: Default::default()
|
||||
last_power_plugged: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -147,7 +147,7 @@ pub struct Config601 {
|
||||
#[serde(skip_serializing_if = "Option::is_none", default)]
|
||||
pub nv_temp_target: Option<u8>,
|
||||
#[serde(skip)]
|
||||
pub last_power_plugged: u8
|
||||
pub last_power_plugged: u8,
|
||||
}
|
||||
|
||||
impl From<Config601> for Config {
|
||||
@@ -170,7 +170,7 @@ impl From<Config601> for Config {
|
||||
last_power_plugged: c.last_power_plugged,
|
||||
ac_profile_tunings: HashMap::default(),
|
||||
dc_profile_tunings: HashMap::default(),
|
||||
armoury_settings: HashMap::default()
|
||||
armoury_settings: HashMap::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ pub const FAN_CURVE_ZBUS_PATH: &str = "/xyz/ljones";
|
||||
pub struct FanCurveConfig {
|
||||
pub profiles: FanCurveProfiles,
|
||||
#[serde(skip)]
|
||||
pub current: PlatformProfile
|
||||
pub current: PlatformProfile,
|
||||
}
|
||||
|
||||
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 [
|
||||
PlatformProfile::Balanced,
|
||||
PlatformProfile::Performance,
|
||||
PlatformProfile::Quiet
|
||||
PlatformProfile::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: PlatformProfile,
|
||||
enabled: bool
|
||||
enabled: bool,
|
||||
) -> zbus::fdo::Result<()> {
|
||||
self.config
|
||||
.lock()
|
||||
@@ -130,7 +130,7 @@ impl CtrlFanCurveZbus {
|
||||
&mut self,
|
||||
profile: PlatformProfile,
|
||||
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: PlatformProfile
|
||||
profile: PlatformProfile,
|
||||
) -> zbus::fdo::Result<Vec<CurveData>> {
|
||||
let curve = self
|
||||
.config
|
||||
@@ -166,7 +166,7 @@ impl CtrlFanCurveZbus {
|
||||
async fn set_fan_curve(
|
||||
&mut self,
|
||||
profile: PlatformProfile,
|
||||
curve: CurveData
|
||||
curve: CurveData,
|
||||
) -> zbus::fdo::Result<()> {
|
||||
self.config
|
||||
.lock()
|
||||
@@ -261,7 +261,7 @@ impl CtrlTask for CtrlFanCurveZbus {
|
||||
.profiles
|
||||
.write_profile_curve_to_platform(
|
||||
profile,
|
||||
&mut find_fan_curve_node().unwrap()
|
||||
&mut find_fan_curve_node().unwrap(),
|
||||
)
|
||||
.map_err(|e| warn!("write_profile_curve_to_platform, {}", e))
|
||||
.ok();
|
||||
|
||||
@@ -45,7 +45,7 @@ pub struct CtrlPlatform {
|
||||
platform: RogPlatform,
|
||||
attributes: FirmwareAttributes,
|
||||
cpu_control: Option<CPUControl>,
|
||||
config: Arc<Mutex<Config>>
|
||||
config: Arc<Mutex<Config>>,
|
||||
}
|
||||
|
||||
impl CtrlPlatform {
|
||||
@@ -55,7 +55,7 @@ impl CtrlPlatform {
|
||||
attributes: FirmwareAttributes,
|
||||
config: Arc<Mutex<Config>>,
|
||||
config_path: &Path,
|
||||
signal_context: SignalEmitter<'static>
|
||||
signal_context: SignalEmitter<'static>,
|
||||
) -> Result<Self, RogError> {
|
||||
let config1 = config.clone();
|
||||
let config_path = config_path.to_owned();
|
||||
@@ -67,7 +67,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();
|
||||
|
||||
@@ -86,7 +86,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 {
|
||||
@@ -128,7 +128,7 @@ impl CtrlPlatform {
|
||||
if limit > 0
|
||||
&& std::mem::replace(
|
||||
&mut self.config.lock().await.charge_control_end_threshold,
|
||||
limit
|
||||
limit,
|
||||
) != limit
|
||||
{
|
||||
self.power
|
||||
@@ -210,7 +210,7 @@ impl CtrlPlatform {
|
||||
match throttle {
|
||||
PlatformProfile::Balanced => self.config.lock().await.profile_balanced_epp,
|
||||
PlatformProfile::Performance => self.config.lock().await.profile_performance_epp,
|
||||
PlatformProfile::Quiet => self.config.lock().await.profile_quiet_epp
|
||||
PlatformProfile::Quiet => self.config.lock().await.profile_quiet_epp,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -305,7 +305,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)?;
|
||||
@@ -319,7 +319,7 @@ impl CtrlPlatform {
|
||||
/// If fan-curves are supported will also activate a fan curve for profile.
|
||||
async fn next_platform_profile(
|
||||
&mut self,
|
||||
#[zbus(signal_context)] ctxt: SignalEmitter<'_>
|
||||
#[zbus(signal_context)] ctxt: SignalEmitter<'_>,
|
||||
) -> Result<(), FdoErr> {
|
||||
let policy: PlatformProfile =
|
||||
platform_get_value!(self, platform_profile, "platform_profile").map(|n| n.into())?;
|
||||
@@ -339,7 +339,7 @@ impl CtrlPlatform {
|
||||
Ok(self.platform_profile_changed(&ctxt).await?)
|
||||
} else {
|
||||
Err(FdoErr::NotSupported(
|
||||
"RogPlatform: platform_profile not supported".to_owned()
|
||||
"RogPlatform: platform_profile not supported".to_owned(),
|
||||
))
|
||||
}
|
||||
}
|
||||
@@ -353,7 +353,7 @@ impl CtrlPlatform {
|
||||
async fn set_platform_profile(
|
||||
&mut self,
|
||||
#[zbus(signal_context)] ctxt: SignalEmitter<'_>,
|
||||
policy: PlatformProfile
|
||||
policy: PlatformProfile,
|
||||
) -> Result<(), FdoErr> {
|
||||
// TODO: watch for external changes
|
||||
if self.platform.has_platform_profile() {
|
||||
@@ -373,7 +373,7 @@ impl CtrlPlatform {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(FdoErr::NotSupported(
|
||||
"RogPlatform: platform_profile not supported".to_owned()
|
||||
"RogPlatform: platform_profile not supported".to_owned(),
|
||||
))
|
||||
}
|
||||
}
|
||||
@@ -399,7 +399,7 @@ impl CtrlPlatform {
|
||||
async fn set_platform_profile_on_battery(
|
||||
&mut self,
|
||||
#[zbus(signal_context)] ctxt: SignalEmitter<'_>,
|
||||
policy: PlatformProfile
|
||||
policy: PlatformProfile,
|
||||
) -> Result<(), FdoErr> {
|
||||
self.config.lock().await.platform_profile_on_battery = policy;
|
||||
self.set_platform_profile(ctxt, policy).await?;
|
||||
@@ -428,7 +428,7 @@ impl CtrlPlatform {
|
||||
async fn set_platform_profile_on_ac(
|
||||
&mut self,
|
||||
#[zbus(signal_context)] ctxt: SignalEmitter<'_>,
|
||||
policy: PlatformProfile
|
||||
policy: PlatformProfile,
|
||||
) -> Result<(), FdoErr> {
|
||||
self.config.lock().await.platform_profile_on_ac = policy;
|
||||
self.set_platform_profile(ctxt, policy).await?;
|
||||
@@ -593,7 +593,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 {
|
||||
@@ -622,7 +622,7 @@ impl ReloadAndNotify for CtrlPlatform {
|
||||
let epp = match profile {
|
||||
PlatformProfile::Balanced => data.profile_balanced_epp,
|
||||
PlatformProfile::Performance => data.profile_performance_epp,
|
||||
PlatformProfile::Quiet => data.profile_quiet_epp
|
||||
PlatformProfile::Quiet => data.profile_quiet_epp,
|
||||
};
|
||||
warn!("setting epp to {epp:?}");
|
||||
self.check_and_set_epp(epp, true);
|
||||
@@ -694,7 +694,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();
|
||||
}
|
||||
@@ -728,7 +728,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);
|
||||
@@ -773,7 +773,7 @@ impl CtrlTask for CtrlPlatform {
|
||||
&attrs,
|
||||
&mut *platform3.config.lock().await,
|
||||
power_plugged,
|
||||
profile
|
||||
profile,
|
||||
)
|
||||
.await;
|
||||
platform3
|
||||
@@ -782,7 +782,7 @@ impl CtrlTask for CtrlPlatform {
|
||||
.ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
.await;
|
||||
|
||||
@@ -829,7 +829,7 @@ impl CtrlTask for CtrlPlatform {
|
||||
&attrs,
|
||||
&mut *ctrl.config.lock().await,
|
||||
power_plugged == 1,
|
||||
profile
|
||||
profile,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,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 {
|
||||
@@ -76,7 +76,7 @@ async fn start_daemon() -> Result<(), Box<dyn Error>> {
|
||||
platform.clone(),
|
||||
power.clone(),
|
||||
attributes.clone(),
|
||||
config.clone()
|
||||
config.clone(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
@@ -96,7 +96,7 @@ async fn start_daemon() -> Result<(), Box<dyn Error>> {
|
||||
attributes,
|
||||
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),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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