Compare commits

...

13 Commits
5.0.0 ... 5.0.5

Author SHA1 Message Date
Luke D. Jones
b525411fd3 Minor fixes in asusctl 2023-12-25 21:24:05 +13:00
Luke D. Jones
a867496f13 Re-enable ROGCC fan curves 2023-12-24 10:30:33 +13:00
Luke D. Jones
f421b8ee3b Fix to apply led effect in rogcc 2023-12-23 21:45:19 +13:00
Luke D. Jones
82780feb4b Update readme 2023-12-23 10:37:46 +13:00
Luke D. Jones
1e5443e206 Bugfix release 2023-12-22 11:39:17 +13:00
Luke D. Jones
027a591d26 Add cargo-vendor-filterer to pipeline 2023-12-17 21:44:33 +13:00
Luke D. Jones
e90375828d Fix: nuke some async deadlocks in fan-curves 2023-12-17 21:41:07 +13:00
Luke D. Jones
75b4d67072 Fix: force Anime power/wakeup disabled to prevent idiotic random wakes 2023-12-15 19:15:14 +13:00
Luke D. Jones
9aa332de3b New release 2023-12-15 11:50:49 +13:00
Luke D. Jones
5efd7fc6a7 Fix: Corrections to dbus signature for some keyboard power settings
Closes #423
2023-12-15 11:48:20 +13:00
Luke D. Jones
0aafe24a02 Fix: correctiosn to asusd.service
Closes #424
2023-12-15 11:48:20 +13:00
Luke D. Jones
dda6d343d9 Fix: correction to switching next fan profile
Closes #425
2023-12-15 11:48:18 +13:00
Luke D. Jones
6f39307080 remember how to tag releases 2023-12-12 22:00:37 +13:00
32 changed files with 619 additions and 381 deletions

View File

@@ -59,6 +59,7 @@ release:
- tags
<<: *rust_cache
script:
- cargo install cargo-vendor-filterer
- make && make vendor
artifacts:
paths:

View File

@@ -6,6 +6,36 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
## [v5.0.5]
- Resync. A release was made that was missing some commits.
## [v5.0.4]
### Changed
- Added G834JZ led config
- Fix in ROGCC to apply the actual effect changed
- Re-enable all fan curves (available) in ROGCC
- Update smithay-client-toolkit
## [v5.0.3]
### Changed
- Fix and error in platform ppt value gets
- Fix to asusctl CLI where an incorrect enum variant was used in throttle check
- Turn some error messages in to warning or info to prevent confusion
- Re-add the keyboard power settings in rogcc
- Add two new aura dbus properties for providing some basic info on aura modes/power
## [v5.0.2]
### Changed
- Fan-curves: nuke a few async deadlocks
- Anime: force power/wakeup disabled to prevent idiotic random wakes
## [v5.0.1]
### Changed
- Fix setting next fan profile
- Fix the assud.service
- Fix dbus signature of some power setting types for some keyboards
## [v5.0.0]
### Added
- Gnome 45 plugin
- Support for G513RW LED modes

