mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Compare commits
34 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c7893b16f9 | |||
| 8e8681c190 | |||
| b26c6a55f0 | |||
| 93d472fe74 | |||
| 5469c73f11 | |||
| ad95765954 | |||
| e42a5bc3e9 | |||
| 28347e87eb | |||
| b34cb672c3 | |||
| 559ddc9a22 | |||
| a8c014881f | |||
| f417032ed9 | |||
| 616fb3aea6 | |||
| 6e6e057995 | |||
| 085e63ebab | |||
| fdadffcdde | |||
| 5f51527dd7 | |||
| 39525980a0 | |||
| 83a0b570e0 | |||
| 2bfbce36b0 | |||
| 2705b08dca | |||
| 2fca7a09c4 | |||
| ef0da62c55 | |||
| 9dab120bcf | |||
| 14bf07ba79 | |||
| e76d01eaed | |||
| 072a066f28 | |||
| 165c6f8ab3 | |||
| 5728a9af62 | |||
| 17a880b2c5 | |||
| 6ba9b9d75d | |||
| eb1f6c83ce | |||
| af653ea405 | |||
| bc13891cdf |
+42
-8
@@ -1,29 +1,63 @@
|
||||
image: rust:latest
|
||||
|
||||
cache:
|
||||
key: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
|
||||
paths:
|
||||
# Don't include `incremental` to save space
|
||||
# Debug
|
||||
- target/debug/build/
|
||||
- target/debug/deps/
|
||||
- target/debug/.fingerprint/
|
||||
- target/debug/.cargo-lock
|
||||
- target/debug/df_storyteller
|
||||
# Release
|
||||
- target/release/build/
|
||||
- target/release/deps/
|
||||
- target/release/.fingerprint/
|
||||
- target/release/.cargo-lock
|
||||
|
||||
before_script:
|
||||
- apt-get update -qq && apt-get install -y -qq libdbus-1-dev libclang-dev libudev-dev libfontconfig1-dev
|
||||
- apt-get update -qq && apt-get install -y -qq libudev-dev libgtk-3-dev grep
|
||||
|
||||
stages:
|
||||
- format
|
||||
- check
|
||||
- test
|
||||
- build
|
||||
- release
|
||||
|
||||
test:
|
||||
format:
|
||||
except:
|
||||
- tags
|
||||
script:
|
||||
- echo "nightly" > rust-toolchain
|
||||
- rustup component add rustfmt
|
||||
- cargo fmt --check
|
||||
|
||||
check:
|
||||
except:
|
||||
- tags
|
||||
script:
|
||||
- rustup component add clippy
|
||||
- cargo check
|
||||
- cargo clippy
|
||||
# deny currently catches too much
|
||||
#- cargo install cargo-deny && cargo deny
|
||||
- cargo install cargo-cranky && cargo cranky
|
||||
|
||||
test:
|
||||
except:
|
||||
- tags
|
||||
script:
|
||||
- cargo test
|
||||
|
||||
build:
|
||||
release:
|
||||
only:
|
||||
- main
|
||||
- tags
|
||||
script:
|
||||
- make && make vendor
|
||||
artifacts:
|
||||
paths:
|
||||
- vendor_asus-nb-ctrl_*.tar.xz
|
||||
- vendor_asusctl_*.tar.xz
|
||||
- cargo-config
|
||||
|
||||
variables:
|
||||
GIT_SUBMODULE_STRATEGY: normal
|
||||
|
||||
|
||||
@@ -5,6 +5,28 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [Unreleased]
|
||||
## [v4.5.5]
|
||||
- remove an unwrap() causing panic on main ROGCC thread
|
||||
|
||||
## [v4.5.4]
|
||||
### Changed
|
||||
- ROGCC:: Allow ROGCC to run without supergfxd
|
||||
- ROGCC: Tray/notifs now reads dGPU status directly via supergfx crate (supergfxd not required)
|
||||
- Add rust-toolchain to force minimum rust version
|
||||
|
||||
## [v4.5.3]
|
||||
### Changed
|
||||
- Adjust how fan graph in ROGCC works, deny incorrect graphs
|
||||
- Fix to apply the fan curve change in ROGCC to the correct profile
|
||||
- Support for G713RS LED modes (Author: Peter Ivanov)
|
||||
- Support for G713RM LED modes (Author: maxbachmann)
|
||||
- Fix VivoBook detection
|
||||
- Update dependencies to get latest winit crate (fixes various small issues)
|
||||
|
||||
## [v4.5.2]
|
||||
### Changed
|
||||
- Update dependencies and bump version
|
||||
|
||||
## [v4.5.1]
|
||||
### Added
|
||||
- Support for FA506IE LED modes (Author: Herohtar)
|
||||
|
||||
Generated
+490
-257
File diff suppressed because it is too large
Load Diff
+10
-13
@@ -2,20 +2,17 @@
|
||||
members = ["asusctl", "daemon", "daemon-user", "rog-platform", "rog-dbus", "rog-anime", "rog-aura", "rog-profiles", "rog-control-center"]
|
||||
|
||||
[workspace.package]
|
||||
version = "4.5.1"
|
||||
version = "4.5.5"
|
||||
|
||||
[workspace.dependencies]
|
||||
async-trait = "^0.1"
|
||||
tokio = { version = "^1.21.2", features = ["macros", "rt-multi-thread", "time", "sync"]}
|
||||
tokio = { version = "^1.22.0", features = ["macros", "rt-multi-thread", "time", "sync"]}
|
||||
concat-idents = "^1.1"
|
||||
dirs = "^4.0"
|
||||
smol = "^1.2"
|
||||
smol = "^1.3"
|
||||
|
||||
zbus = "^3.4"
|
||||
zbus_macros = "^3.4"
|
||||
zvariant = "^3.7"
|
||||
zvariant_derive = "^3.7"
|
||||
logind-zbus = { version = "^3.0" } #, default-features = false, features = ["non_blocking"] }
|
||||
zbus = "^3.5"
|
||||
logind-zbus = { version = "^3.0.3" } #, default-features = false, features = ["non_blocking"] }
|
||||
|
||||
serde = "^1.0"
|
||||
serde_derive = "^1.0"
|
||||
@@ -23,19 +20,19 @@ serde_json = "^1.0"
|
||||
toml = "^0.5.9"
|
||||
|
||||
log = "^0.4"
|
||||
env_logger = "^0.9.3"
|
||||
env_logger = "^0.10.0"
|
||||
|
||||
glam = { version = "^0.22", features = ["serde"] }
|
||||
gumdrop = "^0.8"
|
||||
udev = "^0.6"
|
||||
udev = "^0.7"
|
||||
rusb = "^0.9"
|
||||
sysfs-class = "^0.1.2"
|
||||
sysfs-class = "^0.1.3"
|
||||
inotify = "^0.10.0"
|
||||
|
||||
png_pong = "^0.8"
|
||||
pix = "^0.13"
|
||||
tinybmp = "^0.3"
|
||||
gif = "^0.11"
|
||||
tinybmp = "^0.4.0"
|
||||
gif = "^0.12.0"
|
||||
|
||||
notify-rust = { git = "https://github.com/flukejones/notify-rust.git", default-features = false, features = ["z"] }
|
||||
|
||||
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
# https://github.com/ericseppanen/cargo-cranky
|
||||
# cargo install cargo-cranky && cargo cranky
|
||||
|
||||
warn = [
|
||||
"clippy::all",
|
||||
"clippy::await_holding_lock",
|
||||
"clippy::bool_to_int_with_if",
|
||||
"clippy::char_lit_as_u8",
|
||||
"clippy::checked_conversions",
|
||||
"clippy::dbg_macro",
|
||||
"clippy::debug_assert_with_mut_call",
|
||||
"clippy::disallowed_methods",
|
||||
"clippy::disallowed_script_idents",
|
||||
"clippy::doc_link_with_quotes",
|
||||
"clippy::doc_markdown",
|
||||
"clippy::empty_enum",
|
||||
"clippy::enum_glob_use",
|
||||
"clippy::equatable_if_let",
|
||||
"clippy::exit",
|
||||
"clippy::expl_impl_clone_on_copy",
|
||||
"clippy::explicit_deref_methods",
|
||||
"clippy::explicit_into_iter_loop",
|
||||
"clippy::explicit_iter_loop",
|
||||
"clippy::fallible_impl_from",
|
||||
"clippy::filter_map_next",
|
||||
"clippy::flat_map_option",
|
||||
"clippy::float_cmp_const",
|
||||
"clippy::fn_params_excessive_bools",
|
||||
"clippy::fn_to_numeric_cast_any",
|
||||
"clippy::from_iter_instead_of_collect",
|
||||
"clippy::if_let_mutex",
|
||||
"clippy::implicit_clone",
|
||||
"clippy::imprecise_flops",
|
||||
"clippy::index_refutable_slice",
|
||||
"clippy::inefficient_to_string",
|
||||
"clippy::invalid_upcast_comparisons",
|
||||
"clippy::iter_not_returning_iterator",
|
||||
"clippy::iter_on_empty_collections",
|
||||
"clippy::iter_on_single_items",
|
||||
"clippy::large_digit_groups",
|
||||
"clippy::large_stack_arrays",
|
||||
"clippy::large_types_passed_by_value",
|
||||
"clippy::let_unit_value",
|
||||
"clippy::linkedlist",
|
||||
"clippy::lossy_float_literal",
|
||||
"clippy::macro_use_imports",
|
||||
"clippy::manual_assert",
|
||||
"clippy::manual_instant_elapsed",
|
||||
"clippy::manual_ok_or",
|
||||
"clippy::manual_string_new",
|
||||
"clippy::map_err_ignore",
|
||||
"clippy::map_flatten",
|
||||
"clippy::map_unwrap_or",
|
||||
"clippy::match_on_vec_items",
|
||||
"clippy::match_same_arms",
|
||||
"clippy::match_wild_err_arm",
|
||||
"clippy::match_wildcard_for_single_variants",
|
||||
"clippy::mem_forget",
|
||||
"clippy::mismatched_target_os",
|
||||
"clippy::mismatching_type_param_order",
|
||||
"clippy::missing_enforced_import_renames",
|
||||
# "clippy::missing_errors_doc",
|
||||
"clippy::missing_safety_doc",
|
||||
"clippy::mut_mut",
|
||||
"clippy::mutex_integer",
|
||||
"clippy::needless_borrow",
|
||||
"clippy::needless_continue",
|
||||
"clippy::needless_for_each",
|
||||
"clippy::needless_pass_by_value",
|
||||
"clippy::negative_feature_names",
|
||||
"clippy::nonstandard_macro_braces",
|
||||
"clippy::option_option",
|
||||
"clippy::path_buf_push_overwrite",
|
||||
"clippy::ptr_as_ptr",
|
||||
"clippy::rc_mutex",
|
||||
"clippy::ref_option_ref",
|
||||
"clippy::rest_pat_in_fully_bound_structs",
|
||||
"clippy::same_functions_in_if_condition",
|
||||
"clippy::semicolon_if_nothing_returned",
|
||||
"clippy::single_match_else",
|
||||
"clippy::str_to_string",
|
||||
"clippy::string_add_assign",
|
||||
"clippy::string_add",
|
||||
"clippy::string_lit_as_bytes",
|
||||
"clippy::string_to_string",
|
||||
"clippy::todo",
|
||||
"clippy::trailing_empty_array",
|
||||
"clippy::trait_duplication_in_bounds",
|
||||
"clippy::unimplemented",
|
||||
"clippy::unnecessary_wraps",
|
||||
"clippy::unnested_or_patterns",
|
||||
"clippy::unused_peekable",
|
||||
"clippy::unused_rounding",
|
||||
# "clippy::unused_self",
|
||||
"clippy::useless_transmute",
|
||||
"clippy::verbose_file_reads",
|
||||
"clippy::zero_sized_map_values",
|
||||
"elided_lifetimes_in_paths",
|
||||
"future_incompatible",
|
||||
"nonstandard_style",
|
||||
"rust_2018_idioms",
|
||||
"rust_2021_prelude_collisions",
|
||||
"rustdoc::missing_crate_level_docs",
|
||||
"semicolon_in_expressions_from_macros",
|
||||
"trivial_numeric_casts",
|
||||
"unused_extern_crates",
|
||||
"unused_import_braces",
|
||||
"unused_lifetimes",
|
||||
]
|
||||
|
||||
allow = [
|
||||
# TODO(emilk): enable more lints
|
||||
"clippy::cloned_instead_of_copied",
|
||||
"clippy::derive_partial_eq_without_eq",
|
||||
"clippy::type_complexity",
|
||||
"clippy::undocumented_unsafe_blocks",
|
||||
"trivial_casts",
|
||||
"unsafe_op_in_unsafe_fn", # `unsafe_op_in_unsafe_fn` may become the default in future Rust versions: https://github.com/rust-lang/rust/issues/71668
|
||||
"unused_qualifications",
|
||||
]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
VERSION := $(shell grep -Pm1 'version = "(\d.\d.\d)"' daemon/Cargo.toml | cut -d'"' -f2)
|
||||
VERSION := $(shell /usr/bin/grep -Pm1 'version = "(\d.\d.\d)"' Cargo.toml | cut -d'"' -f2)
|
||||
|
||||
INSTALL = install
|
||||
INSTALL_PROGRAM = ${INSTALL} -D -m 0755
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
[](https://www.paypal.com/donate/?hosted_button_id=4V2DEPS7K6APC) - [Asus Linux Website](https://asus-linux.org/)
|
||||
|
||||
**WARNING:** Do not run the main branch of this repo unless you have all the asus-wmi kernel patches. You should use stable kernels + tagged releases.
|
||||
**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.
|
||||
|
||||
`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.
|
||||
@@ -81,7 +81,7 @@ Requirements are rust >= 1.57 installed from rustup.io if the distro provided ve
|
||||
|
||||
**fedora:**
|
||||
|
||||
dnf install cmake clang-devel systemd-devel gtk3-devel
|
||||
dnf install cmake clang-devel systemd-devel gtk3-devel cargo
|
||||
make
|
||||
sudo make install
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
[package]
|
||||
name = "asusctl"
|
||||
license = "MPL-2.0"
|
||||
authors = ["Luke D Jones <luke@ljones.dev>"]
|
||||
edition = "2021"
|
||||
version.workspace = true
|
||||
|
||||
@@ -20,7 +20,7 @@ fn main() {
|
||||
}
|
||||
|
||||
for c in (0..35).into_iter().step_by(step) {
|
||||
for i in matrix.get_mut()[c].iter_mut() {
|
||||
for i in &mut matrix.get_mut()[c] {
|
||||
*i = 50;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ fn main() {
|
||||
for (y, row) in tmp.iter_mut().enumerate() {
|
||||
if y % 2 == 0 && i + 1 != row.len() - 1 {
|
||||
i += 1;
|
||||
dbg!(i);
|
||||
}
|
||||
row[row.len() - i] = 0x22;
|
||||
if i > 5 {
|
||||
|
||||
@@ -35,7 +35,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
loop {
|
||||
matrix.angle += 0.05;
|
||||
if matrix.angle > PI * 2.0 {
|
||||
matrix.angle = 0.0
|
||||
matrix.angle = 0.0;
|
||||
}
|
||||
matrix.update();
|
||||
|
||||
|
||||
@@ -6,17 +6,17 @@ use rog_aura::{
|
||||
KeyColourArray,
|
||||
};
|
||||
use rog_dbus::RogDbusClientBlocking;
|
||||
use std::collections::LinkedList;
|
||||
use std::collections::VecDeque;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
struct Ball {
|
||||
position: (f32, f32),
|
||||
direction: (f32, f32),
|
||||
trail: LinkedList<(f32, f32)>,
|
||||
trail: VecDeque<(f32, f32)>,
|
||||
}
|
||||
impl Ball {
|
||||
fn new(x: f32, y: f32, trail_len: u32) -> Self {
|
||||
let mut trail = LinkedList::new();
|
||||
let mut trail = VecDeque::new();
|
||||
for _ in 1..=trail_len {
|
||||
trail.push_back((x, y));
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ impl ToString for LedBrightness {
|
||||
Some(0x02) => "high",
|
||||
_ => "unknown",
|
||||
};
|
||||
s.to_string()
|
||||
s.to_owned()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+29
-34
@@ -26,7 +26,7 @@ mod aura_cli;
|
||||
mod cli_opts;
|
||||
mod profiles_cli;
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
fn main() {
|
||||
let args: Vec<String> = args().skip(1).collect();
|
||||
|
||||
let missing_argument_k = gumdrop::Error::missing_argument(Opt::Short('k'));
|
||||
@@ -44,7 +44,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
let (dbus, _) = RogDbusClientBlocking::new()
|
||||
.map_err(|e| {
|
||||
print_error_help(Box::new(e), None);
|
||||
print_error_help(&e, None);
|
||||
std::process::exit(3);
|
||||
})
|
||||
.unwrap();
|
||||
@@ -54,7 +54,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
.supported()
|
||||
.supported_functions()
|
||||
.map_err(|e| {
|
||||
print_error_help(Box::new(e), None);
|
||||
print_error_help(&e, None);
|
||||
std::process::exit(4);
|
||||
})
|
||||
.unwrap();
|
||||
@@ -63,17 +63,14 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
print_versions();
|
||||
println!();
|
||||
print_laptop_info();
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
if let Err(err) = do_parsed(&parsed, &supported, &dbus) {
|
||||
print_error_help(err, Some(&supported));
|
||||
print_error_help(&*err, Some(&supported));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn print_error_help(err: Box<dyn std::error::Error>, supported: Option<&SupportedFunctions>) {
|
||||
fn print_error_help(err: &dyn std::error::Error, supported: Option<&SupportedFunctions>) {
|
||||
check_service("asusd");
|
||||
println!("\nError: {}\n", err);
|
||||
print_versions();
|
||||
@@ -126,7 +123,7 @@ fn check_service(name: &str) -> bool {
|
||||
fn do_parsed(
|
||||
parsed: &CliStart,
|
||||
supported: &SupportedFunctions,
|
||||
dbus: &RogDbusClientBlocking,
|
||||
dbus: &RogDbusClientBlocking<'_>,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
match &parsed.command {
|
||||
Some(CliCommand::LedMode(mode)) => handle_led_mode(dbus, &supported.keyboard_led, mode)?,
|
||||
@@ -134,9 +131,9 @@ fn do_parsed(
|
||||
Some(CliCommand::LedPow2(pow)) => handle_led_power2(dbus, &supported.keyboard_led, pow)?,
|
||||
Some(CliCommand::Profile(cmd)) => handle_profile(dbus, &supported.platform_profile, cmd)?,
|
||||
Some(CliCommand::FanCurve(cmd)) => {
|
||||
handle_fan_curve(dbus, &supported.platform_profile, cmd)?
|
||||
handle_fan_curve(dbus, &supported.platform_profile, cmd)?;
|
||||
}
|
||||
Some(CliCommand::Graphics(_)) => do_gfx()?,
|
||||
Some(CliCommand::Graphics(_)) => do_gfx(),
|
||||
Some(CliCommand::Anime(cmd)) => handle_anime(dbus, &supported.anime_ctrl, cmd)?,
|
||||
Some(CliCommand::Bios(cmd)) => handle_bios_option(dbus, &supported.rog_bios_ctrl, cmd)?,
|
||||
None => {
|
||||
@@ -150,7 +147,7 @@ fn do_parsed(
|
||||
println!("{}", CliStart::usage());
|
||||
println!();
|
||||
if let Some(cmdlist) = CliStart::command_list() {
|
||||
let commands: Vec<String> = cmdlist.lines().map(|s| s.to_string()).collect();
|
||||
let commands: Vec<String> = cmdlist.lines().map(|s| s.to_owned()).collect();
|
||||
for command in commands.iter().filter(|command| {
|
||||
if !matches!(
|
||||
supported.keyboard_led.prod_id,
|
||||
@@ -214,14 +211,13 @@ fn do_parsed(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn do_gfx() -> Result<(), Box<dyn std::error::Error>> {
|
||||
fn do_gfx() {
|
||||
println!("Please use supergfxctl for graphics switching. supergfxctl is the result of making asusctl graphics switching generic so all laptops can use it");
|
||||
println!("This command will be removed in future");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_anime(
|
||||
dbus: &RogDbusClientBlocking,
|
||||
dbus: &RogDbusClientBlocking<'_>,
|
||||
_supported: &AnimeSupportedFunctions,
|
||||
cmd: &AnimeCommand,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
@@ -237,14 +233,14 @@ fn handle_anime(
|
||||
}
|
||||
}
|
||||
if let Some(anime_turn) = cmd.enable {
|
||||
dbus.proxies().anime().set_on_off(anime_turn)?
|
||||
dbus.proxies().anime().set_on_off(anime_turn)?;
|
||||
}
|
||||
if let Some(anime_boot) = cmd.boot_enable {
|
||||
dbus.proxies().anime().set_boot_on_off(anime_boot)?
|
||||
dbus.proxies().anime().set_boot_on_off(anime_boot)?;
|
||||
}
|
||||
if let Some(bright) = cmd.brightness {
|
||||
verify_brightness(bright);
|
||||
dbus.proxies().anime().set_brightness(bright)?
|
||||
dbus.proxies().anime().set_brightness(bright)?;
|
||||
}
|
||||
if cmd.clear {
|
||||
let anime_type = get_anime_type()?;
|
||||
@@ -381,7 +377,7 @@ fn verify_brightness(brightness: f32) {
|
||||
}
|
||||
|
||||
fn handle_led_mode(
|
||||
dbus: &RogDbusClientBlocking,
|
||||
dbus: &RogDbusClientBlocking<'_>,
|
||||
supported: &LedSupportedFunctions,
|
||||
mode: &LedModeCommand,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
@@ -438,7 +434,7 @@ fn handle_led_mode(
|
||||
}
|
||||
|
||||
fn handle_led_power1(
|
||||
dbus: &RogDbusClientBlocking,
|
||||
dbus: &RogDbusClientBlocking<'_>,
|
||||
supported: &LedSupportedFunctions,
|
||||
power: &LedPowerCommand1,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
@@ -473,7 +469,7 @@ fn handle_led_power1(
|
||||
}
|
||||
|
||||
fn handle_led_power_1_do_1866(
|
||||
dbus: &RogDbusClientBlocking,
|
||||
dbus: &RogDbusClientBlocking<'_>,
|
||||
power: &LedPowerCommand1,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let mut enabled: Vec<AuraDev1866> = Vec::new();
|
||||
@@ -513,7 +509,7 @@ fn handle_led_power_1_do_1866(
|
||||
}
|
||||
|
||||
fn handle_led_power_1_do_tuf(
|
||||
dbus: &RogDbusClientBlocking,
|
||||
dbus: &RogDbusClientBlocking<'_>,
|
||||
power: &LedPowerCommand1,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let mut enabled: Vec<AuraDevTuf> = Vec::new();
|
||||
@@ -552,7 +548,7 @@ fn handle_led_power_1_do_tuf(
|
||||
}
|
||||
|
||||
fn handle_led_power2(
|
||||
dbus: &RogDbusClientBlocking,
|
||||
dbus: &RogDbusClientBlocking<'_>,
|
||||
supported: &LedSupportedFunctions,
|
||||
power: &LedPowerCommand2,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
@@ -564,8 +560,8 @@ fn handle_led_power2(
|
||||
println!("Commands available");
|
||||
|
||||
if let Some(cmdlist) = LedPowerCommand2::command_list() {
|
||||
let commands: Vec<String> = cmdlist.lines().map(|s| s.to_string()).collect();
|
||||
for command in commands.iter() {
|
||||
let commands: Vec<String> = cmdlist.lines().map(|s| s.to_owned()).collect();
|
||||
for command in &commands {
|
||||
println!("{}", command);
|
||||
}
|
||||
}
|
||||
@@ -581,7 +577,7 @@ fn handle_led_power2(
|
||||
}
|
||||
|
||||
if supported.prod_id != AuraDevice::X19B6 {
|
||||
println!("This option applies only to keyboards with product ID 0x19b6")
|
||||
println!("This option applies only to keyboards with product ID 0x19b6");
|
||||
}
|
||||
|
||||
let mut enabled: Vec<AuraDev19b6> = Vec::new();
|
||||
@@ -646,7 +642,7 @@ fn handle_led_power2(
|
||||
}
|
||||
|
||||
fn handle_profile(
|
||||
dbus: &RogDbusClientBlocking,
|
||||
dbus: &RogDbusClientBlocking<'_>,
|
||||
supported: &PlatformProfileFunctions,
|
||||
cmd: &ProfileCommand,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
@@ -675,7 +671,9 @@ fn handle_profile(
|
||||
|
||||
if cmd.list {
|
||||
let res = dbus.proxies().profile().profiles()?;
|
||||
res.iter().for_each(|p| println!("{:?}", p));
|
||||
for p in &res {
|
||||
println!("{:?}", p);
|
||||
}
|
||||
}
|
||||
|
||||
if cmd.profile_get {
|
||||
@@ -687,7 +685,7 @@ fn handle_profile(
|
||||
}
|
||||
|
||||
fn handle_fan_curve(
|
||||
dbus: &RogDbusClientBlocking,
|
||||
dbus: &RogDbusClientBlocking<'_>,
|
||||
supported: &PlatformProfileFunctions,
|
||||
cmd: &FanCurveCommand,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
@@ -749,7 +747,7 @@ fn handle_fan_curve(
|
||||
}
|
||||
|
||||
fn handle_bios_option(
|
||||
dbus: &RogDbusClientBlocking,
|
||||
dbus: &RogDbusClientBlocking<'_>,
|
||||
supported: &RogBiosSupportedFunctions,
|
||||
cmd: &BiosCommand,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
@@ -764,10 +762,7 @@ fn handle_bios_option(
|
||||
{
|
||||
println!("Missing arg or command\n");
|
||||
|
||||
let usage: Vec<String> = BiosCommand::usage()
|
||||
.lines()
|
||||
.map(|s| s.to_string())
|
||||
.collect();
|
||||
let usage: Vec<String> = BiosCommand::usage().lines().map(|s| s.to_owned()).collect();
|
||||
|
||||
for line in usage.iter().filter(|line| {
|
||||
line.contains("sound") && supported.post_sound
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
[package]
|
||||
name = "daemon-user"
|
||||
license = "MPL-2.0"
|
||||
version.workspace = true
|
||||
authors = ["Luke D Jones <luke@ljones.dev>"]
|
||||
edition = "2021"
|
||||
@@ -28,5 +29,3 @@ rog_dbus = { path = "../rog-dbus" }
|
||||
rog_platform = { path = "../rog-platform" }
|
||||
|
||||
zbus.workspace = true
|
||||
zvariant.workspace = true
|
||||
zvariant_derive.workspace = true
|
||||
@@ -11,9 +11,10 @@ use std::{
|
||||
},
|
||||
};
|
||||
use std::{sync::Arc, thread::sleep, time::Instant};
|
||||
use zbus::dbus_interface;
|
||||
use zvariant::ObjectPath;
|
||||
use zvariant_derive::Type;
|
||||
use zbus::{
|
||||
dbus_interface,
|
||||
zvariant::{ObjectPath, Type},
|
||||
};
|
||||
|
||||
use crate::user_config::ConfigLoadSave;
|
||||
use crate::{error::Error, user_config::UserAnimeConfig};
|
||||
@@ -102,7 +103,7 @@ impl<'a> CtrlAnimeInner<'static> {
|
||||
.write(output)
|
||||
.map_err(|e| AnimeError::Dbus(format!("{}", e)))
|
||||
.map(|_| false)
|
||||
})?;
|
||||
});
|
||||
}
|
||||
ActionData::Image(image) => {
|
||||
self.client
|
||||
@@ -123,10 +124,10 @@ impl<'a> CtrlAnimeInner<'static> {
|
||||
sleep(Duration::from_millis(1));
|
||||
}
|
||||
}
|
||||
ActionData::AudioEq => {}
|
||||
ActionData::SystemInfo => {}
|
||||
ActionData::TimeDate => {}
|
||||
ActionData::Matrix => {}
|
||||
ActionData::AudioEq
|
||||
| ActionData::SystemInfo
|
||||
| ActionData::TimeDate
|
||||
| ActionData::Matrix => {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,7 +143,7 @@ pub struct CtrlAnime<'a> {
|
||||
inner_early_return: Arc<AtomicBool>,
|
||||
}
|
||||
|
||||
impl<'a> CtrlAnime<'static> {
|
||||
impl CtrlAnime<'static> {
|
||||
pub fn new(
|
||||
config: Arc<Mutex<UserAnimeConfig>>,
|
||||
inner: Arc<Mutex<CtrlAnimeInner<'static>>>,
|
||||
@@ -184,7 +185,7 @@ impl CtrlAnime<'static> {
|
||||
pub fn insert_asus_gif(
|
||||
&mut self,
|
||||
index: u32,
|
||||
file: String,
|
||||
file: &str,
|
||||
time: Timer,
|
||||
brightness: f32,
|
||||
) -> zbus::fdo::Result<String> {
|
||||
@@ -222,7 +223,7 @@ impl CtrlAnime<'static> {
|
||||
pub fn insert_image_gif(
|
||||
&mut self,
|
||||
index: u32,
|
||||
file: String,
|
||||
file: &str,
|
||||
scale: f32,
|
||||
angle: f32,
|
||||
xy: (f32, f32),
|
||||
@@ -268,7 +269,7 @@ impl CtrlAnime<'static> {
|
||||
pub fn insert_image(
|
||||
&mut self,
|
||||
index: u32,
|
||||
file: String,
|
||||
file: &str,
|
||||
scale: f32,
|
||||
angle: f32,
|
||||
xy: (f32, f32),
|
||||
|
||||
@@ -13,7 +13,7 @@ pub enum Error {
|
||||
|
||||
impl fmt::Display for Error {
|
||||
// This trait requires `fmt` with this exact signature.
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Error::Io(err) => write!(f, "Failed to open: {}", err),
|
||||
Error::ConfigLoadFail => write!(f, "Failed to load user config"),
|
||||
|
||||
@@ -114,7 +114,7 @@ impl ConfigLoadSave<UserAnimeConfig> for UserAnimeConfig {
|
||||
impl Default for UserAnimeConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
name: "default".to_string(),
|
||||
name: "default".to_owned(),
|
||||
anime: vec![
|
||||
ActionLoader::AsusImage {
|
||||
file: "/usr/share/asusd/anime/custom/diagonal-template.png".into(),
|
||||
@@ -233,7 +233,7 @@ impl Default for UserAuraConfig {
|
||||
seq.push(key);
|
||||
|
||||
Self {
|
||||
name: "default".to_string(),
|
||||
name: "default".to_owned(),
|
||||
aura: seq,
|
||||
}
|
||||
}
|
||||
@@ -251,8 +251,8 @@ pub struct UserConfig {
|
||||
impl UserConfig {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
active_anime: Some("anime-default".to_string()),
|
||||
active_aura: Some("aura-default".to_string()),
|
||||
active_anime: Some("anime-default".to_owned()),
|
||||
active_aura: Some("aura-default".to_owned()),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-3
@@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "daemon"
|
||||
version.workspace = true
|
||||
license = "MPL-2.0"
|
||||
version.workspace = true
|
||||
readme = "README.md"
|
||||
authors = ["Luke <luke@ljones.dev>"]
|
||||
repository = "https://gitlab.com/asus-linux/asus-nb-ctrl"
|
||||
@@ -32,7 +32,6 @@ log.workspace = true
|
||||
env_logger.workspace = true
|
||||
|
||||
zbus.workspace = true
|
||||
zvariant.workspace = true
|
||||
logind-zbus.workspace = true
|
||||
|
||||
# serialisation
|
||||
@@ -44,4 +43,4 @@ toml.workspace = true
|
||||
# Device control
|
||||
sysfs-class.workspace = true # used for backlight control and baord ID
|
||||
|
||||
concat-idents.workspace = true
|
||||
concat-idents.workspace = true
|
||||
|
||||
@@ -42,7 +42,7 @@ impl Config {
|
||||
"Could not deserialise {}.\nWill rename to {}-old and recreate config",
|
||||
CONFIG_PATH, CONFIG_PATH
|
||||
);
|
||||
let cfg_old = CONFIG_PATH.to_string() + "-old";
|
||||
let cfg_old = CONFIG_PATH.to_owned() + "-old";
|
||||
std::fs::rename(CONFIG_PATH, cfg_old).unwrap_or_else(|err| {
|
||||
panic!(
|
||||
"Could not rename. Please remove {} then restart service: Error {}",
|
||||
@@ -52,7 +52,7 @@ impl Config {
|
||||
config = Self::new();
|
||||
}
|
||||
} else {
|
||||
config = Self::new()
|
||||
config = Self::new();
|
||||
}
|
||||
config.write();
|
||||
config
|
||||
|
||||
@@ -86,25 +86,25 @@ impl AnimeConfigCached {
|
||||
anime_type: AnimeType,
|
||||
) -> Result<(), AnimeError> {
|
||||
let mut sys = Vec::with_capacity(config.system.len());
|
||||
for ani in config.system.iter() {
|
||||
for ani in &config.system {
|
||||
sys.push(ActionData::from_anime_action(anime_type, ani)?);
|
||||
}
|
||||
self.system = sys;
|
||||
|
||||
let mut boot = Vec::with_capacity(config.boot.len());
|
||||
for ani in config.boot.iter() {
|
||||
for ani in &config.boot {
|
||||
boot.push(ActionData::from_anime_action(anime_type, ani)?);
|
||||
}
|
||||
self.boot = boot;
|
||||
|
||||
let mut wake = Vec::with_capacity(config.wake.len());
|
||||
for ani in config.wake.iter() {
|
||||
for ani in &config.wake {
|
||||
wake.push(ActionData::from_anime_action(anime_type, ani)?);
|
||||
}
|
||||
self.wake = wake;
|
||||
|
||||
let mut shutdown = Vec::with_capacity(config.shutdown.len());
|
||||
for ani in config.shutdown.iter() {
|
||||
for ani in &config.shutdown {
|
||||
shutdown.push(ActionData::from_anime_action(anime_type, ani)?);
|
||||
}
|
||||
self.shutdown = shutdown;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
pub mod config;
|
||||
/// Implements CtrlTask, Reloadable, ZbusRun
|
||||
/// Implements `CtrlTask`, Reloadable, `ZbusRun`
|
||||
pub mod trait_impls;
|
||||
|
||||
use self::config::{AnimeConfig, AnimeConfigCached};
|
||||
@@ -62,7 +62,7 @@ impl CtrlAnime {
|
||||
/// one running - so the thread uses atomics to signal run/exit.
|
||||
///
|
||||
/// Because this also writes to the usb device, other write tries (display only) *must*
|
||||
/// get the mutex lock and set the thread_exit atomic.
|
||||
/// get the mutex lock and set the `thread_exit` atomic.
|
||||
fn run_thread(inner: Arc<Mutex<CtrlAnime>>, actions: Vec<ActionData>, mut once: bool) {
|
||||
if actions.is_empty() {
|
||||
warn!("AniMe system actions was empty");
|
||||
@@ -106,13 +106,13 @@ impl CtrlAnime {
|
||||
|
||||
'main: loop {
|
||||
thread_running.store(true, Ordering::SeqCst);
|
||||
for action in actions.iter() {
|
||||
for action in &actions {
|
||||
if thread_exit.load(Ordering::SeqCst) {
|
||||
break 'main;
|
||||
}
|
||||
match action {
|
||||
ActionData::Animation(frames) => {
|
||||
if let Err(err) = rog_anime::run_animation(frames, &|frame| {
|
||||
rog_anime::run_animation(frames, &|frame| {
|
||||
if thread_exit.load(Ordering::Acquire) {
|
||||
info!("rog-anime: frame-loop was asked to exit");
|
||||
return Ok(true); // Do safe exit
|
||||
@@ -130,15 +130,14 @@ impl CtrlAnime {
|
||||
.ok();
|
||||
false // Don't exit yet
|
||||
})
|
||||
.map(Ok)
|
||||
.unwrap_or_else(|| {
|
||||
warn!("rog_anime::run_animation:callback failed");
|
||||
Err(AnimeError::NoFrames)
|
||||
})
|
||||
}) {
|
||||
warn!("rog_anime::run_animation:Animation {}", err);
|
||||
break 'main;
|
||||
};
|
||||
.map_or_else(
|
||||
|| {
|
||||
warn!("rog_anime::run_animation:callback failed");
|
||||
Err(AnimeError::NoFrames)
|
||||
},
|
||||
Ok,
|
||||
)
|
||||
});
|
||||
}
|
||||
ActionData::Image(image) => {
|
||||
once = false;
|
||||
@@ -149,10 +148,10 @@ impl CtrlAnime {
|
||||
}
|
||||
}
|
||||
ActionData::Pause(duration) => sleep(*duration),
|
||||
ActionData::AudioEq => {}
|
||||
ActionData::SystemInfo => {}
|
||||
ActionData::TimeDate => {}
|
||||
ActionData::Matrix => {}
|
||||
ActionData::AudioEq
|
||||
| ActionData::SystemInfo
|
||||
| ActionData::TimeDate
|
||||
| ActionData::Matrix => {}
|
||||
}
|
||||
}
|
||||
if thread_exit.load(Ordering::SeqCst) {
|
||||
@@ -194,7 +193,7 @@ impl CtrlAnime {
|
||||
*led = bright as u8;
|
||||
}
|
||||
let data = AnimePacketType::try_from(buffer)?;
|
||||
for row in data.iter() {
|
||||
for row in &data {
|
||||
self.node.write_bytes(row)?;
|
||||
}
|
||||
self.node.write_bytes(&pkt_for_flush())?;
|
||||
|
||||
@@ -47,7 +47,7 @@ impl CtrlAnimeZbus {
|
||||
let mut lock = self.0.lock().await;
|
||||
let mut bright = bright;
|
||||
if bright < 0.0 {
|
||||
bright = 0.0
|
||||
bright = 0.0;
|
||||
} else if bright > 1.0 {
|
||||
bright = 1.0;
|
||||
}
|
||||
@@ -149,7 +149,7 @@ impl crate::CtrlTask for CtrlAnimeZbus {
|
||||
|
||||
async fn create_tasks(&self, _: SignalContext<'static>) -> Result<(), RogError> {
|
||||
let run_action =
|
||||
|start: bool, lock: MutexGuard<CtrlAnime>, inner: Arc<Mutex<CtrlAnime>>| {
|
||||
|start: bool, lock: MutexGuard<'_, CtrlAnime>, inner: Arc<Mutex<CtrlAnime>>| {
|
||||
if start {
|
||||
info!("CtrlAnimeTask running sleep animation");
|
||||
CtrlAnime::run_thread(inner, lock.cache.shutdown.clone(), true);
|
||||
|
||||
@@ -127,7 +127,7 @@ pub struct AuraConfig {
|
||||
impl Default for AuraConfig {
|
||||
fn default() -> Self {
|
||||
let mut prod_id = AuraDevice::Unknown;
|
||||
for prod in ASUS_KEYBOARD_DEVICES.iter() {
|
||||
for prod in &ASUS_KEYBOARD_DEVICES {
|
||||
if HidRaw::new(prod).is_ok() {
|
||||
prod_id = AuraDevice::from(*prod);
|
||||
break;
|
||||
@@ -242,7 +242,7 @@ impl AuraConfig {
|
||||
colour2: *GRADIENT.get(GRADIENT.len() - i).unwrap_or(&GRADIENT[6]),
|
||||
speed: Speed::Med,
|
||||
direction: Direction::Left,
|
||||
})
|
||||
});
|
||||
}
|
||||
if let Some(m) = config.multizone.as_mut() {
|
||||
m.insert(*n, default);
|
||||
@@ -287,34 +287,31 @@ impl AuraConfig {
|
||||
|
||||
/// Set the mode data, current mode, and if multizone enabled.
|
||||
///
|
||||
/// Multipurpose, will accept AuraEffect with zones and put in the correct store.
|
||||
/// Multipurpose, will accept `AuraEffect` with zones and put in the correct store.
|
||||
pub fn set_builtin(&mut self, effect: AuraEffect) {
|
||||
self.current_mode = effect.mode;
|
||||
match effect.zone() {
|
||||
AuraZone::None => {
|
||||
self.builtins.insert(*effect.mode(), effect);
|
||||
self.multizone_on = false;
|
||||
}
|
||||
_ => {
|
||||
if let Some(multi) = self.multizone.as_mut() {
|
||||
if let Some(fx) = multi.get_mut(effect.mode()) {
|
||||
for fx in fx.iter_mut() {
|
||||
if fx.zone == effect.zone {
|
||||
*fx = effect;
|
||||
return;
|
||||
}
|
||||
if effect.zone() == AuraZone::None {
|
||||
self.builtins.insert(*effect.mode(), effect);
|
||||
self.multizone_on = false;
|
||||
} else {
|
||||
if let Some(multi) = self.multizone.as_mut() {
|
||||
if let Some(fx) = multi.get_mut(effect.mode()) {
|
||||
for fx in fx.iter_mut() {
|
||||
if fx.zone == effect.zone {
|
||||
*fx = effect;
|
||||
return;
|
||||
}
|
||||
fx.push(effect);
|
||||
} else {
|
||||
multi.insert(*effect.mode(), vec![effect]);
|
||||
}
|
||||
fx.push(effect);
|
||||
} else {
|
||||
let mut tmp = BTreeMap::new();
|
||||
tmp.insert(*effect.mode(), vec![effect]);
|
||||
self.multizone = Some(tmp);
|
||||
multi.insert(*effect.mode(), vec![effect]);
|
||||
}
|
||||
self.multizone_on = true;
|
||||
} else {
|
||||
let mut tmp = BTreeMap::new();
|
||||
tmp.insert(*effect.mode(), vec![effect]);
|
||||
self.multizone = Some(tmp);
|
||||
}
|
||||
self.multizone_on = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ impl GetSupported for CtrlKbdLed {
|
||||
let per_key_led_mode = laptop.per_key;
|
||||
|
||||
let mut prod_id = AuraDevice::Unknown;
|
||||
for prod in ASUS_KEYBOARD_DEVICES.iter() {
|
||||
for prod in &ASUS_KEYBOARD_DEVICES {
|
||||
if HidRaw::new(prod).is_ok() {
|
||||
prod_id = AuraDevice::from(*prod);
|
||||
break;
|
||||
@@ -72,10 +72,10 @@ impl CtrlKbdLed {
|
||||
pub fn new(supported_modes: LaptopLedData, config: AuraConfig) -> Result<Self, RogError> {
|
||||
let mut led_prod = None;
|
||||
let mut led_node = None;
|
||||
for prod in ASUS_KEYBOARD_DEVICES.iter() {
|
||||
for prod in &ASUS_KEYBOARD_DEVICES {
|
||||
match HidRaw::new(prod) {
|
||||
Ok(node) => {
|
||||
led_prod = Some(prod.to_string());
|
||||
led_prod = Some((*prod).to_owned());
|
||||
led_node = Some(node);
|
||||
info!("Looked for keyboard controller 0x{prod}: Found");
|
||||
break;
|
||||
@@ -335,7 +335,7 @@ impl CtrlKbdLed {
|
||||
colour2: *GRADIENT.get(GRADIENT.len() - i).unwrap_or(&GRADIENT[6]),
|
||||
speed: Speed::Med,
|
||||
direction: Direction::Left,
|
||||
})
|
||||
});
|
||||
}
|
||||
if default.is_empty() {
|
||||
return Err(RogError::AuraEffectNotSupported);
|
||||
@@ -370,7 +370,7 @@ mod tests {
|
||||
// Checking to ensure set_mode errors when unsupported modes are tried
|
||||
let config = AuraConfig::default();
|
||||
let supported_modes = LaptopLedData {
|
||||
prod_family: "".into(),
|
||||
prod_family: String::new(),
|
||||
board_names: vec![],
|
||||
standard: vec![AuraModeNum::Static],
|
||||
multizone: vec![],
|
||||
@@ -432,7 +432,7 @@ mod tests {
|
||||
// Checking to ensure set_mode errors when unsupported modes are tried
|
||||
let config = AuraConfig::default();
|
||||
let supported_modes = LaptopLedData {
|
||||
prod_family: "".into(),
|
||||
prod_family: String::new(),
|
||||
board_names: vec![],
|
||||
standard: vec![AuraModeNum::Static],
|
||||
multizone: vec![],
|
||||
@@ -470,7 +470,7 @@ mod tests {
|
||||
// Checking to ensure set_mode errors when unsupported modes are tried
|
||||
let config = AuraConfig::default();
|
||||
let supported_modes = LaptopLedData {
|
||||
prod_family: "".into(),
|
||||
prod_family: String::new(),
|
||||
board_names: vec![],
|
||||
standard: vec![AuraModeNum::Static],
|
||||
multizone: vec![AuraZone::Key1, AuraZone::Key2],
|
||||
|
||||
@@ -237,7 +237,7 @@ impl CtrlTask for CtrlKbdLedZbus {
|
||||
}
|
||||
|
||||
async fn create_tasks(&self, _: SignalContext<'static>) -> Result<(), RogError> {
|
||||
let load_save = |start: bool, mut lock: MutexGuard<CtrlKbdLed>| {
|
||||
let load_save = |start: bool, mut lock: MutexGuard<'_, CtrlKbdLed>| {
|
||||
// If waking up
|
||||
if !start {
|
||||
info!("CtrlKbdLedTask reloading brightness and modes");
|
||||
|
||||
@@ -43,7 +43,8 @@ impl ProfileConfig {
|
||||
"Could not deserialise {}.\nWill rename to {}-old and recreate config",
|
||||
config_path, config_path
|
||||
);
|
||||
let cfg_old = config_path.clone() + "-old";
|
||||
let mut cfg_old = config_path.clone();
|
||||
cfg_old.push_str("-old");
|
||||
std::fs::rename(config_path.clone(), cfg_old).unwrap_or_else(|err| {
|
||||
panic!(
|
||||
"Could not rename. Please remove {} then restart service: Error {}",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
pub mod config;
|
||||
pub mod controller;
|
||||
/// Implements CtrlTask, Reloadable, ZbusRun
|
||||
/// Implements `CtrlTask`, Reloadable, `ZbusRun`
|
||||
pub mod trait_impls;
|
||||
|
||||
@@ -32,7 +32,7 @@ impl ProfileZbus {
|
||||
return Ok(profiles);
|
||||
}
|
||||
Err(Error::Failed(
|
||||
"Failed to get all profile details".to_string(),
|
||||
"Failed to get all profile details".to_owned(),
|
||||
))
|
||||
}
|
||||
|
||||
@@ -85,9 +85,9 @@ impl ProfileZbus {
|
||||
let mut ctrl = self.0.lock().await;
|
||||
ctrl.config.read();
|
||||
if let Some(curves) = &ctrl.config.fan_curves {
|
||||
return Ok(curves.get_enabled_curve_profiles().to_vec());
|
||||
return Ok(curves.get_enabled_curve_profiles());
|
||||
}
|
||||
Err(Error::Failed(UNSUPPORTED_MSG.to_string()))
|
||||
Err(Error::Failed(UNSUPPORTED_MSG.to_owned()))
|
||||
}
|
||||
|
||||
/// Set a profile fan curve enabled status. Will also activate a fan curve if in the
|
||||
@@ -109,7 +109,7 @@ impl ProfileZbus {
|
||||
ctrl.save_config();
|
||||
Ok(())
|
||||
} else {
|
||||
Err(Error::Failed(UNSUPPORTED_MSG.to_string()))
|
||||
Err(Error::Failed(UNSUPPORTED_MSG.to_owned()))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ impl ProfileZbus {
|
||||
let curve = curves.get_fan_curves_for(profile);
|
||||
return Ok(curve.clone());
|
||||
}
|
||||
Err(Error::Failed(UNSUPPORTED_MSG.to_string()))
|
||||
Err(Error::Failed(UNSUPPORTED_MSG.to_owned()))
|
||||
}
|
||||
|
||||
/// Set the fan curve for the specified profile.
|
||||
@@ -134,7 +134,7 @@ impl ProfileZbus {
|
||||
.save_fan_curve(curve, profile)
|
||||
.map_err(|err| zbus::fdo::Error::Failed(err.to_string()))?;
|
||||
} else {
|
||||
return Err(Error::Failed(UNSUPPORTED_MSG.to_string()));
|
||||
return Err(Error::Failed(UNSUPPORTED_MSG.to_owned()));
|
||||
}
|
||||
ctrl.write_profile_curve_to_platform()
|
||||
.map_err(|e| warn!("Profile::set_profile, {}", e))
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
use async_trait::async_trait;
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use zbus::dbus_interface;
|
||||
use zbus::Connection;
|
||||
use zvariant::Type;
|
||||
use zbus::{dbus_interface, zvariant::Type, Connection};
|
||||
|
||||
use crate::{
|
||||
ctrl_anime::CtrlAnime, ctrl_aura::controller::CtrlKbdLed, ctrl_platform::CtrlPlatform,
|
||||
|
||||
+2
-2
@@ -37,7 +37,7 @@ pub enum RogError {
|
||||
|
||||
impl fmt::Display for RogError {
|
||||
// This trait requires `fmt` with this exact signature.
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
RogError::ParseVendor => write!(f, "Parse gfx vendor error"),
|
||||
RogError::ParseLed => write!(f, "Parse LED error"),
|
||||
@@ -51,7 +51,7 @@ impl fmt::Display for RogError {
|
||||
RogError::DoTask(deets) => write!(f, "Task error: {}", deets),
|
||||
RogError::MissingFunction(deets) => write!(f, "Missing functionality: {}", deets),
|
||||
RogError::MissingLedBrightNode(path, error) => write!(f, "Led node at {} is missing, please check you have the required patch or dkms module installed: {}", path, error),
|
||||
RogError::ReloadFail(deets) => write!(f, "Task error: {}", deets),
|
||||
RogError::ReloadFail(deets) => write!(f, "Reload error: {}", deets),
|
||||
RogError::Profiles(deets) => write!(f, "Profile error: {}", deets),
|
||||
RogError::Initramfs(detail) => write!(f, "Initiramfs error: {}", detail),
|
||||
RogError::Modprobe(detail) => write!(f, "Modprobe error: {}", detail),
|
||||
|
||||
@@ -71,7 +71,7 @@ impl LaptopLedData {
|
||||
}
|
||||
|
||||
impl LedSupportFile {
|
||||
/// Consumes the LEDModes
|
||||
/// Consumes the `LEDModes`
|
||||
fn matcher(self, prod_family: &str, board_name: &str) -> Option<LaptopLedData> {
|
||||
for config in self.led_data {
|
||||
if prod_family.contains(&config.prod_family) {
|
||||
|
||||
+2
-3
@@ -1,7 +1,7 @@
|
||||
#![deny(unused_must_use)]
|
||||
/// Configuration loading, saving
|
||||
pub mod config;
|
||||
/// Control of AniMe matrix display
|
||||
/// Control of anime matrix display
|
||||
pub mod ctrl_anime;
|
||||
/// Keyboard LED brightness control, RGB, and LED display modes
|
||||
pub mod ctrl_aura;
|
||||
@@ -25,8 +25,7 @@ use crate::error::RogError;
|
||||
use async_trait::async_trait;
|
||||
use log::warn;
|
||||
use logind_zbus::manager::ManagerProxy;
|
||||
use zbus::{export::futures_util::StreamExt, Connection, SignalContext};
|
||||
use zvariant::ObjectPath;
|
||||
use zbus::{export::futures_util::StreamExt, zvariant::ObjectPath, Connection, SignalContext};
|
||||
|
||||
/// This macro adds a function which spawns an `inotify` task on the passed in `Executor`.
|
||||
///
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
[[led_data]]
|
||||
prod_family = "ASUS TUF Gaming F15"
|
||||
board_names = ["FX506HC"]
|
||||
standard = ["Static", "Breathe", "Strobe", "Pulse"]
|
||||
multizone = []
|
||||
per_key = false
|
||||
|
||||
[[led_data]]
|
||||
prod_family = "TUF"
|
||||
board_names = ["FA507"]
|
||||
@@ -78,7 +85,7 @@ per_key = true
|
||||
|
||||
[[led_data]]
|
||||
prod_family = "ROG Strix"
|
||||
board_names = ["G513QE", "GX531", "G512LV", "G712LV", "G712LW", "G513IH", "G513QY", "G713QM", "G512", "G713RW"]
|
||||
board_names = ["G513QE", "GX531", "G512LV", "G712LV", "G712LW", "G513IH", "G513QY", "G713QM", "G512", "G713RM", "G713RW"]
|
||||
standard = ["Static", "Breathe", "Strobe", "Rainbow", "Pulse"]
|
||||
multizone = ["Key1", "Key2", "Key3", "Key4"]
|
||||
per_key = false
|
||||
@@ -184,7 +191,7 @@ per_key = false
|
||||
|
||||
[[led_data]]
|
||||
prod_family = "ROG Strix"
|
||||
board_names = ["G513IC", "G513RC"]
|
||||
board_names = ["G513IC", "G513RC", "G513RM"]
|
||||
standard = ["Static", "Breathe", "Strobe", "Rainbow", "Pulse"]
|
||||
multizone = []
|
||||
per_key = false
|
||||
|
||||
+2
-2
@@ -9,7 +9,7 @@ ENV{DMI_FAMILY}=="*TUF*", GOTO="asusd_start"
|
||||
ENV{DMI_FAMILY}=="*ROG*", GOTO="asusd_start"
|
||||
ENV{DMI_FAMILY}=="*Zephyrus*", GOTO="asusd_start"
|
||||
ENV{DMI_FAMILY}=="*Strix*", GOTO="asusd_start"
|
||||
ENV{DMI_FAMILY}=="*Vivobook*", GOTO="asusd_start"
|
||||
ENV{DMI_FAMILY}=="*Vivo*ook*", GOTO="asusd_start"
|
||||
# No match so
|
||||
GOTO="asusd_end"
|
||||
|
||||
@@ -17,4 +17,4 @@ LABEL="asusd_start"
|
||||
ACTION=="add|change", DRIVER=="asus-nb-wmi", TAG+="systemd", ENV{SYSTEMD_WANTS}="asusd.service"
|
||||
ACTION=="add|remove", DRIVER=="asus-nb-wmi", TAG+="systemd", RUN+="systemctl restart asusd.service"
|
||||
|
||||
LABEL="asusd_end"
|
||||
LABEL="asusd_end"
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
# https://embarkstudios.github.io/cargo-deny/
|
||||
|
||||
targets = [
|
||||
{ triple = "aarch64-apple-darwin" },
|
||||
{ triple = "aarch64-linux-android" },
|
||||
{ triple = "wasm32-unknown-unknown" },
|
||||
{ triple = "x86_64-apple-darwin" },
|
||||
{ triple = "x86_64-pc-windows-msvc" },
|
||||
{ triple = "x86_64-unknown-linux-gnu" },
|
||||
{ triple = "x86_64-unknown-linux-musl" },
|
||||
]
|
||||
|
||||
[advisories]
|
||||
vulnerability = "deny"
|
||||
unmaintained = "warn"
|
||||
yanked = "deny"
|
||||
ignore = [
|
||||
"RUSTSEC-2020-0071", # https://rustsec.org/advisories/RUSTSEC-2020-0071 - chrono/time: Potential segfault in the time crate
|
||||
"RUSTSEC-2020-0159", # https://rustsec.org/advisories/RUSTSEC-2020-0159 - chrono/time: Potential segfault in localtime_r invocations
|
||||
"RUSTSEC-2021-0127", # https://rustsec.org/advisories/RUSTSEC-2021-0127 - https://github.com/bheisler/criterion.rs/issues/534
|
||||
]
|
||||
|
||||
[bans]
|
||||
multiple-versions = "deny"
|
||||
wildcards = "allow" # at least until https://github.com/EmbarkStudios/cargo-deny/issues/241 is fixed
|
||||
deny = [
|
||||
{ name = "openssl" }, # prefer rustls
|
||||
{ name = "openssl-sys" }, # prefer rustls
|
||||
]
|
||||
|
||||
skip-tree = [
|
||||
{ name = "criterion" }, # dev-dependency
|
||||
{ name = "glium" }, # legacy crate, lots of old dependencies
|
||||
{ name = "rfd" }, # example dependency
|
||||
{ name = "three-d" }, # example dependency
|
||||
]
|
||||
|
||||
|
||||
[licenses]
|
||||
unlicensed = "deny"
|
||||
allow-osi-fsf-free = "neither"
|
||||
confidence-threshold = 0.92 # We want really high confidence when inferring licenses from text
|
||||
copyleft = "deny"
|
||||
allow = [
|
||||
"Apache-2.0", # https://tldrlegal.com/license/apache-license-2.0-(apache-2.0)
|
||||
"BSD-2-Clause", # https://tldrlegal.com/license/bsd-2-clause-license-(freebsd)
|
||||
"BSD-3-Clause", # https://tldrlegal.com/license/bsd-3-clause-license-(revised)
|
||||
"BSL-1.0", # https://tldrlegal.com/license/boost-software-license-1.0-explained
|
||||
"CC0-1.0", # https://creativecommons.org/publicdomain/zero/1.0/
|
||||
"ISC", # https://tldrlegal.com/license/-isc-license
|
||||
"LicenseRef-UFL-1.0", # https://tldrlegal.com/license/ubuntu-font-license,-1.0 - no official SPDX, see https://github.com/emilk/egui/issues/2321
|
||||
"MIT", # https://tldrlegal.com/license/mit-license
|
||||
"MPL-2.0", # https://www.mozilla.org/en-US/MPL/2.0/FAQ/ - see Q11
|
||||
"OFL-1.1", # https://spdx.org/licenses/OFL-1.1.html
|
||||
"OpenSSL", # https://www.openssl.org/source/license.html
|
||||
"Unicode-DFS-2016", # https://spdx.org/licenses/Unicode-DFS-2016.html
|
||||
"Zlib", # https://tldrlegal.com/license/zlib-libpng-license-(zlib)
|
||||
]
|
||||
|
||||
[[licenses.clarify]]
|
||||
name = "webpki"
|
||||
expression = "ISC"
|
||||
license-files = [{ path = "LICENSE", hash = 0x001c7e6c }]
|
||||
|
||||
[[licenses.clarify]]
|
||||
name = "ring"
|
||||
expression = "MIT AND ISC AND OpenSSL"
|
||||
license-files = [{ path = "LICENSE", hash = 0xbd0eed23 }]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "rog_anime"
|
||||
version.workspace = true
|
||||
license = "MPL-2.0"
|
||||
version.workspace = true
|
||||
readme = "README.md"
|
||||
authors = ["Luke <luke@ljones.dev>"]
|
||||
repository = "https://gitlab.com/asus-linux/asus-nb-ctrl"
|
||||
@@ -14,7 +14,7 @@ exclude = ["data"]
|
||||
|
||||
[features]
|
||||
default = ["dbus", "detect"]
|
||||
dbus = ["zvariant", "zbus"]
|
||||
dbus = ["zbus"]
|
||||
detect = ["sysfs-class"]
|
||||
|
||||
[dependencies]
|
||||
@@ -28,7 +28,6 @@ serde_derive.workspace = true
|
||||
|
||||
glam.workspace = true
|
||||
|
||||
zvariant = { workspace = true, optional = true }
|
||||
zbus = { workspace = true, optional = true }
|
||||
|
||||
sysfs-class = { workspace = true, optional = true }
|
||||
sysfs-class = { workspace = true, optional = true }
|
||||
|
||||
+7
-11
@@ -7,7 +7,7 @@ use std::{
|
||||
use log::info;
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
#[cfg(feature = "dbus")]
|
||||
use zvariant::Type;
|
||||
use zbus::zvariant::Type;
|
||||
|
||||
use crate::{
|
||||
error::{AnimeError, Result},
|
||||
@@ -47,8 +47,7 @@ impl AnimeType {
|
||||
/// The width of diagonal images
|
||||
pub fn width(&self) -> usize {
|
||||
match self {
|
||||
AnimeType::GA401 => 74,
|
||||
AnimeType::GA402 => 74,
|
||||
AnimeType::GA401 | AnimeType::GA402 => 74,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,8 +102,8 @@ impl AnimeDataBuffer {
|
||||
|
||||
/// Create from a vector of bytes
|
||||
///
|
||||
/// # Panics
|
||||
/// Will panic if the vector length is not `ANIME_DATA_LEN`
|
||||
/// # Errors
|
||||
/// Will error if the vector length is not `ANIME_DATA_LEN`
|
||||
#[inline]
|
||||
pub fn from_vec(anime: AnimeType, data: Vec<u8>) -> Result<Self> {
|
||||
if data.len() != anime.data_length() {
|
||||
@@ -147,10 +146,7 @@ impl TryFrom<AnimeDataBuffer> for AnimePacketType {
|
||||
/// This runs the animations as a blocking loop by using the `callback` to write data
|
||||
///
|
||||
/// If `callback` is `Ok(true)` then `run_animation` will exit the animation loop early.
|
||||
pub fn run_animation(
|
||||
frames: &AnimeGif,
|
||||
callback: &dyn Fn(AnimeDataBuffer) -> Result<bool>,
|
||||
) -> Result<()> {
|
||||
pub fn run_animation(frames: &AnimeGif, callback: &dyn Fn(AnimeDataBuffer) -> Result<bool>) {
|
||||
let mut count = 0;
|
||||
let start = Instant::now();
|
||||
|
||||
@@ -215,9 +211,10 @@ pub fn run_animation(
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Log this error
|
||||
if matches!(callback(output), Ok(true)) {
|
||||
info!("rog-anime: frame-loop callback asked to exit early");
|
||||
return Ok(());
|
||||
return;
|
||||
}
|
||||
|
||||
if timed && Instant::now().duration_since(start) > run_time {
|
||||
@@ -232,5 +229,4 @@ pub fn run_animation(
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
+18
-14
@@ -52,39 +52,43 @@ impl AnimeDiagonal {
|
||||
|
||||
let mut matrix = AnimeDiagonal::new(anime_type, duration);
|
||||
|
||||
match raster {
|
||||
match &raster {
|
||||
png_pong::PngRaster::Gray8(ras) => {
|
||||
Self::pixels_from_8bit(ras, &mut matrix, bright, true)
|
||||
Self::pixels_from_8bit(ras, &mut matrix, bright, true);
|
||||
}
|
||||
png_pong::PngRaster::Graya8(ras) => {
|
||||
Self::pixels_from_8bit(ras, &mut matrix, bright, true)
|
||||
Self::pixels_from_8bit(ras, &mut matrix, bright, true);
|
||||
}
|
||||
png_pong::PngRaster::Rgb8(ras) => {
|
||||
Self::pixels_from_8bit(ras, &mut matrix, bright, false)
|
||||
Self::pixels_from_8bit(ras, &mut matrix, bright, false);
|
||||
}
|
||||
png_pong::PngRaster::Rgba8(ras) => {
|
||||
Self::pixels_from_8bit(ras, &mut matrix, bright, false)
|
||||
Self::pixels_from_8bit(ras, &mut matrix, bright, false);
|
||||
}
|
||||
png_pong::PngRaster::Gray16(ras) => {
|
||||
Self::pixels_from_16bit(ras, &mut matrix, bright, true)
|
||||
Self::pixels_from_16bit(ras, &mut matrix, bright, true);
|
||||
}
|
||||
png_pong::PngRaster::Rgb16(ras) => {
|
||||
Self::pixels_from_16bit(ras, &mut matrix, bright, false)
|
||||
Self::pixels_from_16bit(ras, &mut matrix, bright, false);
|
||||
}
|
||||
png_pong::PngRaster::Graya16(ras) => {
|
||||
Self::pixels_from_16bit(ras, &mut matrix, bright, true)
|
||||
Self::pixels_from_16bit(ras, &mut matrix, bright, true);
|
||||
}
|
||||
png_pong::PngRaster::Rgba16(ras) => {
|
||||
Self::pixels_from_16bit(ras, &mut matrix, bright, false)
|
||||
Self::pixels_from_16bit(ras, &mut matrix, bright, false);
|
||||
}
|
||||
_ => return Err(AnimeError::Format),
|
||||
png_pong::PngRaster::Palette(..) => return Err(AnimeError::Format),
|
||||
};
|
||||
|
||||
Ok(matrix)
|
||||
}
|
||||
|
||||
fn pixels_from_8bit<P>(ras: pix::Raster<P>, matrix: &mut AnimeDiagonal, bright: f32, grey: bool)
|
||||
where
|
||||
fn pixels_from_8bit<P>(
|
||||
ras: &pix::Raster<P>,
|
||||
matrix: &mut AnimeDiagonal,
|
||||
bright: f32,
|
||||
grey: bool,
|
||||
) where
|
||||
P: pix::el::Pixel<Chan = pix::chan::Ch8>,
|
||||
{
|
||||
let width = ras.width();
|
||||
@@ -105,7 +109,7 @@ impl AnimeDiagonal {
|
||||
}
|
||||
|
||||
fn pixels_from_16bit<P>(
|
||||
ras: pix::Raster<P>,
|
||||
ras: &pix::Raster<P>,
|
||||
matrix: &mut AnimeDiagonal,
|
||||
bright: f32,
|
||||
grey: bool,
|
||||
@@ -136,7 +140,7 @@ impl AnimeDiagonal {
|
||||
}
|
||||
}
|
||||
|
||||
/// Do conversion from the nested Vec in AnimeMatrix to the two required
|
||||
/// Do conversion from the nested Vec in `AnimeMatrix` to the two required
|
||||
/// packets suitable for sending over USB
|
||||
fn to_ga401_packets(&self) -> Result<AnimeDataBuffer> {
|
||||
let mut buf = vec![0u8; AnimeType::GA401.data_length()];
|
||||
|
||||
@@ -26,7 +26,7 @@ pub enum AnimeError {
|
||||
|
||||
impl fmt::Display for AnimeError {
|
||||
#[inline]
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
AnimeError::NoFrames => write!(f, "No frames in PNG"),
|
||||
AnimeError::Io(e) => write!(f, "Could not open: {}", e),
|
||||
|
||||
@@ -93,7 +93,7 @@ impl AnimeGrid {
|
||||
impl TryFrom<AnimeGrid> for AnimeDataBuffer {
|
||||
type Error = AnimeError;
|
||||
|
||||
/// Do conversion from the nested Vec in AniMeMatrix to the two required
|
||||
/// Do conversion from the nested Vec in anime matrix to the two required
|
||||
/// packets suitable for sending over USB
|
||||
fn try_from(anime: AnimeGrid) -> Result<Self> {
|
||||
let mut buf = vec![0u8; anime.anime_type.data_length()];
|
||||
|
||||
@@ -30,7 +30,7 @@ impl Default for Pixel {
|
||||
/// is to be used to sample an image and set the LED brightness.
|
||||
///
|
||||
/// The position of the Led in `LedPositions` determines the placement in the final
|
||||
/// data packets when written to the AniMe.
|
||||
/// data packets when written to the `AniMe`.
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
pub struct Led(f32, f32, u8);
|
||||
|
||||
@@ -58,7 +58,7 @@ impl Led {
|
||||
|
||||
/// Container of `Led`, each of which specifies a position within the image
|
||||
/// The main use of this is to position and sample colours for the final image
|
||||
/// to show on AniMe
|
||||
/// to show on `AniMe`
|
||||
pub struct AnimeImage {
|
||||
pub scale: Vec2,
|
||||
/// Angle in radians
|
||||
@@ -294,8 +294,8 @@ impl AnimeImage {
|
||||
let x0 = led_from_px.mul_vec3(pos + Vec3::new(0.0, -0.5, 0.0));
|
||||
|
||||
const GROUP: [f32; 4] = [0.0, 0.5, 1.0, 1.5];
|
||||
for u in GROUP.iter() {
|
||||
for v in GROUP.iter() {
|
||||
for u in &GROUP {
|
||||
for v in &GROUP {
|
||||
let sample = x0 + *u * du + *v * dv;
|
||||
|
||||
let x = sample.x as i32;
|
||||
@@ -399,7 +399,7 @@ impl AnimeImage {
|
||||
let png_pong::Step { raster, delay: _ } = decoder.last().ok_or(AnimeError::NoFrames)??;
|
||||
|
||||
let width;
|
||||
let pixels = match raster {
|
||||
let pixels = match &raster {
|
||||
png_pong::PngRaster::Gray8(ras) => {
|
||||
width = ras.width();
|
||||
Self::pixels_from_8bit(ras, true)
|
||||
@@ -432,7 +432,7 @@ impl AnimeImage {
|
||||
width = ras.width();
|
||||
Self::pixels_from_16bit(ras, false)
|
||||
}
|
||||
_ => return Err(AnimeError::Format),
|
||||
png_pong::PngRaster::Palette(..) => return Err(AnimeError::Format),
|
||||
};
|
||||
|
||||
let mut matrix = AnimeImage::new(
|
||||
@@ -449,7 +449,7 @@ impl AnimeImage {
|
||||
Ok(matrix)
|
||||
}
|
||||
|
||||
fn pixels_from_8bit<P>(ras: pix::Raster<P>, grey: bool) -> Vec<Pixel>
|
||||
fn pixels_from_8bit<P>(ras: &pix::Raster<P>, grey: bool) -> Vec<Pixel>
|
||||
where
|
||||
P: pix::el::Pixel<Chan = pix::chan::Ch8>,
|
||||
{
|
||||
@@ -468,7 +468,7 @@ impl AnimeImage {
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn pixels_from_16bit<P>(ras: pix::Raster<P>, grey: bool) -> Vec<Pixel>
|
||||
fn pixels_from_16bit<P>(ras: &pix::Raster<P>, grey: bool) -> Vec<Pixel>
|
||||
where
|
||||
P: pix::el::Pixel<Chan = pix::chan::Ch16>,
|
||||
{
|
||||
@@ -491,7 +491,7 @@ impl AnimeImage {
|
||||
impl TryFrom<&AnimeImage> for AnimeDataBuffer {
|
||||
type Error = AnimeError;
|
||||
|
||||
/// Do conversion from the nested Vec in AnimeDataBuffer to the two required
|
||||
/// Do conversion from the nested Vec in `AnimeDataBuffer` to the two required
|
||||
/// packets suitable for sending over USB
|
||||
fn try_from(leds: &AnimeImage) -> Result<Self> {
|
||||
let mut l: Vec<u8> = leds
|
||||
|
||||
@@ -7,11 +7,11 @@ pub use data::*;
|
||||
mod grid;
|
||||
pub use grid::*;
|
||||
|
||||
/// Transform a PNG image for displaying on AniMe matrix display
|
||||
/// Transform a PNG image for displaying on `AniMe` matrix display
|
||||
mod image;
|
||||
pub use image::*;
|
||||
|
||||
/// A grid of data that is intended to be read out and displayed on the ANiMe as
|
||||
/// A grid of data that is intended to be read out and displayed on the `AniMe` as
|
||||
/// a diagonal
|
||||
mod diagonal;
|
||||
pub use diagonal::*;
|
||||
|
||||
@@ -7,7 +7,7 @@ use crate::{
|
||||
error::Result, AnimTime, AnimeDataBuffer, AnimeDiagonal, AnimeGif, AnimeImage, AnimeType,
|
||||
};
|
||||
|
||||
/// All the possible AniMe actions that can be used. This enum is intended to be
|
||||
/// All the possible `AniMe` actions that can be used. This enum is intended to be
|
||||
/// a helper for loading up `ActionData`.
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
pub enum ActionLoader {
|
||||
@@ -44,7 +44,7 @@ pub enum ActionLoader {
|
||||
Pause(Duration),
|
||||
}
|
||||
|
||||
/// All the possible AniMe actions that can be used. The enum is intended to be
|
||||
/// All the possible `AniMe` actions that can be used. The enum is intended to be
|
||||
/// used in a array allowing the user to cycle through a series of actions.
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
pub enum ActionData {
|
||||
@@ -194,7 +194,7 @@ impl Sequences {
|
||||
None
|
||||
}
|
||||
|
||||
pub fn iter(&self) -> ActionIterator {
|
||||
pub fn iter(&self) -> ActionIterator<'_> {
|
||||
ActionIterator {
|
||||
actions: self,
|
||||
next_idx: 0,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! Utils for writing to the AniMe USB device
|
||||
//! Utils for writing to the `AniMe` USB device
|
||||
//!
|
||||
//! Use of the device requires a few steps:
|
||||
//! 1. Initialise the device by writing the two packets from `get_init_packets()`
|
||||
@@ -63,7 +63,7 @@ pub const fn pkt_for_flush() -> [u8; PACKET_SIZE] {
|
||||
}
|
||||
|
||||
/// Get the packet required for setting the device to on, on boot. Requires
|
||||
/// pkt_for_apply()` to be written after.
|
||||
/// `pkt_for_apply()` to be written after.
|
||||
#[inline]
|
||||
pub const fn pkt_for_set_boot(status: bool) -> [u8; PACKET_SIZE] {
|
||||
let mut pkt = [0; PACKET_SIZE];
|
||||
|
||||
+4
-4
@@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "rog_aura"
|
||||
version.workspace = true
|
||||
license = "MPL-2.0"
|
||||
version.workspace = true
|
||||
readme = "README.md"
|
||||
authors = ["Luke <luke@ljones.dev>"]
|
||||
repository = "https://gitlab.com/asus-linux/asusctl"
|
||||
@@ -14,13 +14,13 @@ exclude = ["data"]
|
||||
|
||||
[features]
|
||||
default = ["dbus", "toml"]
|
||||
dbus = ["zvariant"]
|
||||
dbus = ["zbus"]
|
||||
|
||||
[dependencies]
|
||||
serde.workspace = true
|
||||
serde_derive.workspace = true
|
||||
toml = { workspace = true, optional = true }
|
||||
zvariant = { workspace = true, optional = true }
|
||||
zbus = { workspace = true, optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
serde_json.workspace = true
|
||||
serde_json.workspace = true
|
||||
|
||||
@@ -7,7 +7,7 @@ pub const LED_INIT5: [u8; 6] = [0x5e, 0x05, 0x20, 0x31, 0, 0x08];
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use std::{fmt::Display, str::FromStr};
|
||||
#[cfg(feature = "dbus")]
|
||||
use zvariant::Type;
|
||||
use zbus::zvariant::Type;
|
||||
|
||||
use crate::{error::Error, LED_MSG_LEN};
|
||||
|
||||
@@ -25,7 +25,6 @@ impl From<u32> for LedBrightness {
|
||||
match bright {
|
||||
0 => LedBrightness::Off,
|
||||
1 => LedBrightness::Low,
|
||||
2 => LedBrightness::Med,
|
||||
3 => LedBrightness::High,
|
||||
_ => LedBrightness::Med,
|
||||
}
|
||||
@@ -179,21 +178,7 @@ impl Display for AuraModeNum {
|
||||
|
||||
impl From<AuraModeNum> for String {
|
||||
fn from(mode: AuraModeNum) -> Self {
|
||||
match mode {
|
||||
AuraModeNum::Static => "Static",
|
||||
AuraModeNum::Breathe => "Breathe",
|
||||
AuraModeNum::Strobe => "Strobe",
|
||||
AuraModeNum::Rainbow => "Rainbow",
|
||||
AuraModeNum::Star => "Stars",
|
||||
AuraModeNum::Rain => "Rain",
|
||||
AuraModeNum::Highlight => "Highlight",
|
||||
AuraModeNum::Laser => "Laser",
|
||||
AuraModeNum::Ripple => "Ripple",
|
||||
AuraModeNum::Pulse => "Pulse",
|
||||
AuraModeNum::Comet => "Comet",
|
||||
AuraModeNum::Flash => "Flash",
|
||||
}
|
||||
.to_string()
|
||||
<&str>::from(&mode).to_owned()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,7 +203,6 @@ impl From<&AuraModeNum> for &str {
|
||||
impl From<&str> for AuraModeNum {
|
||||
fn from(mode: &str) -> Self {
|
||||
match mode {
|
||||
"Static" => AuraModeNum::Static,
|
||||
"Breathe" => AuraModeNum::Breathe,
|
||||
"Strobe" => AuraModeNum::Strobe,
|
||||
"Rainbow" => AuraModeNum::Rainbow,
|
||||
@@ -238,7 +222,6 @@ impl From<&str> for AuraModeNum {
|
||||
impl From<u8> for AuraModeNum {
|
||||
fn from(mode: u8) -> Self {
|
||||
match mode {
|
||||
0 => AuraModeNum::Static,
|
||||
1 => AuraModeNum::Breathe,
|
||||
2 => AuraModeNum::Strobe,
|
||||
3 => AuraModeNum::Rainbow,
|
||||
@@ -284,22 +267,14 @@ impl FromStr for AuraZone {
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
let s = s.to_lowercase();
|
||||
match s.to_ascii_lowercase().as_str() {
|
||||
"0" => Ok(AuraZone::None),
|
||||
"none" => Ok(AuraZone::None),
|
||||
"1" => Ok(AuraZone::Key1),
|
||||
"one" => Ok(AuraZone::Key1),
|
||||
"2" => Ok(AuraZone::Key2),
|
||||
"two" => Ok(AuraZone::Key2),
|
||||
"3" => Ok(AuraZone::Key3),
|
||||
"three" => Ok(AuraZone::Key3),
|
||||
"4" => Ok(AuraZone::Key4),
|
||||
"four" => Ok(AuraZone::Key4),
|
||||
"5" => Ok(AuraZone::Logo),
|
||||
"logo" => Ok(AuraZone::Logo),
|
||||
"6" => Ok(AuraZone::BarLeft),
|
||||
"lightbar-left" => Ok(AuraZone::BarLeft),
|
||||
"7" => Ok(AuraZone::BarRight),
|
||||
"lightbar-right" => Ok(AuraZone::BarRight),
|
||||
"0" | "none" => Ok(AuraZone::None),
|
||||
"1" | "one" => Ok(AuraZone::Key1),
|
||||
"2" | "two" => Ok(AuraZone::Key2),
|
||||
"3" | "three" => Ok(AuraZone::Key3),
|
||||
"4" | "four" => Ok(AuraZone::Key4),
|
||||
"5" | "logo" => Ok(AuraZone::Logo),
|
||||
"6" | "lightbar-left" => Ok(AuraZone::BarLeft),
|
||||
"7" | "lightbar-right" => Ok(AuraZone::BarRight),
|
||||
_ => Err(Error::ParseSpeed),
|
||||
}
|
||||
}
|
||||
@@ -395,18 +370,20 @@ impl AuraEffect {
|
||||
/// factory mode accepts only one colour.
|
||||
pub const fn allowed_parameters(mode: AuraModeNum) -> AuraParameters {
|
||||
match mode {
|
||||
AuraModeNum::Static => AuraParameters::new(true, true, false, false, false),
|
||||
AuraModeNum::Static
|
||||
| AuraModeNum::Highlight
|
||||
| AuraModeNum::Pulse
|
||||
| AuraModeNum::Comet
|
||||
| AuraModeNum::Flash => AuraParameters::new(true, true, false, false, false),
|
||||
AuraModeNum::Breathe => AuraParameters::new(true, true, true, true, false),
|
||||
AuraModeNum::Strobe => AuraParameters::new(true, false, false, true, false),
|
||||
AuraModeNum::Strobe | AuraModeNum::Rain => {
|
||||
AuraParameters::new(true, false, false, true, false)
|
||||
}
|
||||
AuraModeNum::Rainbow => AuraParameters::new(true, false, false, true, true),
|
||||
AuraModeNum::Star => AuraParameters::new(true, true, true, true, true),
|
||||
AuraModeNum::Rain => AuraParameters::new(true, false, false, true, false),
|
||||
AuraModeNum::Highlight => AuraParameters::new(true, true, false, false, false),
|
||||
AuraModeNum::Laser => AuraParameters::new(true, true, false, true, false),
|
||||
AuraModeNum::Ripple => AuraParameters::new(true, true, false, true, false),
|
||||
AuraModeNum::Pulse => AuraParameters::new(true, true, false, false, false),
|
||||
AuraModeNum::Comet => AuraParameters::new(true, true, false, false, false),
|
||||
AuraModeNum::Flash => AuraParameters::new(true, true, false, false, false),
|
||||
AuraModeNum::Laser | AuraModeNum::Ripple => {
|
||||
AuraParameters::new(true, true, false, true, false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ pub enum Error {
|
||||
|
||||
impl fmt::Display for Error {
|
||||
// This trait requires `fmt` with this exact signature.
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Error::ParseColour => write!(f, "Could not parse colour"),
|
||||
Error::ParseSpeed => write!(f, "Could not parse speed"),
|
||||
|
||||
+11
-11
@@ -139,17 +139,17 @@ impl From<&Key> for &str {
|
||||
Key::MediaStop => "Media Stop",
|
||||
Key::MediaNext => "Media Next",
|
||||
Key::MediaPrev => "Media Previous",
|
||||
Key::NormalBlank => "",
|
||||
Key::NormalSpacer => "",
|
||||
Key::FuncBlank => "",
|
||||
Key::FuncSpacer => "",
|
||||
Key::ArrowBlank => "",
|
||||
Key::ArrowSpacer => "",
|
||||
Key::ArrowRegularBlank => "",
|
||||
Key::ArrowRegularSpacer => "",
|
||||
Key::ArrowSplitBlank => "",
|
||||
Key::ArrowSplitSpacer => "",
|
||||
Key::RowEndSpacer => "",
|
||||
Key::NormalBlank
|
||||
| Key::NormalSpacer
|
||||
| Key::FuncBlank
|
||||
| Key::FuncSpacer
|
||||
| Key::ArrowBlank
|
||||
| Key::ArrowSpacer
|
||||
| Key::ArrowRegularBlank
|
||||
| Key::ArrowRegularSpacer
|
||||
| Key::ArrowSplitBlank
|
||||
| Key::ArrowSplitSpacer
|
||||
| Key::RowEndSpacer => "",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+14
-12
@@ -203,17 +203,22 @@ pub enum KeyShape {
|
||||
impl KeyShape {
|
||||
pub const fn width(&self) -> f32 {
|
||||
match self {
|
||||
Self::Tilde => 0.8,
|
||||
Self::Normal => 1.0,
|
||||
Self::NormalBlank => 1.0,
|
||||
Self::NormalSpacer => 1.0,
|
||||
Self::Func => 1.0,
|
||||
Self::FuncBlank => 1.0,
|
||||
Self::Tilde | Self::Arrow => 0.8,
|
||||
Self::Normal
|
||||
| Self::NormalBlank
|
||||
| Self::NormalSpacer
|
||||
| Self::Func
|
||||
| Self::FuncBlank
|
||||
| Self::Space5
|
||||
| Self::ArrowBlank
|
||||
| Self::ArrowSpacer
|
||||
| Self::ArrowSplit
|
||||
| Self::ArrowSplitBlank
|
||||
| Self::ArrowSplitSpacer => 1.0,
|
||||
Self::FuncSpacer => 0.6,
|
||||
Self::Space => 5.0,
|
||||
Self::Space5 => 1.0,
|
||||
Self::LCtrlMed => 1.1,
|
||||
Self::LShift => 2.0,
|
||||
Self::LShift | Self::Backspace => 2.0,
|
||||
Self::LShift3 => 0.67,
|
||||
Self::RShift => 2.8,
|
||||
Self::RshiftSmall => 1.8,
|
||||
@@ -222,12 +227,9 @@ impl KeyShape {
|
||||
Self::Return3 => 0.7333,
|
||||
Self::Tab => 1.4,
|
||||
Self::Caps => 1.6,
|
||||
Self::Backspace => 2.0,
|
||||
Self::Backspace3 => 0.666,
|
||||
Self::ArrowRegularBlank | Self::ArrowRegularSpacer => 0.7,
|
||||
Self::Arrow => 0.8,
|
||||
Self::ArrowBlank | Self::ArrowSpacer => 1.0,
|
||||
Self::ArrowSplit | Self::ArrowSplitBlank | Self::ArrowSplitSpacer => 1.0,
|
||||
|
||||
Self::RowEndSpacer => 0.1,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ impl KeyLayout {
|
||||
pub fn g513_layout() -> Self {
|
||||
Self {
|
||||
matches: vec!["G513".into()],
|
||||
locale: "US".to_string(),
|
||||
locale: "US".to_owned(),
|
||||
rows: vec![
|
||||
KeyRow::new(
|
||||
0.8,
|
||||
|
||||
@@ -5,7 +5,7 @@ impl KeyLayout {
|
||||
pub fn ga401_layout() -> Self {
|
||||
Self {
|
||||
matches: vec!["GA401".into(), "GA402".into()],
|
||||
locale: "US".to_string(),
|
||||
locale: "US".to_owned(),
|
||||
rows: vec![
|
||||
KeyRow::new(
|
||||
0.8,
|
||||
|
||||
@@ -5,7 +5,7 @@ impl KeyLayout {
|
||||
pub fn gx502_layout() -> Self {
|
||||
Self {
|
||||
matches: vec!["GX502".into(), "GU502".into()],
|
||||
locale: "US".to_string(),
|
||||
locale: "US".to_owned(),
|
||||
rows: vec![
|
||||
KeyRow::new(
|
||||
0.8,
|
||||
|
||||
@@ -43,7 +43,7 @@ impl KeyLayout {
|
||||
|
||||
pub fn matches(&self, board_name: &str) -> bool {
|
||||
let board = board_name.to_ascii_uppercase();
|
||||
for tmp in self.matches.iter() {
|
||||
for tmp in &self.matches {
|
||||
if board.contains(tmp.as_str()) {
|
||||
return true;
|
||||
}
|
||||
@@ -91,7 +91,7 @@ impl KeyRow {
|
||||
Self { height, row }
|
||||
}
|
||||
|
||||
pub fn row(&self) -> Iter<Key> {
|
||||
pub fn row(&self) -> Iter<'_, Key> {
|
||||
self.row.iter()
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::keys::Key;
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
#[cfg(feature = "dbus")]
|
||||
use zvariant::Type;
|
||||
use zbus::zvariant::Type;
|
||||
|
||||
/// Represents the per-key raw USB packets
|
||||
pub type PerKeyRaw = Vec<Vec<u8>>;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
#[cfg(feature = "dbus")]
|
||||
use zvariant::Type;
|
||||
use zbus::zvariant::Type;
|
||||
|
||||
/// Represents the zoned raw USB packets
|
||||
pub type ZonedRaw = Vec<u8>;
|
||||
@@ -43,8 +43,7 @@ impl ZonedColourArray {
|
||||
|
||||
pub fn rgb_for_zone(&mut self, zone: PerZone) -> &mut [u8] {
|
||||
match zone {
|
||||
PerZone::None => &mut self.0[9..=11],
|
||||
PerZone::KeyboardLeft => &mut self.0[9..=11],
|
||||
PerZone::None | PerZone::KeyboardLeft => &mut self.0[9..=11],
|
||||
PerZone::KeyboardCenterLeft => &mut self.0[12..=14],
|
||||
PerZone::KeyboardCenterRight => &mut self.0[15..=17],
|
||||
PerZone::KeyboardRight => &mut self.0[18..=20],
|
||||
|
||||
@@ -9,7 +9,7 @@ use serde_derive::{Deserialize, Serialize};
|
||||
// static mut RNDINDEX: usize = 0;
|
||||
static mut PRNDINDEX: usize = 0;
|
||||
|
||||
/// Pseudo random table ripped straight out of Room4Doom
|
||||
/// Pseudo random table ripped straight out of room4doom
|
||||
pub const RNDTABLE: [i32; 256] = [
|
||||
0, 8, 109, 220, 222, 241, 149, 107, 75, 248, 254, 140, 16, 66, 74, 21, 211, 47, 80, 242, 154,
|
||||
27, 205, 128, 161, 89, 77, 36, 95, 110, 85, 48, 212, 140, 211, 249, 22, 79, 200, 50, 28, 188,
|
||||
@@ -88,7 +88,7 @@ impl Sequences {
|
||||
}
|
||||
|
||||
pub fn next_state(&mut self, layout: &KeyLayout) {
|
||||
for effect in self.0.iter_mut() {
|
||||
for effect in &mut self.0 {
|
||||
effect.next_state(layout);
|
||||
}
|
||||
}
|
||||
@@ -97,7 +97,7 @@ impl Sequences {
|
||||
let mut keys = KeyColourArray::new();
|
||||
let mut zones = ZonedColourArray::new();
|
||||
let mut is_per_key = false;
|
||||
for effect in self.0.iter() {
|
||||
for effect in &self.0 {
|
||||
match effect.get_led_type() {
|
||||
LedType::Key(key) => {
|
||||
is_per_key = true;
|
||||
|
||||
+9
-13
@@ -1,7 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::ops::{BitAnd, BitOr};
|
||||
#[cfg(feature = "dbus")]
|
||||
use zvariant::Type;
|
||||
use zbus::zvariant::Type;
|
||||
|
||||
pub const LED_INIT1: [u8; 2] = [0x5d, 0xb9];
|
||||
pub const LED_INIT2: &str = "]ASUS Tech.Inc."; // ] == 0x5d
|
||||
@@ -36,14 +36,10 @@ impl From<&str> for AuraDevice {
|
||||
fn from(s: &str) -> Self {
|
||||
match s.to_lowercase().as_str() {
|
||||
"tuf" => AuraDevice::Tuf,
|
||||
"1866" => AuraDevice::X1866,
|
||||
"1869" => AuraDevice::X1869,
|
||||
"1854" => AuraDevice::X1854,
|
||||
"19b6" => AuraDevice::X19B6,
|
||||
"0x1866" => AuraDevice::X1866,
|
||||
"0x1869" => AuraDevice::X1869,
|
||||
"0x1854" => AuraDevice::X1854,
|
||||
"0x19b6" => AuraDevice::X19B6,
|
||||
"1866" | "0x1866" => AuraDevice::X1866,
|
||||
"1869" | "0x1869" => AuraDevice::X1869,
|
||||
"1854" | "0x1854" => AuraDevice::X1854,
|
||||
"19b6" | "0x19b6" => AuraDevice::X19B6,
|
||||
_ => AuraDevice::Unknown,
|
||||
}
|
||||
}
|
||||
@@ -108,9 +104,9 @@ impl From<AuraDev1866> for u32 {
|
||||
impl AuraDev1866 {
|
||||
pub fn to_bytes(control: &[Self]) -> [u8; 3] {
|
||||
let mut a: u32 = 0;
|
||||
control.iter().for_each(|n| {
|
||||
for n in control {
|
||||
a |= *n as u32;
|
||||
});
|
||||
}
|
||||
[
|
||||
((a & 0xff0000) >> 16) as u8,
|
||||
((a & 0xff00) >> 8) as u8,
|
||||
@@ -197,9 +193,9 @@ impl From<AuraDev19b6> for u32 {
|
||||
impl AuraDev19b6 {
|
||||
pub fn to_bytes(control: &[Self]) -> [u8; 3] {
|
||||
let mut a: u32 = 0;
|
||||
control.iter().for_each(|n| {
|
||||
for n in control {
|
||||
a |= *n as u32;
|
||||
});
|
||||
}
|
||||
[
|
||||
(a & 0xff) as u8,
|
||||
((a & 0xff00) >> 8) as u8,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
[package]
|
||||
name = "rog-control-center"
|
||||
license = "MPL-2.0"
|
||||
version.workspace = true
|
||||
authors = ["Luke D. Jones <luke@ljones.dev>"]
|
||||
edition = "2021"
|
||||
@@ -8,12 +9,11 @@ edition = "2021"
|
||||
mocking = []
|
||||
|
||||
[dependencies]
|
||||
egui = { git = "https://github.com/flukejones/egui" }
|
||||
eframe= { git = "https://github.com/flukejones/egui" }
|
||||
#eframe= { git = "https://github.com/emilk/egui", default-features = false, features = ["dark-light", "default_fonts", "wgpu"] }
|
||||
egui = { git = "https://github.com/flukejones/egui", branch = "wayland_dark_theme" }
|
||||
eframe= { git = "https://github.com/flukejones/egui", branch = "wayland_dark_theme" }
|
||||
|
||||
libappindicator = "0.7" # Tray icon
|
||||
gtk = "0.15"
|
||||
gtk = "0.15.5"
|
||||
|
||||
daemon = { path = "../daemon" }
|
||||
rog_anime = { path = "../rog-anime" }
|
||||
@@ -38,5 +38,7 @@ notify-rust.workspace = true
|
||||
|
||||
png_pong.workspace = true
|
||||
|
||||
nix = "^0.25"
|
||||
tempfile = "3.2.0"
|
||||
nix = "^0.26.1"
|
||||
tempfile = "3.3.0"
|
||||
|
||||
once_cell = "1.10.0"
|
||||
|
||||
@@ -6,7 +6,7 @@ use std::{
|
||||
};
|
||||
//use log::{error, info, warn};
|
||||
|
||||
use crate::{error::Error, notify::EnabledNotifications};
|
||||
use crate::{error::Error, update_and_notify::EnabledNotifications};
|
||||
|
||||
const CFG_DIR: &str = "rog";
|
||||
const CFG_FILE_NAME: &str = "rog-control-center.cfg";
|
||||
|
||||
@@ -15,7 +15,7 @@ pub enum Error {
|
||||
|
||||
impl fmt::Display for Error {
|
||||
// This trait requires `fmt` with this exact signature.
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Error::Io(err) => write!(f, "Failed to open: {}", err),
|
||||
Error::Nix(err) => write!(f, "Error: {}", err),
|
||||
|
||||
@@ -13,11 +13,11 @@ pub mod config;
|
||||
pub mod error;
|
||||
#[cfg(feature = "mocking")]
|
||||
pub mod mocking;
|
||||
pub mod notify;
|
||||
pub mod pages;
|
||||
pub mod startup_error;
|
||||
pub mod system_state;
|
||||
pub mod tray;
|
||||
pub mod update_and_notify;
|
||||
pub mod widgets;
|
||||
|
||||
#[cfg(feature = "mocking")]
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
use eframe::{IconData, NativeOptions};
|
||||
use log::{error, info, LevelFilter};
|
||||
use rog_aura::layouts::KeyLayout;
|
||||
use rog_control_center::notify::EnabledNotifications;
|
||||
use rog_control_center::tray::init_tray;
|
||||
use rog_control_center::update_and_notify::EnabledNotifications;
|
||||
use rog_control_center::{
|
||||
config::Config, error::Result, get_ipc_file, notify::start_notifications, on_tmp_dir_exists,
|
||||
print_versions, startup_error::AppErrorShow, system_state::SystemState, RogApp,
|
||||
RogDbusClientBlocking, SHOWING_GUI, SHOW_GUI,
|
||||
config::Config, error::Result, get_ipc_file, on_tmp_dir_exists, print_versions,
|
||||
startup_error::AppErrorShow, system_state::SystemState, update_and_notify::start_notifications,
|
||||
RogApp, RogDbusClientBlocking, SHOWING_GUI, SHOW_GUI,
|
||||
};
|
||||
use rog_platform::supported::SupportedFunctions;
|
||||
use std::sync::Mutex;
|
||||
@@ -206,7 +206,7 @@ fn load_icon() -> IconData {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
error!("Missing {APP_ICON_PATH}")
|
||||
error!("Missing {APP_ICON_PATH}");
|
||||
}
|
||||
|
||||
IconData {
|
||||
|
||||
@@ -22,7 +22,7 @@ impl RogApp {
|
||||
ui,
|
||||
);
|
||||
|
||||
fan_graphs(supported, &mut states.profiles, &mut states.fan_curves, &states.asus_dbus, &mut states.error, ui);
|
||||
fan_graphs(supported, &mut states.fan_curves, &states.asus_dbus, &mut states.error, ui);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ impl RogApp {
|
||||
supported: &SupportedFunctions,
|
||||
profiles: &mut ProfilesState,
|
||||
curves: &mut FanCurvesState,
|
||||
dbus: &RogDbusClientBlocking,
|
||||
dbus: &RogDbusClientBlocking<'_>,
|
||||
do_error: &mut Option<String>,
|
||||
ui: &mut Ui,
|
||||
) {
|
||||
@@ -62,7 +62,7 @@ impl RogApp {
|
||||
};
|
||||
|
||||
profiles.list.sort();
|
||||
for f in profiles.list.iter() {
|
||||
for f in &profiles.list {
|
||||
item(*f, curves, curves.enabled.contains(f));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -12,9 +12,10 @@ use supergfxctl::{
|
||||
zbus_proxy::DaemonProxyBlocking as GfxProxyBlocking,
|
||||
};
|
||||
|
||||
use crate::{error::Result, notify::EnabledNotifications, RogDbusClientBlocking};
|
||||
use crate::{error::Result, update_and_notify::EnabledNotifications, RogDbusClientBlocking};
|
||||
use log::error;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub struct BiosState {
|
||||
/// To be shared to a thread that checks notifications.
|
||||
/// It's a bit general in that it won't provide *what* was
|
||||
@@ -27,7 +28,7 @@ pub struct BiosState {
|
||||
}
|
||||
|
||||
impl BiosState {
|
||||
pub fn new(supported: &SupportedFunctions, dbus: &RogDbusClientBlocking) -> Result<Self> {
|
||||
pub fn new(supported: &SupportedFunctions, dbus: &RogDbusClientBlocking<'_>) -> Result<Self> {
|
||||
Ok(Self {
|
||||
post_sound: if supported.rog_bios_ctrl.post_sound {
|
||||
dbus.proxies().rog_bios().post_boot_sound()? != 0
|
||||
@@ -51,14 +52,14 @@ impl BiosState {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub struct ProfilesState {
|
||||
pub list: Vec<Profile>,
|
||||
pub current: Profile,
|
||||
}
|
||||
|
||||
impl ProfilesState {
|
||||
pub fn new(supported: &SupportedFunctions, dbus: &RogDbusClientBlocking) -> Result<Self> {
|
||||
pub fn new(supported: &SupportedFunctions, dbus: &RogDbusClientBlocking<'_>) -> Result<Self> {
|
||||
Ok(Self {
|
||||
list: if supported.platform_profile.platform_profile {
|
||||
let mut list = dbus.proxies().profile().profiles()?;
|
||||
@@ -76,7 +77,7 @@ impl ProfilesState {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub struct FanCurvesState {
|
||||
pub show_curve: Profile,
|
||||
pub show_graph: FanCurvePU,
|
||||
@@ -86,26 +87,25 @@ pub struct FanCurvesState {
|
||||
}
|
||||
|
||||
impl FanCurvesState {
|
||||
pub fn new(supported: &SupportedFunctions, dbus: &RogDbusClientBlocking) -> Result<Self> {
|
||||
pub fn new(supported: &SupportedFunctions, dbus: &RogDbusClientBlocking<'_>) -> Result<Self> {
|
||||
let profiles = if supported.platform_profile.platform_profile {
|
||||
dbus.proxies().profile().profiles()?
|
||||
} else {
|
||||
vec![Profile::Balanced, Profile::Quiet, Profile::Performance]
|
||||
};
|
||||
let enabled = if supported.platform_profile.fan_curves {
|
||||
HashSet::from_iter(
|
||||
dbus.proxies()
|
||||
.profile()
|
||||
.enabled_fan_profiles()?
|
||||
.iter()
|
||||
.cloned(),
|
||||
)
|
||||
dbus.proxies()
|
||||
.profile()
|
||||
.enabled_fan_profiles()?
|
||||
.iter()
|
||||
.cloned()
|
||||
.collect::<HashSet<_>>()
|
||||
} else {
|
||||
HashSet::from([Profile::Balanced, Profile::Quiet, Profile::Performance])
|
||||
};
|
||||
|
||||
let mut curves: BTreeMap<Profile, FanCurveSet> = BTreeMap::new();
|
||||
profiles.iter().for_each(|p| {
|
||||
for p in &profiles {
|
||||
if supported.platform_profile.fan_curves {
|
||||
if let Ok(curve) = dbus.proxies().profile().fan_curve_data(*p) {
|
||||
curves.insert(*p, curve);
|
||||
@@ -118,7 +118,7 @@ impl FanCurvesState {
|
||||
curve.gpu.temp = [20, 30, 40, 50, 70, 80, 90, 100];
|
||||
curves.insert(*p, curve);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
let show_curve = if supported.platform_profile.fan_curves {
|
||||
dbus.proxies().profile().active_profile()?
|
||||
@@ -136,7 +136,7 @@ impl FanCurvesState {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub struct AuraState {
|
||||
pub current_mode: AuraModeNum,
|
||||
pub modes: BTreeMap<AuraModeNum, AuraEffect>,
|
||||
@@ -149,7 +149,7 @@ pub struct AuraState {
|
||||
}
|
||||
|
||||
impl AuraState {
|
||||
pub fn new(supported: &SupportedFunctions, dbus: &RogDbusClientBlocking) -> Result<Self> {
|
||||
pub fn new(supported: &SupportedFunctions, dbus: &RogDbusClientBlocking<'_>) -> Result<Self> {
|
||||
Ok(Self {
|
||||
current_mode: if !supported.keyboard_led.stock_led_modes.is_empty() {
|
||||
dbus.proxies().led().led_mode().unwrap_or_default()
|
||||
@@ -189,7 +189,7 @@ impl AuraState {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub struct AnimeState {
|
||||
pub bright: u8,
|
||||
pub boot: bool,
|
||||
@@ -198,7 +198,7 @@ pub struct AnimeState {
|
||||
}
|
||||
|
||||
impl AnimeState {
|
||||
pub fn new(supported: &SupportedFunctions, dbus: &RogDbusClientBlocking) -> Result<Self> {
|
||||
pub fn new(supported: &SupportedFunctions, dbus: &RogDbusClientBlocking<'_>) -> Result<Self> {
|
||||
Ok(Self {
|
||||
boot: if supported.anime_ctrl.0 {
|
||||
dbus.proxies().anime().boot_enabled()?
|
||||
@@ -219,27 +219,39 @@ impl AnimeState {
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct GfxState {
|
||||
pub has_supergfx: bool,
|
||||
pub mode: GfxMode,
|
||||
pub power_status: GfxPower,
|
||||
}
|
||||
|
||||
impl GfxState {
|
||||
pub fn new(_supported: &SupportedFunctions, dbus: &GfxProxyBlocking) -> Result<Self> {
|
||||
pub fn new(_supported: &SupportedFunctions, dbus: &GfxProxyBlocking<'_>) -> Result<Self> {
|
||||
Ok(Self {
|
||||
mode: dbus.mode()?,
|
||||
power_status: dbus.power()?,
|
||||
has_supergfx: dbus.mode().is_ok(),
|
||||
mode: dbus.mode().unwrap_or(GfxMode::None),
|
||||
power_status: dbus.power().unwrap_or(GfxPower::Unknown),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
impl Default for GfxState {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
has_supergfx: false,
|
||||
mode: GfxMode::None,
|
||||
power_status: GfxPower::Unknown,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub struct PowerState {
|
||||
pub charge_limit: u8,
|
||||
pub ac_power: bool,
|
||||
}
|
||||
|
||||
impl PowerState {
|
||||
pub fn new(_supported: &SupportedFunctions, dbus: &RogDbusClientBlocking) -> Result<Self> {
|
||||
pub fn new(_supported: &SupportedFunctions, dbus: &RogDbusClientBlocking<'_>) -> Result<Self> {
|
||||
Ok(Self {
|
||||
charge_limit: dbus.proxies().charge().charge_control_end_threshold()?,
|
||||
ac_power: dbus.proxies().charge().mains_online()?,
|
||||
@@ -277,19 +289,62 @@ impl SystemState {
|
||||
enabled_notifications: Arc<Mutex<EnabledNotifications>>,
|
||||
supported: &SupportedFunctions,
|
||||
) -> Result<Self> {
|
||||
let (asus_dbus, conn) = RogDbusClientBlocking::new().unwrap();
|
||||
let gfx_dbus = GfxProxyBlocking::new(&conn).unwrap();
|
||||
let (asus_dbus, conn) = RogDbusClientBlocking::new()?;
|
||||
let mut error = None;
|
||||
let gfx_dbus = GfxProxyBlocking::new(&conn).expect("Couldn't connect to supergfxd");
|
||||
Ok(Self {
|
||||
keyboard_layout,
|
||||
enabled_notifications,
|
||||
power_state: PowerState::new(supported, &asus_dbus)?,
|
||||
bios: BiosState::new(supported, &asus_dbus)?,
|
||||
aura: AuraState::new(supported, &asus_dbus)?,
|
||||
anime: AnimeState::new(supported, &asus_dbus)?,
|
||||
profiles: ProfilesState::new(supported, &asus_dbus)?,
|
||||
fan_curves: FanCurvesState::new(supported, &asus_dbus)?,
|
||||
gfx_state: GfxState::new(supported, &gfx_dbus)?,
|
||||
error: None,
|
||||
power_state: PowerState::new(supported, &asus_dbus)
|
||||
.map_err(|e| {
|
||||
let e = format!("Could not get PowerState state: {e}");
|
||||
error!("{e}");
|
||||
error = Some(e);
|
||||
})
|
||||
.unwrap_or_default(),
|
||||
bios: BiosState::new(supported, &asus_dbus)
|
||||
.map_err(|e| {
|
||||
let e = format!("Could not get BiosState state: {e}");
|
||||
error!("{e}");
|
||||
error = Some(e);
|
||||
})
|
||||
.unwrap_or_default(),
|
||||
aura: AuraState::new(supported, &asus_dbus)
|
||||
.map_err(|e| {
|
||||
let e = format!("Could not get AuraState state: {e}");
|
||||
error!("{e}");
|
||||
error = Some(e);
|
||||
})
|
||||
.unwrap_or_default(),
|
||||
anime: AnimeState::new(supported, &asus_dbus)
|
||||
.map_err(|e| {
|
||||
let e = format!("Could not get AanimeState state: {e}");
|
||||
error!("{e}");
|
||||
error = Some(e);
|
||||
})
|
||||
.unwrap_or_default(),
|
||||
profiles: ProfilesState::new(supported, &asus_dbus)
|
||||
.map_err(|e| {
|
||||
let e = format!("Could not get ProfilesState state: {e}");
|
||||
error!("{e}");
|
||||
error = Some(e);
|
||||
})
|
||||
.unwrap_or_default(),
|
||||
fan_curves: FanCurvesState::new(supported, &asus_dbus)
|
||||
.map_err(|e| {
|
||||
let e = format!("Could not get FanCurvesState state: {e}");
|
||||
error!("{e}");
|
||||
error = Some(e);
|
||||
})
|
||||
.unwrap_or_default(),
|
||||
gfx_state: GfxState::new(supported, &gfx_dbus)
|
||||
.map_err(|e| {
|
||||
let e = format!("Could not get supergfxd state: {e}");
|
||||
error!("{e}");
|
||||
error = Some(e);
|
||||
})
|
||||
.unwrap_or_default(),
|
||||
error,
|
||||
tray_should_update: true,
|
||||
app_should_update: true,
|
||||
asus_dbus,
|
||||
@@ -305,8 +360,8 @@ impl SystemState {
|
||||
|
||||
impl Default for SystemState {
|
||||
fn default() -> Self {
|
||||
let (asus_dbus, conn) = RogDbusClientBlocking::new().unwrap();
|
||||
let gfx_dbus = GfxProxyBlocking::new(&conn).unwrap();
|
||||
let (asus_dbus, conn) = RogDbusClientBlocking::new().expect("Couldn't connect to asusd");
|
||||
let gfx_dbus = GfxProxyBlocking::new(&conn).expect("Couldn't connect to supergfxd");
|
||||
|
||||
Self {
|
||||
keyboard_layout: KeyLayout::ga401_layout(),
|
||||
@@ -349,6 +404,7 @@ impl Default for SystemState {
|
||||
drag_delta: Default::default(),
|
||||
},
|
||||
gfx_state: GfxState {
|
||||
has_supergfx: false,
|
||||
mode: GfxMode::None,
|
||||
power_status: GfxPower::Unknown,
|
||||
},
|
||||
|
||||
@@ -128,13 +128,18 @@ impl ROGTray {
|
||||
self.menu.show_all();
|
||||
}
|
||||
|
||||
fn add_radio_sub_menu(&mut self, header_label: &str, active_label: &str, sub_menu: RadioGroup) {
|
||||
fn add_radio_sub_menu(
|
||||
&mut self,
|
||||
header_label: &str,
|
||||
active_label: &str,
|
||||
sub_menu: &RadioGroup,
|
||||
) {
|
||||
let header_item = gtk::MenuItem::with_label(header_label);
|
||||
header_item.show_all();
|
||||
self.menu.add(&header_item);
|
||||
|
||||
let menu = gtk::Menu::new();
|
||||
for item in sub_menu.0.iter() {
|
||||
for item in &sub_menu.0 {
|
||||
if let Some(label) = item.label() {
|
||||
item.set_active(label == active_label);
|
||||
} else {
|
||||
@@ -197,7 +202,7 @@ impl ROGTray {
|
||||
}
|
||||
|
||||
fn _set_status(&mut self, status: AppIndicatorStatus) {
|
||||
self.tray.set_status(status)
|
||||
self.tray.set_status(status);
|
||||
}
|
||||
|
||||
fn menu_add_base(&mut self) {
|
||||
@@ -319,13 +324,13 @@ impl ROGTray {
|
||||
}
|
||||
|
||||
let active = match current_mode {
|
||||
GfxMode::AsusMuxDiscreet => "Discreet".to_string(),
|
||||
GfxMode::AsusMuxDiscreet => "Discreet".to_owned(),
|
||||
_ => current_mode.to_string(),
|
||||
};
|
||||
self.add_radio_sub_menu(
|
||||
&format!("GPU Mode: {current_mode}"),
|
||||
active.as_str(),
|
||||
gpu_menu,
|
||||
&gpu_menu,
|
||||
);
|
||||
|
||||
debug!("ROGTray: appended gpu menu");
|
||||
@@ -346,6 +351,7 @@ impl ROGTray {
|
||||
fn rebuild_and_update(
|
||||
&mut self,
|
||||
supported: &SupportedFunctions,
|
||||
has_supergfx: bool,
|
||||
current_gfx_mode: GfxMode,
|
||||
charge_limit: u8,
|
||||
panel_od: bool,
|
||||
@@ -354,7 +360,9 @@ impl ROGTray {
|
||||
self.menu_add_base();
|
||||
self.menu_add_charge_limit(supported, charge_limit);
|
||||
self.menu_add_panel_od(supported, panel_od);
|
||||
self.menu_add_gpu(supported, current_gfx_mode);
|
||||
if has_supergfx {
|
||||
self.menu_add_gpu(supported, current_gfx_mode);
|
||||
}
|
||||
self.menu_update();
|
||||
}
|
||||
}
|
||||
@@ -366,6 +374,12 @@ pub fn init_tray(
|
||||
let (send, recv) = channel();
|
||||
let _send = Arc::new(Mutex::new(send));
|
||||
|
||||
let has_supergfx = if let Ok(lock) = states.try_lock() {
|
||||
lock.gfx_state.has_supergfx
|
||||
} else {
|
||||
false
|
||||
};
|
||||
|
||||
std::thread::spawn(move || {
|
||||
if gtk::init()
|
||||
.map_err(|e| {
|
||||
@@ -391,7 +405,7 @@ pub fn init_tray(
|
||||
return;
|
||||
}
|
||||
};
|
||||
tray.rebuild_and_update(&supported, GfxMode::Hybrid, 100, false);
|
||||
tray.rebuild_and_update(&supported, has_supergfx, GfxMode::Hybrid, 100, false);
|
||||
tray.set_icon(TRAY_APP_ICON);
|
||||
info!("Started ROGTray");
|
||||
|
||||
@@ -400,6 +414,7 @@ pub fn init_tray(
|
||||
if lock.tray_should_update {
|
||||
tray.rebuild_and_update(
|
||||
&supported,
|
||||
has_supergfx,
|
||||
lock.gfx_state.mode,
|
||||
lock.power_state.charge_limit,
|
||||
lock.bios.panel_overdrive,
|
||||
@@ -408,12 +423,19 @@ pub fn init_tray(
|
||||
debug!("ROGTray: rebuilt menus due to state change");
|
||||
|
||||
match lock.gfx_state.power_status {
|
||||
GfxPower::Active => tray.set_icon("asus_notif_red"),
|
||||
GfxPower::Suspended => tray.set_icon("asus_notif_blue"),
|
||||
GfxPower::Off => tray.set_icon("asus_notif_green"),
|
||||
GfxPower::AsusDisabled => tray.set_icon("asus_notif_white"),
|
||||
GfxPower::AsusMuxDiscreet => tray.set_icon("asus_notif_red"),
|
||||
GfxPower::Unknown => tray.set_icon("gpu-integrated"),
|
||||
GfxPower::AsusMuxDiscreet | GfxPower::Active => {
|
||||
tray.set_icon("asus_notif_red");
|
||||
}
|
||||
GfxPower::Unknown => {
|
||||
if has_supergfx {
|
||||
tray.set_icon("gpu-integrated");
|
||||
} else {
|
||||
tray.set_icon("asus_notif_red");
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
//! `update_and_notify` is responsible for both notifications *and* updating stored statuses
|
||||
//! about the system state. This is done through either direct, intoify, zbus notifications
|
||||
//! or similar methods.
|
||||
|
||||
use crate::{config::Config, error::Result, system_state::SystemState};
|
||||
use log::{error, info, trace};
|
||||
use log::{error, info, trace, warn};
|
||||
use notify_rust::{Hint, Notification, NotificationHandle, Urgency};
|
||||
use rog_dbus::{
|
||||
zbus_anime::AnimeProxy, zbus_led::LedProxy, zbus_platform::RogBiosProxy,
|
||||
@@ -12,8 +16,10 @@ use std::{
|
||||
fmt::Display,
|
||||
process::Command,
|
||||
sync::{Arc, Mutex},
|
||||
time::Duration,
|
||||
};
|
||||
use supergfxctl::{pci_device::GfxPower, zbus_proxy::DaemonProxy as SuperProxy};
|
||||
use tokio::time::sleep;
|
||||
use zbus::export::futures_util::{future, StreamExt};
|
||||
|
||||
const NOTIF_HEADER: &str = "ROG Control";
|
||||
@@ -271,103 +277,101 @@ pub fn start_notifications(
|
||||
};
|
||||
});
|
||||
|
||||
recv_notif!(
|
||||
SuperProxy,
|
||||
receive_notify_gfx,
|
||||
last_notification,
|
||||
enabled_notifications,
|
||||
page_states,
|
||||
(gfx_state.mode),
|
||||
(mode),
|
||||
"Gfx mode changed to",
|
||||
do_notification
|
||||
);
|
||||
|
||||
// recv_notif!(
|
||||
// SuperProxy,
|
||||
// receive_notify_action,
|
||||
// bios_notified,
|
||||
// last_gfx_action_notif,
|
||||
// enabled_notifications,
|
||||
// [action],
|
||||
// "Gfx mode change requires",
|
||||
// do_gfx_action_notif
|
||||
// );
|
||||
|
||||
tokio::spawn(async move {
|
||||
let conn = zbus::Connection::system()
|
||||
.await
|
||||
.map_err(|e| {
|
||||
error!("zbus signal: receive_notify_action: {e}");
|
||||
e
|
||||
})
|
||||
.unwrap();
|
||||
let proxy = SuperProxy::new(&conn)
|
||||
.await
|
||||
.map_err(|e| {
|
||||
error!("zbus signal: receive_notify_action: {e}");
|
||||
e
|
||||
})
|
||||
.unwrap();
|
||||
if let Ok(mut p) = proxy.receive_notify_action().await {
|
||||
info!("Started zbus signal thread: receive_notify_action");
|
||||
while let Some(e) = p.next().await {
|
||||
if let Ok(out) = e.args() {
|
||||
let action = out.action();
|
||||
do_gfx_action_notif("Gfx mode change requires", &format!("{action:?}",))
|
||||
.map_err(|e| {
|
||||
error!("zbus signal: do_gfx_action_notif: {e}");
|
||||
e
|
||||
})
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
let notifs_enabled1 = enabled_notifications;
|
||||
let last_notif = last_notification;
|
||||
tokio::spawn(async move {
|
||||
let conn = zbus::Connection::system()
|
||||
.await
|
||||
.map_err(|e| {
|
||||
error!("zbus signal: receive_notify_gfx_status: {e}");
|
||||
e
|
||||
})
|
||||
.unwrap();
|
||||
let proxy = SuperProxy::new(&conn)
|
||||
.await
|
||||
.map_err(|e| {
|
||||
error!("zbus signal: receive_notify_gfx_status: {e}");
|
||||
e
|
||||
})
|
||||
.unwrap();
|
||||
if let Ok(mut p) = proxy.receive_notify_gfx_status().await {
|
||||
info!("Started zbus signal thread: receive_notify_gfx_status");
|
||||
while let Some(e) = p.next().await {
|
||||
if let Ok(out) = e.args() {
|
||||
let status = out.status;
|
||||
if status != GfxPower::Unknown {
|
||||
if let Ok(config) = notifs_enabled1.lock() {
|
||||
if config.all_enabled && config.receive_notify_gfx_status {
|
||||
// Required check because status cycles through active/unknown/suspended
|
||||
if let Ok(ref mut lock) = last_notif.lock() {
|
||||
notify!(
|
||||
do_gpu_status_notif("dGPU status changed:", &status),
|
||||
lock
|
||||
);
|
||||
if let Ok(lock) = page_states.try_lock() {
|
||||
use supergfxctl::pci_device::Device;
|
||||
let dev = Device::find().unwrap_or_default();
|
||||
let mut found_dgpu = false; // just for logging
|
||||
for dev in dev {
|
||||
if dev.is_dgpu() {
|
||||
let notifs_enabled1 = enabled_notifications.clone();
|
||||
let last_notif = last_notification.clone();
|
||||
let page_states1 = page_states.clone();
|
||||
// Plain old thread is perfectly fine since most of this is potentially blocking
|
||||
tokio::spawn(async move {
|
||||
let mut last_status = GfxPower::Unknown;
|
||||
loop {
|
||||
if let Ok(status) = dev.get_runtime_status() {
|
||||
if status != GfxPower::Unknown && status != last_status {
|
||||
if let Ok(config) = notifs_enabled1.lock() {
|
||||
if config.all_enabled && config.receive_notify_gfx_status {
|
||||
// Required check because status cycles through active/unknown/suspended
|
||||
if let Ok(ref mut lock) = last_notif.lock() {
|
||||
notify!(
|
||||
do_gpu_status_notif(
|
||||
"dGPU status changed:",
|
||||
&status
|
||||
),
|
||||
lock
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Ok(mut lock) = page_states1.lock() {
|
||||
lock.gfx_state.power_status = status;
|
||||
lock.set_notified();
|
||||
}
|
||||
last_status = status;
|
||||
}
|
||||
}
|
||||
if let Ok(mut lock) = page_states.lock() {
|
||||
lock.gfx_state.power_status = status;
|
||||
lock.set_notified();
|
||||
sleep(Duration::from_millis(500)).await;
|
||||
}
|
||||
});
|
||||
found_dgpu = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if !found_dgpu {
|
||||
warn!("Did not find a dGPU on this system, dGPU status won't be avilable");
|
||||
}
|
||||
|
||||
if lock.gfx_state.has_supergfx {
|
||||
recv_notif!(
|
||||
SuperProxy,
|
||||
receive_notify_gfx,
|
||||
last_notification,
|
||||
enabled_notifications,
|
||||
page_states,
|
||||
(gfx_state.mode),
|
||||
(mode),
|
||||
"Gfx mode changed to",
|
||||
do_notification
|
||||
);
|
||||
|
||||
tokio::spawn(async move {
|
||||
let conn = zbus::Connection::system()
|
||||
.await
|
||||
.map_err(|e| {
|
||||
error!("zbus signal: receive_notify_action: {e}");
|
||||
e
|
||||
})
|
||||
.unwrap();
|
||||
let proxy = SuperProxy::new(&conn)
|
||||
.await
|
||||
.map_err(|e| {
|
||||
error!("zbus signal: receive_notify_action: {e}");
|
||||
e
|
||||
})
|
||||
.unwrap();
|
||||
if let Ok(mut p) = proxy.receive_notify_action().await {
|
||||
info!("Started zbus signal thread: receive_notify_action");
|
||||
while let Some(e) = p.next().await {
|
||||
if let Ok(out) = e.args() {
|
||||
let action = out.action();
|
||||
do_gfx_action_notif(
|
||||
"Gfx mode change requires",
|
||||
&format!("{action:?}",),
|
||||
)
|
||||
.map_err(|e| {
|
||||
error!("zbus signal: do_gfx_action_notif: {e}");
|
||||
e
|
||||
})
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -397,9 +401,9 @@ where
|
||||
|
||||
fn ac_power_notification(message: &str, on: &bool) -> Result<NotificationHandle> {
|
||||
let data = if *on {
|
||||
"plugged".to_string()
|
||||
"plugged".to_owned()
|
||||
} else {
|
||||
"unplugged".to_string()
|
||||
"unplugged".to_owned()
|
||||
};
|
||||
Ok(base_notification(message, &data).show()?)
|
||||
}
|
||||
@@ -417,13 +421,12 @@ fn do_thermal_notif(message: &str, profile: &Profile) -> Result<NotificationHand
|
||||
|
||||
fn do_gpu_status_notif(message: &str, data: &GfxPower) -> Result<NotificationHandle> {
|
||||
// eww
|
||||
let mut notif = base_notification(message, &<&str>::from(data).to_string());
|
||||
let mut notif = base_notification(message, &<&str>::from(data).to_owned());
|
||||
let icon = match data {
|
||||
GfxPower::Active => "asus_notif_red",
|
||||
GfxPower::Suspended => "asus_notif_blue",
|
||||
GfxPower::Off => "asus_notif_green",
|
||||
GfxPower::AsusDisabled => "asus_notif_white",
|
||||
GfxPower::AsusMuxDiscreet => "asus_notif_red",
|
||||
GfxPower::AsusMuxDiscreet | GfxPower::Active => "asus_notif_red",
|
||||
GfxPower::Unknown => "gpu-integrated",
|
||||
};
|
||||
notif.icon(icon);
|
||||
@@ -452,7 +455,7 @@ where
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Actual GpuMode unused as data is never correct until switched by reboot
|
||||
/// Actual `GpuMode` unused as data is never correct until switched by reboot
|
||||
fn do_mux_notification(message: &str, _: &GpuMode) -> Result<NotificationHandle> {
|
||||
let mut notif = base_notification(message, &"");
|
||||
notif.urgency(Urgency::Critical);
|
||||
@@ -12,7 +12,7 @@ pub fn aura_power_group(supported: &SupportedFunctions, states: &mut SystemState
|
||||
|
||||
match supported.keyboard_led.prod_id {
|
||||
AuraDevice::X1854 | AuraDevice::X1869 | AuraDevice::X1866 => {
|
||||
aura_power1(supported, states, ui)
|
||||
aura_power1(supported, states, ui);
|
||||
}
|
||||
AuraDevice::X19B6 => aura_power2(supported, states, ui),
|
||||
AuraDevice::Tuf => aura_power1(supported, states, ui),
|
||||
|
||||
@@ -2,16 +2,12 @@ use egui::{plot::Points, Ui};
|
||||
use rog_platform::supported::SupportedFunctions;
|
||||
use rog_profiles::{FanCurvePU, Profile};
|
||||
|
||||
use crate::{
|
||||
system_state::{FanCurvesState, ProfilesState},
|
||||
RogDbusClientBlocking,
|
||||
};
|
||||
use crate::{system_state::FanCurvesState, RogDbusClientBlocking};
|
||||
|
||||
pub fn fan_graphs(
|
||||
supported: &SupportedFunctions,
|
||||
profiles: &mut ProfilesState,
|
||||
curves: &mut FanCurvesState,
|
||||
dbus: &RogDbusClientBlocking,
|
||||
dbus: &RogDbusClientBlocking<'_>,
|
||||
do_error: &mut Option<String>,
|
||||
ui: &mut Ui,
|
||||
) {
|
||||
@@ -36,14 +32,14 @@ pub fn fan_graphs(
|
||||
};
|
||||
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
for a in curves.curves.iter() {
|
||||
for a in &curves.curves {
|
||||
item(*a.0, ui);
|
||||
}
|
||||
});
|
||||
|
||||
let curve = curves.curves.get_mut(&curves.show_curve).unwrap();
|
||||
|
||||
use egui::plot::{Line, Plot, PlotPoints};
|
||||
use egui::plot::{Line, Plot};
|
||||
|
||||
let data = if curves.show_graph == FanCurvePU::CPU {
|
||||
&mut curve.cpu
|
||||
@@ -51,14 +47,40 @@ pub fn fan_graphs(
|
||||
&mut curve.gpu
|
||||
};
|
||||
|
||||
let points = data.temp.iter().enumerate().map(|(idx, x)| {
|
||||
let x = *x as f64;
|
||||
let y = ((data.pwm[idx] as u32) * 100 / 255) as f64;
|
||||
[x, y]
|
||||
});
|
||||
let mut points: Vec<[f64; 2]> = data
|
||||
.temp
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(idx, x)| {
|
||||
let x = *x as f64;
|
||||
let y = ((data.pwm[idx] as u32) * 100 / 255) as f64;
|
||||
[x, y]
|
||||
})
|
||||
.collect();
|
||||
|
||||
let line = Line::new(PlotPoints::from_iter(points.clone())).width(2.0);
|
||||
let points = Points::new(PlotPoints::from_iter(points)).radius(3.0);
|
||||
for i in 0..points.len() - 1 {
|
||||
if i > 0 && i < points.len() - 1 {
|
||||
if points[i][0] < points[i - 1][0] {
|
||||
points[i][0] = points[i - 1][0] + 1.0;
|
||||
data.temp[i] = points[i - 1][0] as u8;
|
||||
}
|
||||
if points[i][0] >= points[i + 1][0] {
|
||||
points[i + 1][0] = points[i][0] + 1.0;
|
||||
data.temp[i + 1] = points[i][0] as u8;
|
||||
}
|
||||
if points[i][1] < points[i - 1][1] {
|
||||
points[i][1] = points[i - 1][1] + 1.0;
|
||||
data.pwm[i] = (points[i - 1][1] * 255.0 / 100.0 + 1.0).floor() as u8;
|
||||
}
|
||||
if points[i][1] >= points[i + 1][1] {
|
||||
points[i + 1][1] = points[i][1] + 1.0;
|
||||
data.pwm[i + 1] = (points[i][1] * 255.0 / 100.0 + 1.0).floor() as u8;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let line = Line::new(points.clone()).width(2.0);
|
||||
let points = Points::new(points).radius(3.0);
|
||||
|
||||
Plot::new("fan_curves")
|
||||
.view_aspect(1.666)
|
||||
@@ -85,7 +107,7 @@ pub fn fan_graphs(
|
||||
let mut idx = 0;
|
||||
|
||||
if let Some(point) = plot_ui.pointer_coordinate() {
|
||||
let mut x: i32 = 255;
|
||||
let mut x: i32 = point.x as i32;
|
||||
for (i, n) in data.temp.iter().enumerate() {
|
||||
let tmp = x.min((point.x as i32 - *n as i32).abs());
|
||||
if tmp < x {
|
||||
@@ -107,30 +129,47 @@ pub fn fan_graphs(
|
||||
}
|
||||
}
|
||||
plot_ui.line(line);
|
||||
plot_ui.points(points)
|
||||
plot_ui.points(points);
|
||||
});
|
||||
|
||||
let mut set = false;
|
||||
let mut clear = false;
|
||||
let mut reset = false;
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::TOP), |ui| {
|
||||
set = ui.add(egui::Button::new("Apply Fan-curve")).clicked();
|
||||
reset = ui.add(egui::Button::new("Reset Profile")).clicked();
|
||||
set = ui.add(egui::Button::new("Apply Profile")).clicked();
|
||||
clear = ui.add(egui::Button::new("Clear Profile Changes")).clicked();
|
||||
reset = ui.add(egui::Button::new("Factory Reset Profile")).clicked();
|
||||
});
|
||||
|
||||
if set {
|
||||
dbus.proxies()
|
||||
.profile()
|
||||
.set_fan_curve(profiles.current, data.clone())
|
||||
.set_fan_curve(curves.show_curve, data.clone())
|
||||
.map_err(|err| {
|
||||
*do_error = Some(err.to_string());
|
||||
})
|
||||
.ok();
|
||||
}
|
||||
|
||||
if clear {
|
||||
if let Ok(curve) = dbus
|
||||
.proxies()
|
||||
.profile()
|
||||
.fan_curve_data(curves.show_curve)
|
||||
.map_err(|err| {
|
||||
*do_error = Some(err.to_string());
|
||||
})
|
||||
{
|
||||
if let Some(value) = curves.curves.get_mut(&curves.show_curve) {
|
||||
*value = curve;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if reset {
|
||||
dbus.proxies()
|
||||
.profile()
|
||||
.reset_profile_curves(profiles.current)
|
||||
.reset_profile_curves(curves.show_curve)
|
||||
.map_err(|err| {
|
||||
*do_error = Some(err.to_string());
|
||||
})
|
||||
|
||||
@@ -17,7 +17,7 @@ pub fn platform_profile(states: &mut SystemState, ui: &mut Ui) {
|
||||
};
|
||||
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
for a in states.profiles.list.iter() {
|
||||
for a in &states.profiles.list {
|
||||
item(*a, ui);
|
||||
}
|
||||
});
|
||||
@@ -46,7 +46,7 @@ pub fn rog_bios_group(supported: &SupportedFunctions, states: &mut SystemState,
|
||||
.asus_dbus
|
||||
.proxies()
|
||||
.charge()
|
||||
.set_charge_control_end_threshold(states.power_state.charge_limit as u8)
|
||||
.set_charge_control_end_threshold(states.power_state.charge_limit)
|
||||
.map_err(|err| {
|
||||
states.error = Some(err.to_string());
|
||||
})
|
||||
|
||||
@@ -15,5 +15,3 @@ rog_aura = { path = "../rog-aura" }
|
||||
rog_profiles = { path = "../rog-profiles" }
|
||||
rog_platform = { path = "../rog-platform" }
|
||||
zbus.workspace = true
|
||||
zbus_macros.workspace = true
|
||||
zvariant.workspace = true
|
||||
|
||||
+2
-2
@@ -81,7 +81,7 @@ impl<'a> RogDbusClientBlocking<'a> {
|
||||
Ok((RogDbusClientBlocking { proxies }, conn))
|
||||
}
|
||||
|
||||
pub fn proxies(&self) -> &DbusProxiesBlocking {
|
||||
pub fn proxies(&self) -> &DbusProxiesBlocking<'_> {
|
||||
&self.proxies
|
||||
}
|
||||
}
|
||||
@@ -150,7 +150,7 @@ impl<'a> RogDbusClient<'a> {
|
||||
Ok((RogDbusClient { proxies }, conn))
|
||||
}
|
||||
|
||||
pub fn proxies(&self) -> &DbusProxies {
|
||||
pub fn proxies(&self) -> &DbusProxies<'_> {
|
||||
&self.proxies
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use rog_anime::{AnimeDataBuffer, AnimePowerStates};
|
||||
use zbus_macros::dbus_proxy;
|
||||
use zbus::dbus_proxy;
|
||||
|
||||
#[dbus_proxy(
|
||||
interface = "org.asuslinux.Daemon",
|
||||
@@ -7,33 +7,26 @@ use zbus_macros::dbus_proxy;
|
||||
)]
|
||||
trait Anime {
|
||||
/// Set whether the AniMe will show boot, suspend, or off animations
|
||||
#[inline]
|
||||
fn set_boot_on_off(&self, status: bool) -> zbus::Result<()>;
|
||||
|
||||
/// Set the global AniMe brightness
|
||||
#[inline]
|
||||
fn set_brightness(&self, bright: f32) -> zbus::Result<()>;
|
||||
|
||||
/// Set whether the AniMe is displaying images/data
|
||||
#[inline]
|
||||
fn set_on_off(&self, status: bool) -> zbus::Result<()>;
|
||||
|
||||
/// Writes a data stream of length. Will force system thread to exit until it is restarted
|
||||
#[inline]
|
||||
fn write(&self, input: AnimeDataBuffer) -> zbus::Result<()>;
|
||||
|
||||
/// Get status of if the AniMe LEDs are on
|
||||
#[inline]
|
||||
#[dbus_proxy(property)]
|
||||
fn awake_enabled(&self) -> zbus::Result<bool>;
|
||||
|
||||
/// Get the status of if factory system-status animations are enabled
|
||||
#[inline]
|
||||
#[dbus_proxy(property)]
|
||||
fn boot_enabled(&self) -> zbus::Result<bool>;
|
||||
|
||||
/// Notify listeners of the status of AniMe LED power and factory system-status animations
|
||||
#[inline]
|
||||
#[dbus_proxy(signal)]
|
||||
fn power_states(&self, data: AnimePowerStates) -> zbus::Result<()>;
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use zbus::dbus_proxy;
|
||||
use zbus::{blocking::Connection, Result};
|
||||
use zbus_macros::dbus_proxy;
|
||||
|
||||
use rog_aura::{usb::AuraPowerDev, AuraEffect, AuraModeNum, LedBrightness, PerKeyRaw};
|
||||
|
||||
@@ -34,60 +34,46 @@ const BLOCKING_TIME: u64 = 40; // 100ms = 10 FPS, max 50ms = 20 FPS, 40ms = 25 F
|
||||
)]
|
||||
trait Led {
|
||||
/// NextLedMode method
|
||||
#[inline]
|
||||
fn next_led_mode(&self) -> zbus::Result<()>;
|
||||
|
||||
/// PrevLedMode method
|
||||
#[inline]
|
||||
fn prev_led_mode(&self) -> zbus::Result<()>;
|
||||
|
||||
/// Toggle to next led brightness
|
||||
#[inline]
|
||||
fn next_led_brightness(&self) -> zbus::Result<()>;
|
||||
|
||||
/// Toggle to previous led brightness
|
||||
#[inline]
|
||||
fn prev_led_brightness(&self) -> zbus::Result<()>;
|
||||
|
||||
/// SetBrightness method
|
||||
#[inline]
|
||||
fn set_brightness(&self, brightness: LedBrightness) -> zbus::Result<()>;
|
||||
|
||||
/// SetLedMode method
|
||||
#[inline]
|
||||
fn set_led_mode(&self, effect: &AuraEffect) -> zbus::Result<()>;
|
||||
|
||||
#[inline]
|
||||
fn set_leds_power(&self, options: AuraPowerDev, enabled: bool) -> zbus::Result<()>;
|
||||
|
||||
#[inline]
|
||||
fn per_key_raw(&self, data: PerKeyRaw) -> zbus::fdo::Result<()>;
|
||||
|
||||
/// NotifyLed signal
|
||||
#[inline]
|
||||
#[dbus_proxy(signal)]
|
||||
fn notify_led(&self, data: AuraEffect) -> zbus::Result<()>;
|
||||
|
||||
#[dbus_proxy(signal)]
|
||||
#[inline]
|
||||
fn notify_power_states(&self, data: AuraPowerDev) -> zbus::Result<()>;
|
||||
|
||||
/// LedBrightness property
|
||||
#[inline]
|
||||
#[dbus_proxy(property)]
|
||||
fn led_brightness(&self) -> zbus::Result<i16>;
|
||||
|
||||
/// LedMode property
|
||||
#[inline]
|
||||
fn led_mode(&self) -> zbus::Result<AuraModeNum>;
|
||||
|
||||
/// LedModes property
|
||||
#[inline]
|
||||
fn led_modes(&self) -> zbus::Result<BTreeMap<AuraModeNum, AuraEffect>>;
|
||||
|
||||
// As property doesn't work for AuraPowerDev (complexity of serialization?)
|
||||
// #[dbus_proxy(property)]
|
||||
#[inline]
|
||||
fn leds_enabled(&self) -> zbus::Result<AuraPowerDev>;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
//! …consequently `zbus-xmlgen` did not generate code for the above interfaces.
|
||||
|
||||
use rog_platform::platform::GpuMode;
|
||||
use zbus_macros::dbus_proxy;
|
||||
use zbus::dbus_proxy;
|
||||
|
||||
#[dbus_proxy(
|
||||
interface = "org.asuslinux.Daemon",
|
||||
@@ -28,62 +28,48 @@ use zbus_macros::dbus_proxy;
|
||||
)]
|
||||
trait RogBios {
|
||||
/// DgpuDisable method
|
||||
#[inline]
|
||||
fn dgpu_disable(&self) -> zbus::Result<bool>;
|
||||
|
||||
/// EgpuEnable method
|
||||
#[inline]
|
||||
fn egpu_enable(&self) -> zbus::Result<bool>;
|
||||
|
||||
/// GpuMuxMode method
|
||||
#[inline]
|
||||
fn gpu_mux_mode(&self) -> zbus::Result<GpuMode>;
|
||||
|
||||
/// PanelOd method
|
||||
#[inline]
|
||||
fn panel_od(&self) -> zbus::Result<bool>;
|
||||
|
||||
/// PostBootSound method
|
||||
#[inline]
|
||||
fn post_boot_sound(&self) -> zbus::Result<i16>;
|
||||
|
||||
/// SetDgpuDisable method
|
||||
#[inline]
|
||||
fn set_dgpu_disable(&self, disable: bool) -> zbus::Result<()>;
|
||||
|
||||
/// SetEgpuEnable method
|
||||
#[inline]
|
||||
fn set_egpu_enable(&self, enable: bool) -> zbus::Result<()>;
|
||||
|
||||
/// SetGpuMuxMode method
|
||||
#[inline]
|
||||
fn set_gpu_mux_mode(&self, mode: GpuMode) -> zbus::Result<()>;
|
||||
|
||||
/// SetPanelOd method
|
||||
#[inline]
|
||||
fn set_panel_od(&self, overdrive: bool) -> zbus::Result<()>;
|
||||
|
||||
/// SetPostBootSound method
|
||||
#[inline]
|
||||
fn set_post_boot_sound(&self, on: bool) -> zbus::Result<()>;
|
||||
|
||||
/// NotifyDgpuDisable signal
|
||||
#[inline]
|
||||
#[dbus_proxy(signal)]
|
||||
fn notify_dgpu_disable(&self, disable: bool) -> zbus::Result<()>;
|
||||
|
||||
/// NotifyEgpuEnable signal
|
||||
#[inline]
|
||||
#[dbus_proxy(signal)]
|
||||
fn notify_egpu_enable(&self, enable: bool) -> zbus::Result<()>;
|
||||
|
||||
/// NotifyGpuMuxMode signal
|
||||
#[inline]
|
||||
#[dbus_proxy(signal)]
|
||||
fn notify_gpu_mux_mode(&self, mode: GpuMode) -> zbus::Result<()>;
|
||||
|
||||
/// NotifyPanelOd signal
|
||||
#[inline]
|
||||
#[dbus_proxy(signal)]
|
||||
fn notify_panel_od(&self, overdrive: bool) -> zbus::Result<()>;
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
//!
|
||||
//! …consequently `zbus-xmlgen` did not generate code for the above interfaces.
|
||||
|
||||
use zbus_macros::dbus_proxy;
|
||||
use zbus::dbus_proxy;
|
||||
|
||||
#[dbus_proxy(
|
||||
interface = "org.asuslinux.Daemon",
|
||||
@@ -27,24 +27,19 @@ use zbus_macros::dbus_proxy;
|
||||
)]
|
||||
trait Power {
|
||||
/// charge_control_end_threshold method
|
||||
#[inline]
|
||||
fn charge_control_end_threshold(&self) -> zbus::Result<u8>;
|
||||
|
||||
/// MainsOnline method
|
||||
#[inline]
|
||||
fn mains_online(&self) -> zbus::Result<bool>;
|
||||
|
||||
/// set_charge_control_end_threshold method
|
||||
#[inline]
|
||||
fn set_charge_control_end_threshold(&self, limit: u8) -> zbus::Result<()>;
|
||||
|
||||
/// NotifyCharge signal
|
||||
#[inline]
|
||||
#[dbus_proxy(signal)]
|
||||
fn notify_charge_control_end_threshold(&self, limit: u8) -> zbus::Result<u8>;
|
||||
|
||||
/// NotifyMainsOnline signal
|
||||
#[inline]
|
||||
#[dbus_proxy(signal)]
|
||||
fn notify_mains_online(&self, on: bool) -> zbus::Result<()>;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ use rog_profiles::{
|
||||
fan_curve_set::{CurveData, FanCurveSet},
|
||||
Profile,
|
||||
};
|
||||
use zbus_macros::dbus_proxy;
|
||||
use zbus::dbus_proxy;
|
||||
|
||||
#[dbus_proxy(
|
||||
interface = "org.asuslinux.Daemon",
|
||||
@@ -31,55 +31,44 @@ use zbus_macros::dbus_proxy;
|
||||
)]
|
||||
trait Profile {
|
||||
/// Get the fan-curve data for the currently active Profile
|
||||
#[inline]
|
||||
fn fan_curve_data(&self, profile: Profile) -> zbus::Result<FanCurveSet>;
|
||||
|
||||
/// Fetch the active profile name
|
||||
#[inline]
|
||||
fn active_profile(&self) -> zbus::Result<Profile>;
|
||||
|
||||
/// Get a list of profiles that have fan-curves enabled.
|
||||
#[inline]
|
||||
fn enabled_fan_profiles(&self) -> zbus::Result<Vec<Profile>>;
|
||||
|
||||
/// Toggle to next platform_profile. Names provided by `Profiles`.
|
||||
/// If fan-curves are supported will also activate a fan curve for profile.
|
||||
#[inline]
|
||||
fn next_profile(&self) -> zbus::Result<()>;
|
||||
|
||||
/// Fetch profile names
|
||||
#[inline]
|
||||
fn profiles(&self) -> zbus::Result<Vec<Profile>>;
|
||||
|
||||
/// Set this platform_profile name as active
|
||||
#[inline]
|
||||
fn set_active_profile(&self, profile: Profile) -> zbus::Result<()>;
|
||||
|
||||
/// Set a profile fan curve enabled status. Will also activate a fan curve.
|
||||
#[inline]
|
||||
fn set_fan_curve_enabled(&self, profile: Profile, enabled: bool) -> zbus::Result<()>;
|
||||
|
||||
/// Set the fan curve for the specified profile, or the profile the user is
|
||||
/// currently in if profile == None. Will also activate the fan curve.
|
||||
#[inline]
|
||||
fn set_fan_curve(&self, profile: Profile, curve: CurveData) -> zbus::Result<()>;
|
||||
|
||||
/// Reset the stored (self) and device curve to the defaults of the platform.
|
||||
///
|
||||
/// Each platform_profile has a different default and the defualt can be read
|
||||
/// only for the currently active profile.
|
||||
#[inline]
|
||||
fn set_active_curve_to_defaults(&self) -> zbus::Result<()>;
|
||||
|
||||
/// Reset the stored (self) and device curve to the defaults of the platform.
|
||||
///
|
||||
/// Each platform_profile has a different default and the defualt can be read
|
||||
/// only for the currently active profile.
|
||||
#[inline]
|
||||
fn reset_profile_curves(&self, profile: Profile) -> zbus::fdo::Result<()>;
|
||||
|
||||
/// NotifyProfile signal
|
||||
#[inline]
|
||||
#[dbus_proxy(signal)]
|
||||
async fn notify_profile(&self, profile: Profile) -> zbus::Result<Profile>;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
//! …consequently `zbus-xmlgen` did not generate code for the above interfaces.
|
||||
|
||||
use rog_platform::supported::SupportedFunctions;
|
||||
use zbus_macros::dbus_proxy;
|
||||
use zbus::dbus_proxy;
|
||||
|
||||
#[dbus_proxy(
|
||||
interface = "org.asuslinux.Daemon",
|
||||
@@ -28,6 +28,5 @@ use zbus_macros::dbus_proxy;
|
||||
)]
|
||||
trait Supported {
|
||||
/// SupportedFunctions method
|
||||
#[inline]
|
||||
fn supported_functions(&self) -> zbus::Result<SupportedFunctions>;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
[package]
|
||||
name = "rog_platform"
|
||||
license = "MPL-2.0"
|
||||
version.workspace = true
|
||||
edition = "2021"
|
||||
|
||||
@@ -8,11 +9,10 @@ log.workspace = true
|
||||
rog_aura = { path = "../rog-aura" }
|
||||
serde.workspace = true
|
||||
serde_derive.workspace = true
|
||||
zvariant.workspace = true
|
||||
zvariant_derive.workspace = true
|
||||
zbus.workspace = true
|
||||
sysfs-class.workspace = true
|
||||
concat-idents.workspace = true
|
||||
udev.workspace = true
|
||||
inotify.workspace = true
|
||||
|
||||
rusb.workspace = true
|
||||
rusb.workspace = true
|
||||
|
||||
@@ -23,7 +23,7 @@ pub enum PlatformError {
|
||||
|
||||
impl fmt::Display for PlatformError {
|
||||
// This trait requires `fmt` with this exact signature.
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
PlatformError::ParseVendor => write!(f, "Parse gfx vendor error"),
|
||||
PlatformError::ParseNum => write!(f, "Parse number error"),
|
||||
|
||||
@@ -19,7 +19,7 @@ pub const VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||
|
||||
pub(crate) fn to_device(sys_path: &Path) -> Result<Device> {
|
||||
Device::from_syspath(sys_path)
|
||||
.map_err(|e| PlatformError::Udev("Couldn't transform syspath to device".to_string(), e))
|
||||
.map_err(|e| PlatformError::Udev("Couldn't transform syspath to device".to_owned(), e))
|
||||
}
|
||||
|
||||
pub fn has_attr(device: &Device, attr_name: &str) -> bool {
|
||||
@@ -39,7 +39,7 @@ pub fn read_attr_bool(device: &Device, attr_name: &str) -> Result<bool> {
|
||||
}
|
||||
return Ok(true);
|
||||
}
|
||||
Err(PlatformError::AttrNotFound(attr_name.to_string()))
|
||||
Err(PlatformError::AttrNotFound(attr_name.to_owned()))
|
||||
}
|
||||
|
||||
pub fn write_attr_bool(device: &mut Device, attr: &str, value: bool) -> Result<()> {
|
||||
@@ -53,7 +53,7 @@ pub fn read_attr_u8(device: &Device, attr_name: &str) -> Result<u8> {
|
||||
let tmp = value.to_string_lossy();
|
||||
return tmp.parse::<u8>().map_err(|_| PlatformError::ParseNum);
|
||||
}
|
||||
Err(PlatformError::AttrNotFound(attr_name.to_string()))
|
||||
Err(PlatformError::AttrNotFound(attr_name.to_owned()))
|
||||
}
|
||||
|
||||
pub fn write_attr_u8(device: &mut Device, attr: &str, value: u8) -> Result<()> {
|
||||
@@ -71,7 +71,7 @@ pub fn read_attr_u8_array(device: &Device, attr_name: &str) -> Result<Vec<u8>> {
|
||||
.collect();
|
||||
return Ok(tmp);
|
||||
}
|
||||
Err(PlatformError::AttrNotFound(attr_name.to_string()))
|
||||
Err(PlatformError::AttrNotFound(attr_name.to_owned()))
|
||||
}
|
||||
|
||||
pub fn write_attr_u8_array(device: &mut Device, attr: &str, values: &[u8]) -> Result<()> {
|
||||
|
||||
@@ -2,7 +2,7 @@ use std::{fmt::Display, path::PathBuf, str::FromStr};
|
||||
|
||||
use log::{info, warn};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use zvariant::Type;
|
||||
use zbus::zvariant::Type;
|
||||
|
||||
use crate::{
|
||||
attr_bool, attr_u8,
|
||||
@@ -11,12 +11,12 @@ use crate::{
|
||||
};
|
||||
|
||||
/// The "platform" device provides access to things like:
|
||||
/// - dgpu_disable
|
||||
/// - egpu_enable
|
||||
/// - panel_od
|
||||
/// - gpu_mux
|
||||
/// - keyboard_mode, set keyboard RGB mode and speed
|
||||
/// - keyboard_state, set keyboard power states
|
||||
/// - `dgpu_disable`
|
||||
/// - `egpu_enable`
|
||||
/// - `panel_od`
|
||||
/// - `gpu_mux`
|
||||
/// - `keyboard_mode`, set keyboard RGB mode and speed
|
||||
/// - `keyboard_state`, set keyboard power states
|
||||
#[derive(Debug, PartialEq, Eq, PartialOrd, Clone)]
|
||||
pub struct AsusPlatform {
|
||||
path: PathBuf,
|
||||
@@ -65,12 +65,13 @@ impl AsusPlatform {
|
||||
attr_u8!("platform_profile", pp_path);
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Type, Debug, PartialEq, Eq, Clone, Copy)]
|
||||
#[derive(Serialize, Deserialize, Default, Type, Debug, PartialEq, Eq, Clone, Copy)]
|
||||
pub enum GpuMode {
|
||||
Discrete,
|
||||
Optimus,
|
||||
Integrated,
|
||||
Egpu,
|
||||
#[default]
|
||||
Error,
|
||||
NotSupported,
|
||||
}
|
||||
|
||||
@@ -9,12 +9,12 @@ use crate::{
|
||||
};
|
||||
|
||||
/// The "platform" device provides access to things like:
|
||||
/// - dgpu_disable
|
||||
/// - egpu_enable
|
||||
/// - panel_od
|
||||
/// - gpu_mux
|
||||
/// - keyboard_mode, set keyboard RGB mode and speed
|
||||
/// - keyboard_state, set keyboard power states
|
||||
/// - `dgpu_disable`
|
||||
/// - `egpu_enable`
|
||||
/// - `panel_od`
|
||||
/// - `gpu_mux`
|
||||
/// - `keyboard_mode`, set keyboard RGB mode and speed
|
||||
/// - `keyboard_state`, set keyboard power states
|
||||
#[derive(Debug, PartialEq, Eq, PartialOrd, Clone)]
|
||||
pub struct AsusPower {
|
||||
mains: PathBuf,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use rog_aura::{usb::AuraDevice, AuraModeNum, AuraZone};
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use std::fmt;
|
||||
use zvariant_derive::Type;
|
||||
use zbus::zvariant::Type;
|
||||
|
||||
#[derive(Serialize, Deserialize, Type, Debug, Default, Clone)]
|
||||
pub struct SupportedFunctions {
|
||||
|
||||
@@ -11,7 +11,7 @@ impl USBRaw {
|
||||
for device in rusb::devices()?.iter() {
|
||||
let device_desc = device.device_descriptor()?;
|
||||
if device_desc.vendor_id() == 0x0b05 && device_desc.product_id() == id_product {
|
||||
let handle = Self::get_dev_handle(device)?;
|
||||
let handle = Self::get_dev_handle(&device)?;
|
||||
return Ok(Self(handle));
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ impl USBRaw {
|
||||
}
|
||||
|
||||
fn get_dev_handle(
|
||||
device: Device<rusb::GlobalContext>,
|
||||
device: &Device<rusb::GlobalContext>,
|
||||
) -> Result<DeviceHandle<rusb::GlobalContext>> {
|
||||
// We don't expect this ID to ever change
|
||||
let mut device = device.open()?;
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
[package]
|
||||
name = "rog_profiles"
|
||||
license = "MPL-2.0"
|
||||
version.workspace = true
|
||||
authors = ["Luke D. Jones <luke@ljones.dev>"]
|
||||
edition = "2021"
|
||||
|
||||
[features]
|
||||
default = ["dbus"]
|
||||
dbus = ["zvariant", "zvariant_derive"]
|
||||
dbus = ["zbus"]
|
||||
|
||||
[dependencies]
|
||||
udev.workspace = true
|
||||
serde.workspace = true
|
||||
serde_derive.workspace = true
|
||||
|
||||
zvariant = { workspace = true, optional = true }
|
||||
zvariant_derive = { workspace = true, optional = true }
|
||||
zbus = { workspace = true, optional = true }
|
||||
|
||||
@@ -2,7 +2,7 @@ use serde_derive::{Deserialize, Serialize};
|
||||
|
||||
use udev::Device;
|
||||
#[cfg(feature = "dbus")]
|
||||
use zvariant_derive::Type;
|
||||
use zbus::zvariant::Type;
|
||||
|
||||
use crate::{error::ProfileError, FanCurvePU};
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ use serde_derive::{Deserialize, Serialize};
|
||||
|
||||
use udev::Device;
|
||||
#[cfg(feature = "dbus")]
|
||||
use zvariant_derive::Type;
|
||||
use zbus::zvariant::Type;
|
||||
|
||||
pub const PLATFORM_PROFILE: &str = "/sys/firmware/acpi/platform_profile";
|
||||
pub const PLATFORM_PROFILES: &str = "/sys/firmware/acpi/platform_profile_choices";
|
||||
@@ -93,7 +93,6 @@ impl From<Profile> for &str {
|
||||
impl From<&str> for Profile {
|
||||
fn from(profile: &str) -> Profile {
|
||||
match profile.to_ascii_lowercase().trim() {
|
||||
"balanced" => Profile::Balanced,
|
||||
"performance" => Profile::Performance,
|
||||
"quiet" => Profile::Quiet,
|
||||
_ => Profile::Balanced,
|
||||
@@ -202,7 +201,7 @@ impl FanCurveProfiles {
|
||||
|
||||
/// Reset the stored (self) and device curve to the defaults of the platform.
|
||||
///
|
||||
/// Each platform_profile has a different default and the defualt can be read
|
||||
/// Each `platform_profile` has a different default and the defualt can be read
|
||||
/// only for the currently active profile.
|
||||
pub fn set_active_curve_to_defaults(
|
||||
&mut self,
|
||||
@@ -296,12 +295,12 @@ impl FanCurveProfiles {
|
||||
FanCurvePU::GPU => &self.balanced.gpu,
|
||||
},
|
||||
Profile::Performance => match pu {
|
||||
FanCurvePU::CPU => &self.balanced.cpu,
|
||||
FanCurvePU::GPU => &self.balanced.gpu,
|
||||
FanCurvePU::CPU => &self.performance.cpu,
|
||||
FanCurvePU::GPU => &self.performance.gpu,
|
||||
},
|
||||
Profile::Quiet => match pu {
|
||||
FanCurvePU::CPU => &self.balanced.cpu,
|
||||
FanCurvePU::GPU => &self.balanced.gpu,
|
||||
FanCurvePU::CPU => &self.quiet.cpu,
|
||||
FanCurvePU::GPU => &self.quiet.gpu,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
# If you see this, run "rustup self update" to get rustup 1.23 or newer.
|
||||
|
||||
# NOTE: above comment is for older `rustup` (before TOML support was added),
|
||||
# which will treat the first line as the toolchain name, and therefore show it
|
||||
# to the user in the error, instead of "error: invalid channel name '[toolchain]'".
|
||||
|
||||
[toolchain]
|
||||
channel = "1.65.0"
|
||||
components = [ "rustfmt", "clippy" ]
|
||||
Reference in New Issue
Block a user