431
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -4,11 +4,11 @@ default-members = ["asusctl", "asusd", "asusd-user", "cpuctl", "rog-control-cent
resolver = "2"
[workspace.package]
version = "5.0.0"
version = "5.0.5"
[workspace.dependencies]
async-trait = "^0.1"
tokio = { version = "^1.23.0", features = ["macros", "sync", "rt-multi-thread"]}
tokio = { version = "^1.23.0", default-features = false, features = ["macros", "sync"]}
concat-idents = "^1.1"
dirs = "^4.0"
smol = "^1.3"

View File

@@ -2,7 +2,7 @@
[Become a Patron!](https://www.patreon.com/bePatron?u=7602281) - [Asus Linux Website](https://asus-linux.org/)
**WARNING:** Many features are developed in tandem with kernel patches. If you see a feature is missing you either need a patched kernel, or v6.1 which has all my work merged upstream.
**WARNING:** Many features are developed in tandem with kernel patches. If you see a feature is missing you either need a patched kernel or latest release.
`asusd` is a utility for Linux to control many aspects of various ASUS laptops
but can also be used with non-asus laptops with reduced features.
@@ -11,23 +11,23 @@ Now includes a GUI, `rog-control-center`.
## Kernel support
**The minimum supported kernel version is 5.17**
**For TUF laptops, the minimum supported kernel version is 6.1**
**The minimum supported kernel version is 6.6**
## Goals
1. To provide an interface for rootless control of some system functions most users wish to control such as fan speeds, keyboard LEDs, graphics modes.
2. Enable third-party apps to use the above with dbus methods
3. To make the above as easy as possible for new users
4. Respect the users resources: be small, light, and fast
The main goal of this work is to provide a safe and easy to use abstraction over various laptop features via DBUS, and to provide some helpful defaults and other behaviour such as toggling throttle/profile on AC/battery change.
Point 3 means that the list of supported distros is very narrow - fedora is explicitly
supported. All other distros are *not* supported (while asusd might still run fine on them).
For best support use fedora 36+ Workstation.
1. Provide safe dbus interface
2. Respect the users resources: be small, light, and fast
Point 4? asusd currently uses a tiny fraction of cpu time, and less than 1Mb of ram, the way
a system-level daemon should.
a system-level daemon should. Languages such as JS and python should never be used for system level daemons (please stop).
## Keyboard LEDs
The level of support for laptops is dependent on folks submitting data to include in [`./rog-aura/data/layouts/aura_support.ron`](./rog-aura/data/layouts/aura_support.ron), typically installed in `/usr/share/asusd/aura_support.ron`. This is because the controller used for keyboards and LEDs is used across many years and many laptop models, all with different firmware configurations - the only way to track this is with the file mentioned above. Why not just enable all by default? Because it confuses people.
See the [rog-aura readme](./rog-aura/README.md) for more details.
## Discord
@@ -41,6 +41,10 @@ to this:
```
Bus 001 Device 002: ID 0b05:1866 ASUSTek Computer, Inc. N-KEY Device
```
or
```
Bus 003 Device 002: ID 0b05:19b6 ASUSTek Computer, Inc. [unknown]
```
then it may work without tweaks. Technically all other functions except the LED
and AniMe parts should work regardless of your latop make.

View File

@@ -132,9 +132,9 @@ fn do_parsed(
println!("{}", CliStart::usage());
println!();
if let Some(cmdlist) = CliStart::command_list() {
let dev_type = dbus.proxies().aura().device_type()?;
let commands: Vec<String> = cmdlist.lines().map(|s| s.to_owned()).collect();
for command in commands.iter().filter(|command| {
let dev_type = dbus.proxies().aura().device_type().unwrap();
if !dev_type.is_old_style()
&& !dev_type.is_tuf_style()
&& command.trim().starts_with("led-pow-1")
@@ -420,8 +420,8 @@ fn handle_led_mode(
if let Some(cmdlist) = LedModeCommand::command_list() {
let commands: Vec<String> = cmdlist.lines().map(|s| s.to_owned()).collect();
let modes = dbus.proxies().aura().supported_basic_modes()?;
for command in commands.iter().filter(|command| {
let modes = dbus.proxies().aura().supported_modes().unwrap();
for mode in &modes {
if command
.trim()
@@ -450,7 +450,7 @@ fn handle_led_mode(
}
if mode.next_mode {
let mode = dbus.proxies().aura().led_mode()?;
let modes = dbus.proxies().aura().supported_modes()?;
let modes = dbus.proxies().aura().supported_basic_modes()?;
let mut pos = modes.iter().position(|m| *m == mode).unwrap() + 1;
if pos >= modes.len() {
pos = 0;
@@ -458,7 +458,7 @@ fn handle_led_mode(
dbus.proxies().aura().set_led_mode(modes[pos])?;
} else if mode.prev_mode {
let mode = dbus.proxies().aura().led_mode()?;
let modes = dbus.proxies().aura().supported_modes()?;
let modes = dbus.proxies().aura().supported_basic_modes()?;
let mut pos = modes.iter().position(|m| *m == mode).unwrap();
if pos == 0 {
pos = modes.len() - 1;
@@ -662,7 +662,7 @@ fn handle_throttle_profile(
supported: &[Properties],
cmd: &ProfileCommand,
) -> Result<(), Box<dyn std::error::Error>> {
if !supported.contains(&Properties::DgpuDisable) {
if !supported.contains(&Properties::PlatformPolicy) {
println!("Profiles not supported by either this kernel or by the laptop.");
return Err(ProfileError::NotSupported.into());
}

View File

@@ -21,6 +21,7 @@ rog_platform = { path = "../rog-platform" }
rog_profiles = { path = "../rog-profiles" }
dmi_id = { path = "../dmi-id" }
futures-lite = "*"
udev.workspace = true
async-trait.workspace = true
tokio.workspace = true

View File

@@ -73,6 +73,20 @@ impl CtrlAnime {
return Err(RogError::Anime(AnimeError::NoDevice));
};
// TODO: something better to set wakeups disabled
if matches!(node, Node::Usb(_)) {
if let Ok(mut enumerator) = udev::Enumerator::new() {
enumerator.match_subsystem("usb").ok();
enumerator.match_attribute("idProduct", "193b").ok();
if let Ok(mut enumer) = enumerator.scan_devices() {
if let Some(mut dev) = enumer.next() {
dev.set_attribute_value("power/wakeup", "disabled").ok();
}
}
}
}
let mut anime_type = get_anime_type()?;
if let AnimeType::Unknown = anime_type {
if let Some(model) = config.model_override {

View File

@@ -277,6 +277,15 @@ impl crate::CtrlTask for CtrlAnimeZbus {
async move {
let lock = inner.lock().await;
if lock.config.display_enabled {
lock.node
.write_bytes(&pkt_set_enable_powersave_anim(
!(sleeping && lock.config.off_when_suspended),
))
.map_err(|err| {
warn!("create_sys_event_tasks::off_when_suspended {}", err);
})
.ok();
lock.thread_exit.store(true, Ordering::Release); // ensure clean slate
lock.node
.write_bytes(&pkt_set_enable_display(
@@ -316,8 +325,16 @@ impl crate::CtrlTask for CtrlAnimeZbus {
async move {
let lock = inner.lock().await;
if lock.config.off_when_lid_closed {
if lock.config.builtin_anims_enabled {
lock.node
.write_bytes(&pkt_set_enable_powersave_anim(!lid_closed))
.map_err(|err| {
warn!("create_sys_event_tasks::off_when_suspended {}", err);
})
.ok();
}
lock.node
.write_bytes(&pkt_set_enable_display(lid_closed))
.write_bytes(&pkt_set_enable_display(!lid_closed))
.map_err(|err| {
warn!("create_sys_event_tasks::off_when_lid_closed {}", err);
})
@@ -331,6 +348,14 @@ impl crate::CtrlTask for CtrlAnimeZbus {
async move {
let lock = inner.lock().await;
if lock.config.off_when_unplugged {
if lock.config.builtin_anims_enabled {
lock.node
.write_bytes(&pkt_set_enable_powersave_anim(power_plugged))
.map_err(|err| {
warn!("create_sys_event_tasks::off_when_suspended {}", err);
})
.ok();
}
lock.node
.write_bytes(&pkt_set_enable_display(power_plugged))
.map_err(|err| {

View File

@@ -25,13 +25,13 @@ pub struct CtrlKbdLed {
pub led_prod: AuraDevice,
pub led_node: LEDNode,
pub sysfs_node: KeyboardLed,
pub supported_modes: LaptopLedData,
pub supported_data: LaptopLedData,
pub per_key_mode_active: bool,
pub config: AuraConfig,
}
impl CtrlKbdLed {
pub fn new(supported_modes: LaptopLedData) -> Result<Self, RogError> {
pub fn new(supported_basic_modes: LaptopLedData) -> Result<Self, RogError> {
let mut led_prod = AuraDevice::Unknown;
let mut usb_node = None;
for prod in ASUS_KEYBOARD_DEVICES {
@@ -97,7 +97,7 @@ impl CtrlKbdLed {
let mut new_set = Vec::new();
// only reuse a zone mode if the mode is supported
for mode in loaded {
if supported_modes.basic_modes.contains(&mode.mode) {
if supported_basic_modes.basic_modes.contains(&mode.mode) {
new_set.push(mode.clone());
}
}
@@ -111,7 +111,7 @@ impl CtrlKbdLed {
led_prod,
led_node, // on TUF this is the same as rgb_led / kd_brightness
sysfs_node: rgb_led, // If was none then we already returned above
supported_modes,
supported_data: supported_basic_modes,
per_key_mode_active: false,
config: config_loaded,
};
@@ -245,7 +245,7 @@ impl CtrlKbdLed {
/// exists.
fn create_multizone_default(&mut self) -> Result<(), RogError> {
let mut default = vec![];
for (i, tmp) in self.supported_modes.basic_zones.iter().enumerate() {
for (i, tmp) in self.supported_data.basic_zones.iter().enumerate() {
default.push(AuraEffect {
mode: self.config.current_mode,
zone: *tmp,
@@ -285,7 +285,7 @@ mod tests {
fn create_multizone_if_no_config() {
// Checking to ensure set_mode errors when unsupported modes are tried
let config = AuraConfig::from_default_support(AuraDevice::X19b6, &LaptopLedData::default());
let supported_modes = LaptopLedData {
let supported_basic_modes = LaptopLedData {
board_name: String::new(),
layout_name: "ga401".to_owned(),
basic_modes: vec![AuraModeNum::Static],
@@ -297,7 +297,7 @@ mod tests {
led_prod: AuraDevice::X19b6,
led_node: LEDNode::None,
sysfs_node: KeyboardLed::default(),
supported_modes,
supported_data: supported_basic_modes,
per_key_mode_active: false,
config,
};
@@ -306,8 +306,8 @@ mod tests {
assert!(controller.create_multizone_default().is_err());
assert!(controller.config.multizone.is_none());
controller.supported_modes.basic_zones.push(AuraZone::Key1);
controller.supported_modes.basic_zones.push(AuraZone::Key2);
controller.supported_data.basic_zones.push(AuraZone::Key1);
controller.supported_data.basic_zones.push(AuraZone::Key2);
assert!(controller.create_multizone_default().is_ok());
assert!(controller.config.multizone.is_some());
@@ -323,7 +323,7 @@ mod tests {
fn next_mode_create_multizone_if_no_config() {
// Checking to ensure set_mode errors when unsupported modes are tried
let config = AuraConfig::from_default_support(AuraDevice::X19b6, &LaptopLedData::default());
let supported_modes = LaptopLedData {
let supported_basic_modes = LaptopLedData {
board_name: String::new(),
layout_name: "ga401".to_owned(),
basic_modes: vec![AuraModeNum::Static],
@@ -335,7 +335,7 @@ mod tests {
led_prod: AuraDevice::X19b6,
led_node: LEDNode::None,
sysfs_node: KeyboardLed::default(),
supported_modes,
supported_data: supported_basic_modes,
per_key_mode_active: false,
config,
};

View File

@@ -5,6 +5,7 @@ use async_trait::async_trait;
use config_traits::StdConfig;
use log::{debug, error, info, warn};
use rog_aura::advanced::UsbPackets;
use rog_aura::aura_detection::PowerZones;
use rog_aura::usb::{AuraDevice, AuraPowerDev};
use rog_aura::{AuraEffect, AuraModeNum, AuraZone, LedBrightness};
use zbus::export::futures_util::lock::{Mutex, MutexGuard};
@@ -78,11 +79,23 @@ impl CtrlAuraZbus {
/// The total available modes
#[dbus_interface(property)]
async fn supported_modes(&self) -> Result<Vec<AuraModeNum>, ZbErr> {
async fn supported_basic_modes(&self) -> Result<Vec<AuraModeNum>, ZbErr> {
let ctrl = self.0.lock().await;
Ok(ctrl.config.builtins.keys().cloned().collect())
}
#[dbus_interface(property)]
async fn supported_basic_zones(&self) -> Result<Vec<AuraZone>, ZbErr> {
let ctrl = self.0.lock().await;
Ok(ctrl.supported_data.basic_zones.clone())
}
#[dbus_interface(property)]
async fn supported_power_zones(&self) -> Result<Vec<PowerZones>, ZbErr> {
let ctrl = self.0.lock().await;
Ok(ctrl.supported_data.power_zones.clone())
}
/// The current mode data
#[dbus_interface(property)]
async fn led_mode(&self) -> Result<AuraModeNum, ZbErr> {
@@ -126,9 +139,9 @@ impl CtrlAuraZbus {
#[dbus_interface(property)]
async fn set_led_mode_data(&mut self, effect: AuraEffect) -> Result<(), ZbErr> {
let mut ctrl = self.0.lock().await;
if !ctrl.supported_modes.basic_modes.contains(&effect.mode)
if !ctrl.supported_data.basic_modes.contains(&effect.mode)
|| effect.zone != AuraZone::None
&& !ctrl.supported_modes.basic_zones.contains(&effect.zone)
&& !ctrl.supported_data.basic_zones.contains(&effect.zone)
{
return Err(ZbErr::NotSupported(format!(
"The Aura effect is not supported: {effect:?}"

View File

@@ -109,19 +109,18 @@ impl CtrlFanCurveZbus {
}
pub async fn update_profiles_from_config(&self) {
let mut fan_curves = self.fan_curves.lock().await;
let config = self.config.lock().await;
fan_curves.balanced = config.balanced.clone();
fan_curves.performance = config.performance.clone();
fan_curves.quiet = config.quiet.clone();
self.fan_curves.lock().await.balanced = self.config.lock().await.balanced.clone();
self.fan_curves.lock().await.performance = self.config.lock().await.performance.clone();
self.fan_curves.lock().await.quiet = self.config.lock().await.quiet.clone();
}
/// Because this locks both config and fan_curves, it means nothing else can
/// hold a lock across this function call. Stupid choice to do this and
/// needs to be fixed.
pub async fn update_config_from_profiles(&self) {
let fan_curves = self.fan_curves.lock().await;
let mut config = self.config.lock().await;
config.balanced = fan_curves.balanced.clone();
config.performance = fan_curves.performance.clone();
config.quiet = fan_curves.quiet.clone();
self.config.lock().await.balanced = self.fan_curves.lock().await.balanced.clone();
self.config.lock().await.performance = self.fan_curves.lock().await.performance.clone();
self.config.lock().await.quiet = self.fan_curves.lock().await.quiet.clone();
}
}
@@ -134,10 +133,14 @@ impl CtrlFanCurveZbus {
profile: PlatformPolicy,
enabled: bool,
) -> zbus::fdo::Result<()> {
let mut fan_curves = self.fan_curves.lock().await;
fan_curves.set_profile_curves_enabled(profile, enabled);
fan_curves.write_profile_curve_to_platform(profile, &mut find_fan_curve_node()?)?;
self.fan_curves
.lock()
.await
.set_profile_curves_enabled(profile, enabled);
self.fan_curves
.lock()
.await
.write_profile_curve_to_platform(profile, &mut find_fan_curve_node()?)?;
self.update_config_from_profiles().await;
self.config.lock().await.write();
Ok(())
@@ -151,10 +154,14 @@ impl CtrlFanCurveZbus {
fan: FanCurvePU,
enabled: bool,
) -> zbus::fdo::Result<()> {
let mut fan_curves = self.fan_curves.lock().await;
fan_curves.set_profile_fan_curve_enabled(profile, fan, enabled);
fan_curves.write_profile_curve_to_platform(profile, &mut find_fan_curve_node()?)?;
self.fan_curves
.lock()
.await
.set_profile_fan_curve_enabled(profile, fan, enabled);
self.fan_curves
.lock()
.await
.write_profile_curve_to_platform(profile, &mut find_fan_curve_node()?)?;
self.update_config_from_profiles().await;
self.config.lock().await.write();
Ok(())
@@ -165,9 +172,13 @@ impl CtrlFanCurveZbus {
&mut self,
profile: PlatformPolicy,
) -> zbus::fdo::Result<Vec<CurveData>> {
let fan_curves = self.fan_curves.lock().await;
let curve = fan_curves.get_fan_curves_for(profile);
Ok(curve.to_vec())
let curve = self
.fan_curves
.lock()
.await
.get_fan_curves_for(profile)
.to_vec();
Ok(curve)
}
/// Set the fan curve for the specified profile.
@@ -177,13 +188,16 @@ impl CtrlFanCurveZbus {
profile: PlatformPolicy,
curve: CurveData,
) -> zbus::fdo::Result<()> {
let mut fan_curves = self.fan_curves.lock().await;
fan_curves.save_fan_curve(curve, profile)?;
fan_curves.write_profile_curve_to_platform(profile, &mut find_fan_curve_node()?)?;
self.fan_curves
.lock()
.await
.save_fan_curve(curve, profile)?;
self.fan_curves
.lock()
.await
.write_profile_curve_to_platform(profile, &mut find_fan_curve_node()?)?;
self.update_config_from_profiles().await;
self.config.lock().await.write();
Ok(())
}
@@ -193,10 +207,11 @@ impl CtrlFanCurveZbus {
/// Each platform_profile has a different default and the defualt can be
/// read only for the currently active profile.
async fn set_active_curve_to_defaults(&mut self) -> zbus::fdo::Result<()> {
let mut fan_curves = self.fan_curves.lock().await;
let active = self.platform.get_throttle_thermal_policy()?;
fan_curves.set_active_curve_to_defaults(active.into(), &mut find_fan_curve_node()?)?;
self.fan_curves
.lock()
.await
.set_active_curve_to_defaults(active.into(), &mut find_fan_curve_node()?)?;
self.update_config_from_profiles().await;
self.config.lock().await.write();
Ok(())
@@ -208,15 +223,16 @@ impl CtrlFanCurveZbus {
/// Each platform_profile has a different default and the defualt can be
/// read only for the currently active profile.
async fn reset_profile_curves(&self, profile: PlatformPolicy) -> zbus::fdo::Result<()> {
let mut fan_curves = self.fan_curves.lock().await;
let active = self
.platform
.get_throttle_thermal_policy()
.unwrap_or(PlatformPolicy::Balanced.into());
self.platform.set_throttle_thermal_policy(profile.into())?;
fan_curves.set_active_curve_to_defaults(active.into(), &mut find_fan_curve_node()?)?;
self.fan_curves
.lock()
.await
.set_active_curve_to_defaults(active.into(), &mut find_fan_curve_node()?)?;
self.platform.set_throttle_thermal_policy(active)?;
self.update_config_from_profiles().await;

View File

@@ -4,7 +4,7 @@ use std::sync::Arc;
use async_trait::async_trait;
use config_traits::StdConfig;
use log::{debug, error, info, warn};
use rog_platform::cpu::CPUControl;
use rog_platform::cpu::{CPUControl, CPUGovernor};
use rog_platform::platform::{GpuMode, PlatformPolicy, Properties, RogPlatform};
use rog_platform::power::AsusPower;
use zbus::export::futures_util::lock::Mutex;
@@ -33,7 +33,7 @@ macro_rules! platform_get_value {
})
})
} else {
error!("RogPlatform: {} not supported", $prop_name);
info!("RogPlatform: {} not supported", $prop_name);
return Err(FdoErr::NotSupported(format!("RogPlatform: {} not supported", $prop_name)));
}
})
@@ -45,9 +45,9 @@ macro_rules! platform_get_value_if_some {
concat_idents::concat_idents!(has = has_, $property {
if $self.platform.has() {
let lock = $self.config.lock().await;
Ok(lock.ppt_pl1_spl.unwrap_or($default))
Ok(lock.$property.unwrap_or($default))
} else {
error!("RogPlatform: {} not supported", $prop_name);
info!("RogPlatform: {} not supported", $prop_name);
return Err(FdoErr::NotSupported(format!("RogPlatform: {} not supported", $prop_name)));
}
})
@@ -69,7 +69,7 @@ macro_rules! platform_set_bool {
lock.write();
Ok(())
} else {
error!("RogPlatform: {} not supported", $prop_name);
info!("RogPlatform: {} not supported", $prop_name);
Err(FdoErr::NotSupported(format!("RogPlatform: {} not supported", $prop_name)))
}
})
@@ -180,6 +180,23 @@ impl CtrlPlatform {
}
}
fn check_and_set_epp(&self, profile: PlatformPolicy) {
info!("PlatformPolicy setting EPP");
if let Some(cpu) = self.cpu_control.as_ref() {
if let Ok(epp) = cpu.get_available_epp() {
debug!("Available EPP: {epp:?}");
if epp.contains(&profile.into()) {
debug!("Setting {profile:?}");
cpu.set_epp(profile.into()).ok();
} else if let Ok(gov) = cpu.get_governor() {
if gov != CPUGovernor::Powersave {
warn!("powersave governor is not is use, you should use it.");
}
}
}
}
}
async fn update_policy_ac_or_bat(&self, power_plugged: bool) {
let profile = if power_plugged {
self.config.lock().await.platform_policy_on_ac
@@ -189,9 +206,7 @@ impl CtrlPlatform {
self.platform
.set_throttle_thermal_policy(profile.into())
.ok();
if let Some(cpu) = self.cpu_control.as_ref() {
cpu.set_epp(profile.into()).ok();
}
self.check_and_set_epp(profile);
}
}
@@ -322,12 +337,10 @@ impl CtrlPlatform {
let policy: PlatformPolicy =
platform_get_value!(self, throttle_thermal_policy, "throttle_thermal_policy")
.map(|n| n.into())?;
let policy = PlatformPolicy::next(&policy);
if self.platform.has_throttle_thermal_policy() {
if let Some(cpu) = self.cpu_control.as_ref() {
info!("PlatformPolicy setting EPP");
cpu.set_epp(policy.into())?
}
self.check_and_set_epp(policy);
self.platform
.set_throttle_thermal_policy(policy.into())
.map_err(|err| {
@@ -353,10 +366,7 @@ impl CtrlPlatform {
async fn set_throttle_thermal_policy(&mut self, policy: PlatformPolicy) -> Result<(), FdoErr> {
// TODO: watch for external changes
if self.platform.has_throttle_thermal_policy() {
if let Some(cpu) = self.cpu_control.as_ref() {
info!("PlatformPolicy setting EPP");
cpu.set_epp(policy.into())?
}
self.check_and_set_epp(policy);
self.config.lock().await.platform_policy_to_restore = policy;
self.platform
.set_throttle_thermal_policy(policy.into())
@@ -687,10 +697,7 @@ impl CtrlTask for CtrlPlatform {
error!("Platform: get_throttle_thermal_policy error: {e}");
})
{
if let Some(cpu) = ctrl.cpu_control.as_ref() {
info!("PlatformPolicy setting EPP");
cpu.set_epp(profile.into()).ok();
}
ctrl.check_and_set_epp(profile);
ctrl.config.lock().await.platform_policy_to_restore = profile;
}
}

View File

@@ -2,7 +2,7 @@
Description=ASUS Notebook Control
StartLimitInterval=500
StartLimitBurst=5
After=nvidia-powerd.service,systemd-udevd.service
After=nvidia-powerd.service systemd-udevd.service
[Service]
Environment=IS_SERVICE=1

View File

@@ -399,6 +399,14 @@
advanced_type: PerKey,
power_zones: [Keyboard, Lightbar],
),
(
board_name: "G834JZ",
layout_name: "g814ji-per-key",
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
basic_zones: [],
advanced_type: PerKey,
power_zones: [Keyboard, Lightbar, Logo, RearGlow],
),
(
board_name: "GA401Q",
layout_name: "ga401q",

View File

@@ -28,7 +28,7 @@ pub struct LedSupportFile(Vec<LaptopLedData>);
#[cfg_attr(
feature = "dbus",
derive(Type, Value, OwnedValue),
zvariant(signature = "s")
zvariant(signature = "u")
)]
#[derive(Serialize, Deserialize, PartialEq, Eq, Debug, Default, Copy, Clone)]
pub enum PowerZones {

View File

@@ -303,7 +303,7 @@ impl From<AuraEffect> for AuraModeNum {
#[cfg_attr(
feature = "dbus",
derive(Type, Value, OwnedValue),
zvariant(signature = "s")
zvariant(signature = "u")
)]
#[derive(Debug, Default, Copy, Clone, PartialEq, Eq, Deserialize, Serialize)]
pub enum AuraZone {

View File

@@ -137,7 +137,7 @@ pub struct AuraPowerDev {
#[cfg_attr(
feature = "dbus",
derive(Type, Value, OwnedValue),
zvariant(signature = "s")
zvariant(signature = "y")
)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[repr(u32)]
@@ -172,7 +172,7 @@ impl AuraDevTuf {
#[cfg_attr(
feature = "dbus",
derive(Type, Value, OwnedValue),
zvariant(signature = "s")
zvariant(signature = "y")
)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[repr(u32)]

View File

@@ -10,8 +10,9 @@ edition = "2021"
#mocking = []
[dependencies]
egui = { git = "https://github.com/emilk/egui", rev = "b8e798777de519de3a1878798097ab2ab0bd4def"}
eframe = { git = "https://github.com/emilk/egui", rev = "b8e798777de519de3a1878798097ab2ab0bd4def"}
egui = "0.24.1"
eframe = "0.24.1"
egui_plot = "0.24.1"
# egui = { path = "../../egui/crates/egui" }
# eframe = { path = "../../egui/crates/eframe" }

View File

@@ -6,9 +6,9 @@ use std::sync::{Arc, Mutex};
use std::thread;
use std::time::Duration;
use eframe::IconData;
use eframe::HardwareAcceleration;
use gumdrop::Options;
use log::{debug, error, info, warn, LevelFilter};
use log::{debug, error, warn, LevelFilter};
use rog_aura::aura_detection::{LaptopLedData, LedSupportFile};
use rog_aura::layouts::KeyLayout;
use rog_control_center::cli_options::CliStart;
@@ -29,7 +29,8 @@ const DATA_DIR: &str = "/usr/share/rog-gui/";
#[cfg(feature = "mocking")]
const DATA_DIR: &str = env!("CARGO_MANIFEST_DIR");
const BOARD_NAME: &str = "/sys/class/dmi/id/board_name";
const APP_ICON_PATH: &str = "/usr/share/icons/hicolor/512x512/apps/rog-control-center.png";
// const APP_ICON_PATH: &str =
// "/usr/share/icons/hicolor/512x512/apps/rog-control-center.png";
fn main() -> Result<()> {
let args: Vec<String> = args().skip(1).collect();
@@ -60,12 +61,10 @@ fn main() -> Result<()> {
let native_options = eframe::NativeOptions {
vsync: true,
decorated: true,
transparent: false,
min_window_size: Some(egui::vec2(960.0, 670.0)),
max_window_size: Some(egui::vec2(960.0, 670.0)),
hardware_acceleration: HardwareAcceleration::Preferred,
// min_window_size: Some(egui::vec2(960.0, 670.0)),
// max_window_size: Some(egui::vec2(960.0, 670.0)),
run_and_return: true,
icon_data: Some(load_icon()),
..Default::default()
};
@@ -202,7 +201,9 @@ fn main() -> Result<()> {
"ROG Control Center",
native_options.clone(),
Box::new(move |cc| {
Box::new(RogApp::new(Config::load().unwrap(), states, cc).unwrap())
let cfg = Config::load().unwrap();
let app = RogApp::new(cfg, states, cc);
Box::new(app.unwrap())
}),
)?;
@@ -261,37 +262,38 @@ fn setup_page_state_and_notifs(
}
/// Bah.. the icon dosn't work on wayland anyway, but we'll leave it in for now.
fn load_icon() -> IconData {
let path = PathBuf::from(APP_ICON_PATH);
let mut rgba = Vec::new();
let mut height = 512;
let mut width = 512;
if path.exists() {
if let Ok(data) = std::fs::read(path)
.map_err(|e| error!("Error reading app icon: {e:?}"))
.map_err(|e| error!("Error opening app icon: {e:?}"))
{
let data = std::io::Cursor::new(data);
let decoder = png_pong::Decoder::new(data).unwrap().into_steps();
let png_pong::Step { raster, delay: _ } = decoder.last().unwrap().unwrap();
// fn load_icon() -> IconData {
// let path = PathBuf::from(APP_ICON_PATH);
// let mut rgba = Vec::new();
// let mut height = 512;
// let mut width = 512;
// if path.exists() {
// if let Ok(data) = std::fs::read(path)
// .map_err(|e| error!("Error reading app icon: {e:?}"))
// .map_err(|e| error!("Error opening app icon: {e:?}"))
// {
// let data = std::io::Cursor::new(data);
// let decoder = png_pong::Decoder::new(data).unwrap().into_steps();
// let png_pong::Step { raster, delay: _ } =
// decoder.last().unwrap().unwrap();
if let png_pong::PngRaster::Rgba8(ras) = raster {
rgba = ras.as_u8_slice().to_vec();
width = ras.width();
height = ras.height();
info!("Loaded app icon. Not actually supported in Wayland yet");
}
}
} else {
error!("Missing {APP_ICON_PATH}");
}
// if let png_pong::PngRaster::Rgba8(ras) = raster {
// rgba = ras.as_u8_slice().to_vec();
// width = ras.width();
// height = ras.height();
// info!("Loaded app icon. Not actually supported in Wayland
// yet"); }
// }
// } else {
// error!("Missing {APP_ICON_PATH}");
// }
IconData {
height,
width,
rgba,
}
}
// IconData {
// height,
// width,
// rgba,
// }
// }
fn do_cli_help(parsed: &CliStart) -> bool {
if parsed.help {

View File

@@ -43,31 +43,6 @@ impl RogApp {
ui.label(RichText::new(format!("{}", current)).strong());
});
// ui.horizontal(|ui| {
// ui.label("Enabled fan-curves: ");
// let mut fan_curve_enable = |profile: Profile, fan: FanCurvePU, mut
// checked: bool| { if ui
// .add(egui::Checkbox::new(&mut checked, format!("{:?}", fan)))
// .changed()
// {
// dbus.proxies()
// .profile()
// .set_fan_curves_enabled(profile, checked)
// .map_err(|err| {
// *do_error = Some(err.to_string());
// })
// .ok();
// changed = true;
// }
// };
// if let Some(curves) = curves.curves.get_mut(&current) {
// for curve in curves.iter_mut() {
// fan_curve_enable(current, curve.fan, curve.enabled);
// }
// }
// });
ui.horizontal(|ui| {
ui.label("Enabled fan-curves: ");
let mut checked = false;

View File

@@ -1,5 +1,5 @@
use crate::system_state::SystemState;
use crate::widgets::{anime_power_group, platform_profile, rog_bios_group};
use crate::widgets::{anime_power_group, aura_power_group, platform_profile, rog_bios_group};
use crate::RogApp;
impl RogApp {
@@ -22,7 +22,7 @@ impl RogApp {
ui.vertical(|ui| {
ui.separator();
if self.supported_interfaces.contains(&"Aura".to_string()) {
// aura_power_group(states, ui);
aura_power_group(states, ui);
}
});
ui.end_row();

View File

@@ -1,4 +1,4 @@
use egui::{Button, RichText};
use egui::RichText;
pub struct AppErrorShow {
error: String,
@@ -11,7 +11,7 @@ impl AppErrorShow {
}
impl eframe::App for AppErrorShow {
fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
egui::CentralPanel::default().show(ctx, |ui| {
ui.heading("ROG ERROR");
@@ -19,18 +19,20 @@ impl eframe::App for AppErrorShow {
ui.label(RichText::new(format!("The error was: {:?}", self.error)).size(22.0));
});
egui::TopBottomPanel::bottom("error_bar_2")
.default_height(26.0)
.show(ctx, |ui| {
ui.with_layout(egui::Layout::right_to_left(egui::Align::TOP), |ui| {
if ui
.add(Button::new(RichText::new("Okay").size(20.0)))
.clicked()
{
frame.close();
}
});
});
// egui::TopBottomPanel::bottom("error_bar_2")
// .default_height(26.0)
// .show(ctx, |ui| {
// ui.
// with_layout(egui::Layout::right_to_left(egui::Align::TOP), |ui| {
// if ui
// .add(Button::new(RichText::new("Okay").size(20.0)))
// .clicked()
// {
// // frame.close();
// // ui.close_menu();
// }
// });
// });
});
}
}

View File

@@ -6,9 +6,10 @@ use std::time::SystemTime;
use egui::Vec2;
use log::error;
use rog_anime::{Animations, DeviceState};
use rog_aura::aura_detection::PowerZones;
use rog_aura::layouts::KeyLayout;
use rog_aura::usb::AuraPowerDev;
use rog_aura::{AuraEffect, AuraModeNum, LedBrightness};
use rog_aura::usb::{AuraDevice, AuraPowerDev};
use rog_aura::{AuraEffect, AuraModeNum, AuraZone, LedBrightness};
use rog_platform::platform::{GpuMode, PlatformPolicy};
use rog_profiles::fan_curve_set::CurveData;
use rog_profiles::FanCurvePU;
@@ -79,20 +80,21 @@ impl FanCurvesState {
PlatformPolicy::Performance,
];
let mut available_fans = HashSet::new();
let mut curves: BTreeMap<PlatformPolicy, Vec<CurveData>> = BTreeMap::new();
for p in &profiles {
if let Ok(curve) = dbus.proxies().fan_curves().fan_curve_data(*p) {
if available_fans.is_empty() {
for fan in &curve {
available_fans.insert(fan.fan);
}
}
curves.insert(*p, curve);
} else {
curves.insert(*p, Default::default());
}
}
let available_fans = HashSet::new();
// for fan in supported.platform_profile.fans.iter() {
// available_fans.insert(*fan);
// }
let show_curve = dbus.proxies().platform().throttle_thermal_policy()?;
Ok(Self {
@@ -110,6 +112,9 @@ pub struct AuraState {
pub current_mode: AuraModeNum,
pub modes: BTreeMap<AuraModeNum, AuraEffect>,
pub enabled: AuraPowerDev,
pub dev_type: AuraDevice,
pub supported_basic_zones: Vec<AuraZone>,
pub supported_power_zones: Vec<PowerZones>,
/// Brightness from 0-3
pub bright: LedBrightness,
pub wave_red: [u8; 22],
@@ -132,6 +137,17 @@ impl AuraState {
BTreeMap::new()
},
enabled: dbus.proxies().aura().led_power().unwrap_or_default(),
supported_basic_zones: dbus
.proxies()
.aura()
.supported_basic_zones()
.unwrap_or_default(),
supported_power_zones: dbus
.proxies()
.aura()
.supported_power_zones()
.unwrap_or_default(),
dev_type: dbus.proxies().aura().device_type().unwrap_or_default(),
bright: dbus.proxies().aura().brightness().unwrap_or_default(),
wave_red: [0u8; 22],
wave_green: [0u8; 22],

View File

@@ -224,12 +224,11 @@ pub fn aura_modes_group(states: &mut SystemState, freq: &mut Arc<AtomicU8>, ui:
if changed {
states.aura.current_mode = selected;
states
.asus_dbus
.proxies()
.aura()
.set_led_mode(states.aura.modes.get(&selected).unwrap().mode)
.set_led_mode_data(states.aura.modes.get(&selected).unwrap().clone())
.map_err(|err| {
states.error = Some(err.to_string());
})

View File

@@ -4,24 +4,23 @@ use rog_aura::usb::{AuraDevRog1, AuraDevTuf, AuraDevice, AuraPowerDev};
use crate::system_state::SystemState;
pub fn aura_power_group(supported: &SupportedFunctions, states: &mut SystemState, ui: &mut Ui) {
pub fn aura_power_group(states: &mut SystemState, ui: &mut Ui) {
ui.heading("Keyboard LED power settings");
if supported.keyboard_led.dev_id.is_old_style() || supported.keyboard_led.dev_id.is_tuf_style()
{
aura_power1(supported, states, ui);
} else if supported.keyboard_led.dev_id.is_new_style() {
aura_power2(supported, states, ui);
if states.aura.dev_type.is_old_style() || states.aura.dev_type.is_tuf_style() {
aura_power1(states, ui);
} else if states.aura.dev_type.is_new_style() {
aura_power2(states, ui);
}
}
fn aura_power1(supported: &SupportedFunctions, states: &mut SystemState, ui: &mut Ui) {
fn aura_power1(states: &mut SystemState, ui: &mut Ui) {
let enabled_states = &mut states.aura.enabled;
let mut boot = enabled_states.old_rog.contains(&AuraDevRog1::Boot);
let mut sleep = enabled_states.old_rog.contains(&AuraDevRog1::Sleep);
let mut keyboard = enabled_states.old_rog.contains(&AuraDevRog1::Keyboard);
let mut lightbar = enabled_states.old_rog.contains(&AuraDevRog1::Lightbar);
if supported.keyboard_led.dev_id == AuraDevice::Tuf {
if states.aura.dev_type == AuraDevice::Tuf {
boot = enabled_states.tuf.contains(&AuraDevTuf::Boot);
sleep = enabled_states.tuf.contains(&AuraDevTuf::Sleep);
keyboard = enabled_states.tuf.contains(&AuraDevTuf::Awake);
@@ -58,7 +57,7 @@ fn aura_power1(supported: &SupportedFunctions, states: &mut SystemState, ui: &mu
if ui.toggle_value(&mut keyboard, "Keyboard").changed() {
changed = true;
}
if !supported.keyboard_led.basic_zones.is_empty()
if !states.aura.supported_basic_zones.is_empty()
&& ui.toggle_value(&mut lightbar, "Lightbar").changed()
{
changed = true;
@@ -93,7 +92,7 @@ fn aura_power1(supported: &SupportedFunctions, states: &mut SystemState, ui: &mu
});
if changed {
if supported.keyboard_led.dev_id == AuraDevice::Tuf {
if states.aura.dev_type == AuraDevice::Tuf {
let mut enabled = Vec::new();
let mut disabled = Vec::new();
@@ -132,7 +131,7 @@ fn aura_power1(supported: &SupportedFunctions, states: &mut SystemState, ui: &mu
.asus_dbus
.proxies()
.aura()
.set_led_power(options, enable)
.set_led_power((options, enable))
.map_err(|err| {
states.error = Some(err.to_string());
})
@@ -168,7 +167,7 @@ fn aura_power1(supported: &SupportedFunctions, states: &mut SystemState, ui: &mu
modify_x1866(boot, AuraDevRog1::Boot);
modify_x1866(sleep, AuraDevRog1::Sleep);
modify_x1866(keyboard, AuraDevRog1::Keyboard);
if !supported.keyboard_led.basic_zones.is_empty() {
if !states.aura.supported_basic_zones.is_empty() {
modify_x1866(lightbar, AuraDevRog1::Lightbar);
}
@@ -182,7 +181,7 @@ fn aura_power1(supported: &SupportedFunctions, states: &mut SystemState, ui: &mu
.asus_dbus
.proxies()
.aura()
.set_led_power(options, enable)
.set_led_power((options, enable))
.map_err(|err| {
states.error = Some(err.to_string());
})
@@ -194,7 +193,7 @@ fn aura_power1(supported: &SupportedFunctions, states: &mut SystemState, ui: &mu
}
}
fn aura_power2(supported: &SupportedFunctions, states: &mut SystemState, ui: &mut Ui) {
fn aura_power2(states: &mut SystemState, ui: &mut Ui) {
let AuraPower {
keyboard,
logo,
@@ -208,7 +207,7 @@ fn aura_power2(supported: &SupportedFunctions, states: &mut SystemState, ui: &mu
let mut changed = false;
let mut item = |power: &mut KbAuraPowerState, ui: &mut Ui| {
ui.vertical(|ui| {
if supported.keyboard_led.power_zones.contains(&power.zone) {
if states.aura.supported_power_zones.contains(&power.zone) {
ui.horizontal_wrapped(|ui| {
ui.label(RichText::new(format!("{:?}", power.zone)).size(14.0));
});
@@ -247,7 +246,7 @@ fn aura_power2(supported: &SupportedFunctions, states: &mut SystemState, ui: &mu
.asus_dbus
.proxies()
.aura()
.set_led_power(options, enable)
.set_led_power((options, enable))
.map_err(|err| {
states.error = Some(err.to_string());
})

View File

@@ -1,5 +1,5 @@
use egui::plot::Points;
use egui::Ui;
use egui_plot::Points;
use rog_platform::platform::PlatformPolicy;
use rog_profiles::fan_curve_set::CurveData;
use rog_profiles::FanCurvePU;
@@ -60,7 +60,7 @@ pub fn fan_graphs(
let curve = curves.curves.get_mut(&curves.show_curve).unwrap();
use egui::plot::{Line, Plot};
use egui_plot::{Line, Plot};
let mut data = &mut CurveData::default();
for c in curve {
@@ -116,8 +116,8 @@ pub fn fan_graphs(
.allow_scroll(false)
.allow_drag(false)
.allow_boxed_zoom(false)
.x_axis_formatter(|d, _r| format!("{}", d))
.y_axis_formatter(|d, _r| format!("{:.*}%", 1, d))
// .x_axis_formatter(|d, _r| format!("{}", d))
// .y_axis_formatter(|d, _r| format!("{:.*}%", 1, d))
.label_formatter(|name, value| {
if !name.is_empty() {
format!("{}: {:.*}%", name, 1, value.y)
@@ -126,7 +126,7 @@ pub fn fan_graphs(
}
})
.show(ui, |plot_ui| {
if plot_ui.plot_hovered() {
if plot_ui.response().hovered() {
let mut idx = 0;
if let Some(point) = plot_ui.pointer_coordinate() {
@@ -139,7 +139,7 @@ pub fn fan_graphs(
}
}
if plot_ui.plot_clicked() {
if plot_ui.response().clicked() {
data.temp[idx] = point.x as u8;
data.pwm[idx] = (point.y * 255.0 / 100.0) as u8;
} else {

View File

@@ -1,7 +1,7 @@
mod anime_power;
mod app_settings;
mod aura_modes;
// mod aura_power;
mod aura_power;
mod fan_graph;
mod keyboard_layout;
mod rog_bios;
@@ -11,7 +11,7 @@ mod top_bar;
pub use anime_power::*;
pub use app_settings::*;
pub use aura_modes::*;
// pub use aura_power::*;
pub use aura_power::*;
pub use fan_graph::*;
pub use keyboard_layout::*;
pub use rog_bios::*;

View File

@@ -1,4 +1,4 @@
use egui::{vec2, Align2, FontId, Id, Sense};
use egui::{vec2, Align2, FontId};
use crate::system_state::SystemState;
use crate::{RogApp, VERSION};
@@ -6,9 +6,9 @@ use crate::{RogApp, VERSION};
impl RogApp {
pub fn top_bar(
&mut self,
states: &mut SystemState,
_states: &mut SystemState,
ctx: &egui::Context,
frame: &mut eframe::Frame,
_frame: &mut eframe::Frame,
) {
egui::TopBottomPanel::top("top_panel").show(ctx, |ui| {
// The top panel is often a good place for a menu bar:
@@ -16,22 +16,18 @@ impl RogApp {
ui.horizontal(|ui| {
self.dark_light_mode_buttons(ui);
egui::warn_if_debug_build(ui);
if ui.button("Quit app").clicked() {
states.run_in_bg = false;
frame.close();
}
});
// Drag area
let text_color = ctx.style().visuals.text_color();
let mut titlebar_rect = ui.available_rect_before_wrap();
titlebar_rect.max.x -= titlebar_rect.height();
if ui
.interact(titlebar_rect, Id::new("title_bar"), Sense::drag())
.drag_started()
{
frame.drag_window();
}
// if ui
// .interact(titlebar_rect, Id::new("title_bar"), Sense::drag())
// .drag_started()
// {
// frame.drag_window();
// }
let height = titlebar_rect.height();

View File

@@ -23,8 +23,9 @@
use std::collections::BTreeMap;
use rog_aura::advanced::UsbPackets;
use rog_aura::aura_detection::PowerZones;
use rog_aura::usb::{AuraDevice, AuraPowerDev};
use rog_aura::{AuraEffect, AuraModeNum, LedBrightness};
use rog_aura::{AuraEffect, AuraModeNum, AuraZone, LedBrightness};
use zbus::blocking::Connection;
use zbus::{dbus_proxy, Result};
@@ -74,9 +75,17 @@ trait Aura {
#[dbus_proxy(property)]
fn supported_brightness(&self) -> zbus::Result<Vec<LedBrightness>>;
/// SupportedModes property
/// SupportedBasicModes property
#[dbus_proxy(property)]
fn supported_modes(&self) -> zbus::Result<Vec<AuraModeNum>>;
fn supported_basic_modes(&self) -> zbus::Result<Vec<AuraModeNum>>;
/// SupportedBasicZones property
#[dbus_proxy(property)]
fn supported_basic_zones(&self) -> zbus::Result<Vec<AuraZone>>;
/// SupportedPowerZones property
#[dbus_proxy(property)]
fn supported_power_zones(&self) -> zbus::Result<Vec<PowerZones>>;
}
pub struct AuraProxyPerkey<'a>(AuraProxyBlocking<'a>);

View File

@@ -4,6 +4,7 @@ use std::io::Write;
use std::path::PathBuf;
use log::{info, warn};
use udev::Device;
use crate::error::{PlatformError, Result};
@@ -88,4 +89,10 @@ impl HidRaw {
file.write_all(message)
.map_err(|e| PlatformError::IoPath(path.to_string_lossy().to_string(), e))
}
pub fn set_wakeup_disabled(&self) -> Result<()> {
let path = unsafe { &*(self.path.get()) };
let mut dev = Device::from_syspath(path)?;
Ok(dev.set_attribute_value("power/wakeup", "disabled")?)
}
}

View File

@@ -278,7 +278,7 @@ pub enum PlatformPolicy {
impl PlatformPolicy {
pub const fn next(&self) -> Self {
match self {
Self::Balanced => Self::Balanced,
Self::Balanced => Self::Performance,
Self::Performance => Self::Quiet,
Self::Quiet => Self::Balanced,
}