Compare commits

...

12 Commits

Author SHA1 Message Date
Luke D. Jones ccf8d8df91 Prep 6.0.5 version 2024-05-10 12:44:46 +12:00
Luke D. Jones b970d364f7 Fix test 2024-05-10 12:36:34 +12:00
Luke D. Jones 1da68ea69d Try to mitigate the lack of kbd_brightness on some laptops 2024-05-10 12:22:36 +12:00
Luke D. Jones e62e7e8eca Cleanup sys config 2024-05-10 10:26:32 +12:00
Luke D. Jones 1b1d10c461 Try to better handle pre-2021 laptops with lightbar 2024-05-10 10:04:51 +12:00
Stefan Boca 14ea0f6d83 Update GA402XV supported aura modes 2024-05-08 19:20:17 -07:00
Luke Jones 5107a6c39c Merge branch 'FAYZER77-main-patch-34823' into 'main'
Change 733C model profile to add support for Lid LED, and remove unneeded basic zones entries

See merge request asus-linux/asusctl!183
2024-05-08 23:12:56 +00:00
FAYZER77 2c77ec9e24 Change 733C model profile to add support for Lid LED, and remove unneeded basic zones entries 2024-05-08 23:08:19 +00:00
Luke D. Jones 817a66bdf1 Prep 6.0.4 2024-05-09 11:00:51 +12:00
Luke D. Jones 664a3d5533 Match G533Q to 0x8166 keyboard ID explicitly
Should close #438
2024-05-09 10:01:48 +12:00
Luke D. Jones 37bc5e45b9 Fix: ensure property derive is on all property methods for slash 2024-05-09 09:34:02 +12:00
Luke D. Jones a18692ef1e Fix up colour sliders
- Fixup colour sliders for UI
- Correctly drop tokio runtime
2024-05-08 22:55:11 +12:00
23 changed files with 398 additions and 400 deletions
+28
View File
@@ -7,6 +7,34 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
## [v6.0.5]
### Changed
- Better more robust error handling in ROGCC
- Try to better handle pre-2021 laptops with lightbar
- Add more logging to try and trace the charge_control_end_threshold issue
- Make `kbd_brightness` optional to work around issues on some laptops that seem to lack it. Likely this will all need a refactor *again* if work proceeds in kernel for better RGB support.
## [v6.0.4]
### Changed
- Remove some `todo()` in rogcc
- Add missing `#[zbus(property)]` derive to Slash dbus properties
- Match G533Q laptop explicitly to the 0x8166 PID
## [v6.0.3]
### NOTE
- Xorg is not supported any longer. All major desktops and distros are Wayland.
### Changed
- Add a check to prevent non-TUF laptops with screwed up method return from TUF acpi methods from trying to add a TUF aura device without actually being a TUF laptop.
- Make the G834JZ entry in aura db generic for all G834J
## [v6.0.2] ## [v6.0.2]
### Changed ### Changed
Generated
+33 -33
View File
@@ -117,7 +117,7 @@ checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711"
[[package]] [[package]]
name = "asusctl" name = "asusctl"
version = "6.0.2" version = "6.0.5"
dependencies = [ dependencies = [
"asusd", "asusd",
"cargo-husky", "cargo-husky",
@@ -135,14 +135,14 @@ dependencies = [
[[package]] [[package]]
name = "asusd" name = "asusd"
version = "6.0.2" version = "6.0.5"
dependencies = [ dependencies = [
"cargo-husky", "cargo-husky",
"concat-idents", "concat-idents",
"config-traits", "config-traits",
"dmi_id", "dmi_id",
"env_logger", "env_logger",
"futures-lite 2.3.0", "futures-lite 1.13.0",
"inotify", "inotify",
"log", "log",
"logind-zbus", "logind-zbus",
@@ -161,7 +161,7 @@ dependencies = [
[[package]] [[package]]
name = "asusd-user" name = "asusd-user"
version = "6.0.2" version = "6.0.5"
dependencies = [ dependencies = [
"cargo-husky", "cargo-husky",
"config-traits", "config-traits",
@@ -828,7 +828,7 @@ dependencies = [
[[package]] [[package]]
name = "config-traits" name = "config-traits"
version = "6.0.2" version = "6.0.5"
dependencies = [ dependencies = [
"cargo-husky", "cargo-husky",
"log", "log",
@@ -839,7 +839,7 @@ dependencies = [
[[package]] [[package]]
name = "const-field-offset" name = "const-field-offset"
version = "0.1.5" version = "0.1.5"
source = "git+https://github.com/slint-ui/slint.git#c0b79024cc6d064f9e94695d63a18ae490add2d3" source = "git+https://github.com/slint-ui/slint.git#65160638a1c36cf8ee19047554f7bb4384c69ddf"
dependencies = [ dependencies = [
"const-field-offset-macro", "const-field-offset-macro",
"field-offset", "field-offset",
@@ -848,7 +848,7 @@ dependencies = [
[[package]] [[package]]
name = "const-field-offset-macro" name = "const-field-offset-macro"
version = "0.1.5" version = "0.1.5"
source = "git+https://github.com/slint-ui/slint.git#c0b79024cc6d064f9e94695d63a18ae490add2d3" source = "git+https://github.com/slint-ui/slint.git#65160638a1c36cf8ee19047554f7bb4384c69ddf"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@@ -934,7 +934,7 @@ checksum = "7704b5fdd17b18ae31c4c1da5a2e0305a2bf17b5249300a9ee9ed7b72114c636"
[[package]] [[package]]
name = "cpuctl" name = "cpuctl"
version = "6.0.2" version = "6.0.5"
[[package]] [[package]]
name = "cpufeatures" name = "cpufeatures"
@@ -1134,7 +1134,7 @@ dependencies = [
[[package]] [[package]]
name = "dmi_id" name = "dmi_id"
version = "6.0.2" version = "6.0.5"
dependencies = [ dependencies = [
"log", "log",
"udev 0.8.0", "udev 0.8.0",
@@ -1252,9 +1252,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
[[package]] [[package]]
name = "errno" name = "errno"
version = "0.3.8" version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba"
dependencies = [ dependencies = [
"libc", "libc",
"windows-sys 0.52.0", "windows-sys 0.52.0",
@@ -1841,7 +1841,7 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
[[package]] [[package]]
name = "i-slint-backend-linuxkms" name = "i-slint-backend-linuxkms"
version = "1.6.0" version = "1.6.0"
source = "git+https://github.com/slint-ui/slint.git#c0b79024cc6d064f9e94695d63a18ae490add2d3" source = "git+https://github.com/slint-ui/slint.git#65160638a1c36cf8ee19047554f7bb4384c69ddf"
dependencies = [ dependencies = [
"calloop", "calloop",
"drm", "drm",
@@ -1861,7 +1861,7 @@ dependencies = [
[[package]] [[package]]
name = "i-slint-backend-selector" name = "i-slint-backend-selector"
version = "1.6.0" version = "1.6.0"
source = "git+https://github.com/slint-ui/slint.git#c0b79024cc6d064f9e94695d63a18ae490add2d3" source = "git+https://github.com/slint-ui/slint.git#65160638a1c36cf8ee19047554f7bb4384c69ddf"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"i-slint-backend-linuxkms", "i-slint-backend-linuxkms",
@@ -1873,7 +1873,7 @@ dependencies = [
[[package]] [[package]]
name = "i-slint-backend-winit" name = "i-slint-backend-winit"
version = "1.6.0" version = "1.6.0"
source = "git+https://github.com/slint-ui/slint.git#c0b79024cc6d064f9e94695d63a18ae490add2d3" source = "git+https://github.com/slint-ui/slint.git#65160638a1c36cf8ee19047554f7bb4384c69ddf"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"cfg_aliases 0.2.0", "cfg_aliases 0.2.0",
@@ -1903,7 +1903,7 @@ dependencies = [
[[package]] [[package]]
name = "i-slint-common" name = "i-slint-common"
version = "1.6.0" version = "1.6.0"
source = "git+https://github.com/slint-ui/slint.git#c0b79024cc6d064f9e94695d63a18ae490add2d3" source = "git+https://github.com/slint-ui/slint.git#65160638a1c36cf8ee19047554f7bb4384c69ddf"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"derive_more", "derive_more",
@@ -1914,7 +1914,7 @@ dependencies = [
[[package]] [[package]]
name = "i-slint-compiler" name = "i-slint-compiler"
version = "1.6.0" version = "1.6.0"
source = "git+https://github.com/slint-ui/slint.git#c0b79024cc6d064f9e94695d63a18ae490add2d3" source = "git+https://github.com/slint-ui/slint.git#65160638a1c36cf8ee19047554f7bb4384c69ddf"
dependencies = [ dependencies = [
"by_address", "by_address",
"codemap", "codemap",
@@ -1943,7 +1943,7 @@ dependencies = [
[[package]] [[package]]
name = "i-slint-core" name = "i-slint-core"
version = "1.6.0" version = "1.6.0"
source = "git+https://github.com/slint-ui/slint.git#c0b79024cc6d064f9e94695d63a18ae490add2d3" source = "git+https://github.com/slint-ui/slint.git#65160638a1c36cf8ee19047554f7bb4384c69ddf"
dependencies = [ dependencies = [
"auto_enums", "auto_enums",
"bitflags 2.5.0", "bitflags 2.5.0",
@@ -1986,7 +1986,7 @@ dependencies = [
[[package]] [[package]]
name = "i-slint-core-macros" name = "i-slint-core-macros"
version = "1.6.0" version = "1.6.0"
source = "git+https://github.com/slint-ui/slint.git#c0b79024cc6d064f9e94695d63a18ae490add2d3" source = "git+https://github.com/slint-ui/slint.git#65160638a1c36cf8ee19047554f7bb4384c69ddf"
dependencies = [ dependencies = [
"quote", "quote",
"syn 2.0.61", "syn 2.0.61",
@@ -1995,7 +1995,7 @@ dependencies = [
[[package]] [[package]]
name = "i-slint-renderer-femtovg" name = "i-slint-renderer-femtovg"
version = "1.6.0" version = "1.6.0"
source = "git+https://github.com/slint-ui/slint.git#c0b79024cc6d064f9e94695d63a18ae490add2d3" source = "git+https://github.com/slint-ui/slint.git#65160638a1c36cf8ee19047554f7bb4384c69ddf"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"const-field-offset", "const-field-offset",
@@ -2026,7 +2026,7 @@ dependencies = [
[[package]] [[package]]
name = "i-slint-renderer-skia" name = "i-slint-renderer-skia"
version = "1.6.0" version = "1.6.0"
source = "git+https://github.com/slint-ui/slint.git#c0b79024cc6d064f9e94695d63a18ae490add2d3" source = "git+https://github.com/slint-ui/slint.git#65160638a1c36cf8ee19047554f7bb4384c69ddf"
dependencies = [ dependencies = [
"bytemuck", "bytemuck",
"cfg-if", "cfg-if",
@@ -3309,7 +3309,7 @@ dependencies = [
[[package]] [[package]]
name = "rog-control-center" name = "rog-control-center"
version = "6.0.2" version = "6.0.5"
dependencies = [ dependencies = [
"asusd", "asusd",
"betrayer", "betrayer",
@@ -3341,7 +3341,7 @@ dependencies = [
[[package]] [[package]]
name = "rog_anime" name = "rog_anime"
version = "6.0.2" version = "6.0.5"
dependencies = [ dependencies = [
"cargo-husky", "cargo-husky",
"dmi_id", "dmi_id",
@@ -3358,7 +3358,7 @@ dependencies = [
[[package]] [[package]]
name = "rog_aura" name = "rog_aura"
version = "6.0.2" version = "6.0.5"
dependencies = [ dependencies = [
"cargo-husky", "cargo-husky",
"dmi_id", "dmi_id",
@@ -3372,7 +3372,7 @@ dependencies = [
[[package]] [[package]]
name = "rog_dbus" name = "rog_dbus"
version = "6.0.2" version = "6.0.5"
dependencies = [ dependencies = [
"asusd", "asusd",
"cargo-husky", "cargo-husky",
@@ -3386,7 +3386,7 @@ dependencies = [
[[package]] [[package]]
name = "rog_platform" name = "rog_platform"
version = "6.0.2" version = "6.0.5"
dependencies = [ dependencies = [
"cargo-husky", "cargo-husky",
"concat-idents", "concat-idents",
@@ -3401,7 +3401,7 @@ dependencies = [
[[package]] [[package]]
name = "rog_profiles" name = "rog_profiles"
version = "6.0.2" version = "6.0.5"
dependencies = [ dependencies = [
"cargo-husky", "cargo-husky",
"log", "log",
@@ -3415,7 +3415,7 @@ dependencies = [
[[package]] [[package]]
name = "rog_simulators" name = "rog_simulators"
version = "6.0.2" version = "6.0.5"
dependencies = [ dependencies = [
"log", "log",
"rog_anime", "rog_anime",
@@ -3425,7 +3425,7 @@ dependencies = [
[[package]] [[package]]
name = "rog_slash" name = "rog_slash"
version = "6.0.2" version = "6.0.5"
dependencies = [ dependencies = [
"cargo-husky", "cargo-husky",
"dmi_id", "dmi_id",
@@ -3760,7 +3760,7 @@ dependencies = [
[[package]] [[package]]
name = "slint" name = "slint"
version = "1.6.0" version = "1.6.0"
source = "git+https://github.com/slint-ui/slint.git#c0b79024cc6d064f9e94695d63a18ae490add2d3" source = "git+https://github.com/slint-ui/slint.git#65160638a1c36cf8ee19047554f7bb4384c69ddf"
dependencies = [ dependencies = [
"const-field-offset", "const-field-offset",
"i-slint-backend-selector", "i-slint-backend-selector",
@@ -3776,7 +3776,7 @@ dependencies = [
[[package]] [[package]]
name = "slint-build" name = "slint-build"
version = "1.6.0" version = "1.6.0"
source = "git+https://github.com/slint-ui/slint.git#c0b79024cc6d064f9e94695d63a18ae490add2d3" source = "git+https://github.com/slint-ui/slint.git#65160638a1c36cf8ee19047554f7bb4384c69ddf"
dependencies = [ dependencies = [
"i-slint-compiler", "i-slint-compiler",
"spin_on", "spin_on",
@@ -3787,7 +3787,7 @@ dependencies = [
[[package]] [[package]]
name = "slint-macros" name = "slint-macros"
version = "1.6.0" version = "1.6.0"
source = "git+https://github.com/slint-ui/slint.git#c0b79024cc6d064f9e94695d63a18ae490add2d3" source = "git+https://github.com/slint-ui/slint.git#65160638a1c36cf8ee19047554f7bb4384c69ddf"
dependencies = [ dependencies = [
"i-slint-compiler", "i-slint-compiler",
"proc-macro2", "proc-macro2",
@@ -4496,7 +4496,7 @@ dependencies = [
[[package]] [[package]]
name = "vtable" name = "vtable"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/slint-ui/slint.git#c0b79024cc6d064f9e94695d63a18ae490add2d3" source = "git+https://github.com/slint-ui/slint.git#65160638a1c36cf8ee19047554f7bb4384c69ddf"
dependencies = [ dependencies = [
"const-field-offset", "const-field-offset",
"portable-atomic", "portable-atomic",
@@ -4507,7 +4507,7 @@ dependencies = [
[[package]] [[package]]
name = "vtable-macro" name = "vtable-macro"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/slint-ui/slint.git#c0b79024cc6d064f9e94695d63a18ae490add2d3" source = "git+https://github.com/slint-ui/slint.git#65160638a1c36cf8ee19047554f7bb4384c69ddf"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
+11 -11
View File
@@ -1,3 +1,14 @@
[workspace.package]
version = "6.0.5"
rust-version = "1.77"
license = "MPL-2.0"
readme = "README.md"
authors = ["Luke <luke@ljones.dev>"]
repository = "https://gitlab.com/asus-linux/asusctl"
homepage = "https://gitlab.com/asus-linux/asusctl"
description = "Laptop feature control for ASUS ROG laptops and others"
edition = "2021"
[workspace] [workspace]
members = [ members = [
"asusctl", "asusctl",
@@ -24,17 +35,6 @@ default-members = [
] ]
resolver = "2" resolver = "2"
[workspace.package]
version = "6.0.2"
rust-version = "1.77"
license = "MPL-2.0"
readme = "README.md"
authors = ["Luke <luke@ljones.dev>"]
repository = "https://gitlab.com/asus-linux/asusctl"
homepage = "https://gitlab.com/asus-linux/asusctl"
description = "Laptop feature control for ASUS ROG laptops and others"
edition = "2021"
[workspace.dependencies] [workspace.dependencies]
tokio = { version = "^1.36.0", default-features = false, features = [ tokio = { version = "^1.36.0", default-features = false, features = [
"macros", "macros",
+4 -3
View File
@@ -72,14 +72,15 @@ The list is a bit outdated as many features have been enabled in the Linux kerne
A gui is now in the repo - ROG Control Center. At this time it is still a WIP, but it has almost all features in place already. A gui is now in the repo - ROG Control Center. At this time it is still a WIP, but it has almost all features in place already.
**NOTE**: Xorg is not supported.
# BUILDING # BUILDING
Rust and cargo are required, they can be installed from [rustup.rs](https://rustup.rs/) or from the distro repos if newer than 1.75. Rust and cargo are required, they can be installed from [rustup.rs](https://rustup.rs/) or from the distro repos if newer than 1.75.
**fedora:** **fedora:**
dnf install cmake clang-devel libinput-devel libseat-devel libgbm-devel libxkbcommon-devel systemd-devel \ dnf install cmake clang-devel libinput-devel libseat-devel libgbm-devel libxkbcommon-devel systemd-devel libdrm-devel expat-devel pcre2-devel libzstd-devel gtk3-devel
libdrm-devel expat-devel pcre2-devel libzstd-devel libappindicator-gtk3
make make
sudo make install sudo make install
@@ -88,7 +89,7 @@ Rust and cargo are required, they can be installed from [rustup.rs](https://rust
Works with KDE Plasma (without GTK packages) Works with KDE Plasma (without GTK packages)
zypper in -t pattern devel_basis zypper in -t pattern devel_basis
zypper in rustup make cmake libinput-devel libseat-devel libgbm-devel systemd-devel clang-devel llvm-devel gdk-pixbuf-devel cairo-devel pango-devel freetype-devel libexpat-devel libayatana-indicator3-7 zypper in rustup make cmake clang-devel libinput-devel libseat-devel libgbm-devel libxkbcommon-devel systemd-devel libdrm-devel expat-devel pcre2-devel libzstd-devel gtk3-devel
make make
sudo make install sudo make install
+16 -13
View File
@@ -645,25 +645,28 @@ fn handle_led_power_1_do_1866(
aura: &AuraProxyBlocking, aura: &AuraProxyBlocking,
power: &LedPowerCommand1, power: &LedPowerCommand1,
) -> Result<(), Box<dyn std::error::Error>> { ) -> Result<(), Box<dyn std::error::Error>> {
let zone = if power.keyboard && power.lightbar { let mut states = Vec::new();
PowerZones::KeyboardAndLightbar if power.keyboard {
} else if power.lightbar { states.push(AuraPowerState {
PowerZones::Lightbar zone: PowerZones::Keyboard,
} else {
PowerZones::Keyboard
};
let states = LaptopAuraPower {
states: vec![AuraPowerState {
zone,
boot: power.boot.unwrap_or_default(), boot: power.boot.unwrap_or_default(),
awake: power.awake.unwrap_or_default(), awake: power.awake.unwrap_or_default(),
sleep: power.sleep.unwrap_or_default(), sleep: power.sleep.unwrap_or_default(),
shutdown: false, shutdown: false,
}], });
}; }
if power.lightbar {
states.push(AuraPowerState {
zone: PowerZones::Lightbar,
boot: power.boot.unwrap_or_default(),
awake: power.awake.unwrap_or_default(),
sleep: power.sleep.unwrap_or_default(),
shutdown: false,
});
}
let states = LaptopAuraPower { states };
aura.set_led_power(states)?; aura.set_led_power(states)?;
Ok(()) Ok(())
} }
+2 -78
View File
@@ -1,4 +1,4 @@
use config_traits::{StdConfig, StdConfigLoad3}; use config_traits::{StdConfig, StdConfigLoad1};
use rog_platform::cpu::CPUEPP; use rog_platform::cpu::CPUEPP;
use rog_platform::platform::ThrottlePolicy; use rog_platform::platform::ThrottlePolicy;
use serde_derive::{Deserialize, Serialize}; use serde_derive::{Deserialize, Serialize};
@@ -106,7 +106,7 @@ impl StdConfig for Config {
} }
} }
impl StdConfigLoad3<Config472, Config506, Config507> for Config {} impl StdConfigLoad1<Config507> for Config {}
#[derive(Deserialize, Serialize)] #[derive(Deserialize, Serialize)]
pub struct Config507 { pub struct Config507 {
@@ -157,79 +157,3 @@ impl From<Config507> for Config {
} }
} }
} }
#[derive(Deserialize, Serialize)]
pub struct Config506 {
/// Save charge limit for restoring on boot
pub charge_control_end_threshold: u8,
pub panel_od: bool,
pub mini_led_mode: bool,
pub disable_nvidia_powerd_on_battery: bool,
pub ac_command: String,
pub bat_command: String,
/// Restored on boot as well as when power is plugged
#[serde(skip)]
pub platform_policy_to_restore: ThrottlePolicy,
pub platform_policy_on_battery: ThrottlePolicy,
pub platform_policy_on_ac: ThrottlePolicy,
//
pub ppt_pl1_spl: Option<u8>,
pub ppt_pl2_sppt: Option<u8>,
pub ppt_fppt: Option<u8>,
pub ppt_apu_sppt: Option<u8>,
pub ppt_platform_sppt: Option<u8>,
pub nv_dynamic_boost: Option<u8>,
pub nv_temp_target: Option<u8>,
}
impl From<Config506> for Config {
fn from(c: Config506) -> Self {
Self {
charge_control_end_threshold: c.charge_control_end_threshold,
panel_od: c.panel_od,
boot_sound: false,
disable_nvidia_powerd_on_battery: c.disable_nvidia_powerd_on_battery,
ac_command: c.ac_command,
bat_command: c.bat_command,
mini_led_mode: c.mini_led_mode,
throttle_policy_linked_epp: true,
throttle_policy_on_battery: c.platform_policy_on_battery,
throttle_policy_on_ac: c.platform_policy_on_ac,
throttle_quiet_epp: CPUEPP::Power,
throttle_balanced_epp: CPUEPP::BalancePower,
throttle_performance_epp: CPUEPP::Performance,
ppt_pl1_spl: c.ppt_pl1_spl,
ppt_pl2_sppt: c.ppt_pl2_sppt,
ppt_fppt: c.ppt_fppt,
ppt_apu_sppt: c.ppt_apu_sppt,
ppt_platform_sppt: c.ppt_platform_sppt,
nv_dynamic_boost: c.nv_dynamic_boost,
nv_temp_target: c.nv_temp_target,
last_power_plugged: 0,
}
}
}
#[derive(Deserialize, Serialize)]
pub struct Config472 {
/// Save charge limit for restoring on boot
pub bat_charge_limit: u8,
pub panel_od: bool,
pub mini_led_mode: bool,
pub disable_nvidia_powerd_on_battery: bool,
pub ac_command: String,
pub bat_command: String,
}
impl From<Config472> for Config {
fn from(c: Config472) -> Self {
Self {
charge_control_end_threshold: c.bat_charge_limit,
panel_od: c.panel_od,
disable_nvidia_powerd_on_battery: true,
ac_command: c.ac_command,
bat_command: c.bat_command,
..Default::default()
}
}
}
+83 -21
View File
@@ -1,6 +1,7 @@
use std::collections::{BTreeMap, HashSet}; use std::collections::{BTreeMap, HashSet};
use config_traits::{StdConfig, StdConfigLoad}; use config_traits::{StdConfig, StdConfigLoad};
use dmi_id::DMIID;
use inotify::Inotify; use inotify::Inotify;
use log::{debug, info, warn}; use log::{debug, info, warn};
use rog_aura::aura_detection::LedSupportData; use rog_aura::aura_detection::LedSupportData;
@@ -10,7 +11,7 @@ use rog_aura::{
AuraDeviceType, AuraEffect, Direction, LedBrightness, Speed, GRADIENT, LED_MSG_LEN, AuraDeviceType, AuraEffect, Direction, LedBrightness, Speed, GRADIENT, LED_MSG_LEN,
}; };
use rog_platform::hid_raw::HidRaw; use rog_platform::hid_raw::HidRaw;
use rog_platform::keyboard_led::KeyboardLed; use rog_platform::keyboard_led::KeyboardBacklight;
use zbus::zvariant::OwnedObjectPath; use zbus::zvariant::OwnedObjectPath;
use super::config::AuraConfig; use super::config::AuraConfig;
@@ -20,9 +21,9 @@ use crate::error::RogError;
#[derive(Debug)] #[derive(Debug)]
pub enum LEDNode { pub enum LEDNode {
/// Brightness and/or TUF RGB controls /// Brightness and/or TUF RGB controls
KbdLed(KeyboardLed), KbdLed(KeyboardBacklight),
/// Raw HID handle /// Raw HID handle
Rog(KeyboardLed, HidRaw), Rog(Option<KeyboardBacklight>, HidRaw),
} }
impl LEDNode { impl LEDNode {
@@ -30,7 +31,13 @@ impl LEDNode {
pub fn set_brightness(&self, value: u8) -> Result<(), RogError> { pub fn set_brightness(&self, value: u8) -> Result<(), RogError> {
match self { match self {
LEDNode::KbdLed(k) => k.set_brightness(value)?, LEDNode::KbdLed(k) => k.set_brightness(value)?,
LEDNode::Rog(k, _) => k.set_brightness(value)?, LEDNode::Rog(k, _) => {
if let Some(k) = k {
k.set_brightness(value)?
} else {
debug!("No brightness control found");
}
}
} }
Ok(()) Ok(())
} }
@@ -38,16 +45,47 @@ impl LEDNode {
pub fn get_brightness(&self) -> Result<u8, RogError> { pub fn get_brightness(&self) -> Result<u8, RogError> {
Ok(match self { Ok(match self {
LEDNode::KbdLed(k) => k.get_brightness()?, LEDNode::KbdLed(k) => k.get_brightness()?,
LEDNode::Rog(k, _) => k.get_brightness()?, LEDNode::Rog(k, _) => {
if let Some(k) = k {
k.get_brightness()?
} else {
debug!("No brightness control found");
return Err(RogError::MissingFunction(
"No keyboard brightness control found".to_string(),
));
}
}
}) })
} }
pub fn monitor_brightness(&self) -> Result<Inotify, RogError> { pub fn monitor_brightness(&self) -> Result<Inotify, RogError> {
Ok(match self { Ok(match self {
LEDNode::KbdLed(k) => k.monitor_brightness()?, LEDNode::KbdLed(k) => k.monitor_brightness()?,
LEDNode::Rog(k, _) => k.monitor_brightness()?, LEDNode::Rog(k, _) => {
if let Some(k) = k {
k.monitor_brightness()?
} else {
debug!("No brightness control found");
return Err(RogError::MissingFunction(
"No keyboard brightness control found".to_string(),
));
}
}
}) })
} }
pub fn has_brightness_control(&self) -> bool {
match self {
LEDNode::KbdLed(k) => k.has_brightness(),
LEDNode::Rog(k, _) => {
if let Some(k) = k {
k.has_brightness()
} else {
false
}
}
}
}
} }
/// Individual controller for one Aura device /// Individual controller for one Aura device
@@ -121,19 +159,30 @@ impl CtrlKbdLed {
} }
// Check for a TUF laptop LED. Assume there is only ever one. // Check for a TUF laptop LED. Assume there is only ever one.
if let Ok(kbd_backlight) = KeyboardLed::new() { if let Ok(kbd_backlight) = KeyboardBacklight::new() {
if kbd_backlight.has_kbd_rgb_mode() { if kbd_backlight.has_kbd_rgb_mode() {
info!("AuraControl found a TUF laptop keyboard"); // Extra sure double-check that this isn't a laptop with crap
let ctrl = CtrlKbdLed { // ACPI with borked return on the TUF rgb methods
led_type: AuraDeviceType::LaptopTuf, let dmi = DMIID::new().unwrap_or_default();
led_node: LEDNode::KbdLed(kbd_backlight), info!("Found a TUF with product family: {}", dmi.product_family);
supported_data: LedSupportData::get_data("tuf"), info!("and board name: {}", dmi.board_name);
per_key_mode_active: false,
config: Self::init_config("tuf"), if dmi.product_family.contains("TUF") {
dbus_path: dbus_path_for_tuf(), info!("AuraControl found a TUF laptop keyboard");
}; let ctrl = CtrlKbdLed {
devices.push(ctrl); led_type: AuraDeviceType::LaptopTuf,
led_node: LEDNode::KbdLed(kbd_backlight),
supported_data: LedSupportData::get_data("tuf"),
per_key_mode_active: false,
config: Self::init_config("tuf"),
dbus_path: dbus_path_for_tuf(),
};
devices.push(ctrl);
}
} }
} else {
let dmi = DMIID::new().unwrap_or_default();
warn!("No asus::kbd_backlight found for {} ??", dmi.product_family);
} }
info!("Found {} Aura devices", devices.len()); info!("Found {} Aura devices", devices.len());
@@ -145,7 +194,14 @@ impl CtrlKbdLed {
/// should be overwritten. The reason for the default config is because /// should be overwritten. The reason for the default config is because
/// of async issues between this and udev/hidraw /// of async issues between this and udev/hidraw
pub fn from_hidraw(device: HidRaw, dbus_path: OwnedObjectPath) -> Result<Self, RogError> { pub fn from_hidraw(device: HidRaw, dbus_path: OwnedObjectPath) -> Result<Self, RogError> {
let rgb_led = KeyboardLed::new()?; let rgb_led = KeyboardBacklight::new()
.map_err(|e| {
log::error!(
"{} is missing a keyboard backlight brightness control: {e:?}",
device.prod_id()
);
})
.ok();
let prod_id = AuraDeviceType::from(device.prod_id()); let prod_id = AuraDeviceType::from(device.prod_id());
if prod_id == AuraDeviceType::Unknown { if prod_id == AuraDeviceType::Unknown {
log::error!("{} is AuraDevice::Unknown", device.prod_id()); log::error!("{} is AuraDevice::Unknown", device.prod_id());
@@ -364,7 +420,7 @@ mod tests {
use rog_aura::aura_detection::LedSupportData; use rog_aura::aura_detection::LedSupportData;
use rog_aura::{AuraDeviceType, AuraModeNum, AuraZone, PowerZones}; use rog_aura::{AuraDeviceType, AuraModeNum, AuraZone, PowerZones};
use rog_platform::hid_raw::HidRaw; use rog_platform::hid_raw::HidRaw;
use rog_platform::keyboard_led::KeyboardLed; use rog_platform::keyboard_led::KeyboardBacklight;
use zbus::zvariant::OwnedObjectPath; use zbus::zvariant::OwnedObjectPath;
use super::CtrlKbdLed; use super::CtrlKbdLed;
@@ -387,7 +443,10 @@ mod tests {
}; };
let mut controller = CtrlKbdLed { let mut controller = CtrlKbdLed {
led_type: AuraDeviceType::LaptopPost2021, led_type: AuraDeviceType::LaptopPost2021,
led_node: LEDNode::Rog(KeyboardLed::default(), HidRaw::new("19b6").unwrap()), led_node: LEDNode::Rog(
Some(KeyboardBacklight::default()),
HidRaw::new("19b6").unwrap(),
),
supported_data: supported_basic_modes, supported_data: supported_basic_modes,
per_key_mode_active: false, per_key_mode_active: false,
config, config,
@@ -428,7 +487,10 @@ mod tests {
}; };
let mut controller = CtrlKbdLed { let mut controller = CtrlKbdLed {
led_type: AuraDeviceType::LaptopPost2021, led_type: AuraDeviceType::LaptopPost2021,
led_node: LEDNode::Rog(KeyboardLed::default(), HidRaw::new("19b6").unwrap()), led_node: LEDNode::Rog(
Some(KeyboardBacklight::default()),
HidRaw::new("19b6").unwrap(),
),
supported_data: supported_basic_modes, supported_data: supported_basic_modes,
per_key_mode_active: false, per_key_mode_active: false,
config, config,
+33 -25
View File
@@ -26,7 +26,7 @@ impl CtrlAuraZbus {
} }
fn update_config(lock: &mut CtrlKbdLed) -> Result<(), RogError> { fn update_config(lock: &mut CtrlKbdLed) -> Result<(), RogError> {
let bright = lock.led_node.get_brightness()?; let bright = lock.led_node.get_brightness().unwrap_or_default();
lock.config.read(); lock.config.read();
lock.config.brightness = bright.into(); lock.config.brightness = bright.into();
lock.config.write(); lock.config.write();
@@ -109,8 +109,10 @@ impl CtrlAuraZbus {
if ctrl.config.brightness == LedBrightness::Off { if ctrl.config.brightness == LedBrightness::Off {
ctrl.config.brightness = LedBrightness::Med; ctrl.config.brightness = LedBrightness::Med;
} }
ctrl.led_node if ctrl.led_node.has_brightness_control() {
.set_brightness(ctrl.config.brightness.into())?; ctrl.led_node
.set_brightness(ctrl.config.brightness.into())?;
}
ctrl.config.write(); ctrl.config.write();
self.led_mode_data_invalidate(&self.1).await.ok(); self.led_mode_data_invalidate(&self.1).await.ok();
@@ -148,8 +150,10 @@ impl CtrlAuraZbus {
if ctrl.config.brightness == LedBrightness::Off { if ctrl.config.brightness == LedBrightness::Off {
ctrl.config.brightness = LedBrightness::Med; ctrl.config.brightness = LedBrightness::Med;
} }
ctrl.led_node if ctrl.led_node.has_brightness_control() {
.set_brightness(ctrl.config.brightness.into())?; ctrl.led_node
.set_brightness(ctrl.config.brightness.into())?;
}
ctrl.config.set_builtin(effect); ctrl.config.set_builtin(effect);
ctrl.config.write(); ctrl.config.write();
@@ -213,12 +217,14 @@ impl CtrlTask for CtrlAuraZbus {
// If waking up // If waking up
if !start { if !start {
info!("CtrlKbdLedTask reloading brightness and modes"); info!("CtrlKbdLedTask reloading brightness and modes");
lock.led_node if lock.led_node.has_brightness_control() {
.set_brightness(lock.config.brightness.into()) lock.led_node
.map_err(|e| { .set_brightness(lock.config.brightness.into())
error!("CtrlKbdLedTask: {e}"); .map_err(|e| {
e error!("CtrlKbdLedTask: {e}");
})?; e
})?;
}
lock.write_current_config_mode().map_err(|e| { lock.write_current_config_mode().map_err(|e| {
error!("CtrlKbdLedTask: {e}"); error!("CtrlKbdLedTask: {e}");
e e
@@ -264,20 +270,22 @@ impl CtrlTask for CtrlAuraZbus {
let ctrl2 = self.0.clone(); let ctrl2 = self.0.clone();
let ctrl = self.0.lock().await; let ctrl = self.0.lock().await;
let watch = ctrl.led_node.monitor_brightness()?; if ctrl.led_node.has_brightness_control() {
tokio::spawn(async move { let watch = ctrl.led_node.monitor_brightness()?;
let mut buffer = [0; 32]; tokio::spawn(async move {
watch let mut buffer = [0; 32];
.into_event_stream(&mut buffer) watch
.unwrap() .into_event_stream(&mut buffer)
.for_each(|_| async { .unwrap()
if let Some(lock) = ctrl2.try_lock() { .for_each(|_| async {
load_save(true, lock).unwrap(); // unwrap as we want to if let Some(lock) = ctrl2.try_lock() {
// bomb out of the task load_save(true, lock).unwrap(); // unwrap as we want to
} // bomb out of the task
}) }
.await; })
}); .await;
});
}
Ok(()) Ok(())
} }
+17 -14
View File
@@ -731,8 +731,9 @@ impl ReloadAndNotify for CtrlPlatform {
info!("asusd.ron updated externally, reloading and updating internal copy"); info!("asusd.ron updated externally, reloading and updating internal copy");
if self.power.has_charge_control_end_threshold() { if self.power.has_charge_control_end_threshold() {
self.power let limit = data.charge_control_end_threshold;
.set_charge_control_end_threshold(data.charge_control_end_threshold)?; warn!("setting charge_control_end_threshold to {limit}");
self.power.set_charge_control_end_threshold(limit)?;
self.charge_control_end_threshold_changed(signal_context) self.charge_control_end_threshold_changed(signal_context)
.await?; .await?;
} }
@@ -827,9 +828,9 @@ impl crate::Reloadable for CtrlPlatform {
ppt_reload!(nv_temp_target, "nv_temp_target"); ppt_reload!(nv_temp_target, "nv_temp_target");
if self.power.has_charge_control_end_threshold() { if self.power.has_charge_control_end_threshold() {
self.power.set_charge_control_end_threshold( let limit = self.config.lock().await.charge_control_end_threshold;
self.config.lock().await.charge_control_end_threshold, info!("reloading charge_control_end_threshold to {limit}");
)?; self.power.set_charge_control_end_threshold(limit)?;
} }
if let Ok(power_plugged) = self.power.get_online() { if let Ok(power_plugged) = self.power.get_online() {
@@ -847,11 +848,11 @@ impl crate::Reloadable for CtrlPlatform {
} }
impl CtrlPlatform { impl CtrlPlatform {
task_watch_item!(panel_od platform); task_watch_item!(panel_od "panel_od" platform);
task_watch_item!(mini_led_mode platform); task_watch_item!(mini_led_mode "mini_led_mode" platform);
task_watch_item!(charge_control_end_threshold power); task_watch_item!(charge_control_end_threshold "charge_control_end_threshold" power);
task_watch_item_notify!(boot_sound platform); task_watch_item_notify!(boot_sound platform);
@@ -901,12 +902,14 @@ impl CtrlTask for CtrlPlatform {
}) })
.ok(); .ok();
} }
if sleeping && platform1.power.has_charge_control_end_threshold() { // Don't store it on suspend, assume that the current config setting is desired
platform1.config.lock().await.charge_control_end_threshold = platform1 // if sleeping && platform1.power.has_charge_control_end_threshold() {
.power // platform1.config.lock().await.charge_control_end_threshold = platform1
.get_charge_control_end_threshold() // .power
.unwrap_or(100); // .get_charge_control_end_threshold()
} else if !sleeping && platform1.power.has_charge_control_end_threshold() { // .unwrap_or(100);
// } else
if !sleeping && platform1.power.has_charge_control_end_threshold() {
platform1 platform1
.power .power
.set_charge_control_end_threshold( .set_charge_control_end_threshold(
+4
View File
@@ -33,6 +33,7 @@ impl CtrlSlashZbus {
} }
/// Set enabled true or false /// Set enabled true or false
#[zbus(property)]
async fn set_enabled(&self, enabled: bool) { async fn set_enabled(&self, enabled: bool) {
let mut lock = self.0.lock().await; let mut lock = self.0.lock().await;
let brightness = if enabled && lock.config.slash_brightness == 0 { let brightness = if enabled && lock.config.slash_brightness == 0 {
@@ -64,6 +65,7 @@ impl CtrlSlashZbus {
} }
/// Set brightness level /// Set brightness level
#[zbus(property)]
async fn set_brightness(&self, brightness: u8) { async fn set_brightness(&self, brightness: u8) {
let mut lock = self.0.lock().await; let mut lock = self.0.lock().await;
let enabled = brightness > 0; let enabled = brightness > 0;
@@ -90,6 +92,7 @@ impl CtrlSlashZbus {
} }
/// Set interval between slash animations (0-255) /// Set interval between slash animations (0-255)
#[zbus(property)]
async fn set_interval(&self, interval: u8) { async fn set_interval(&self, interval: u8) {
let mut lock = self.0.lock().await; let mut lock = self.0.lock().await;
lock.node lock.node
@@ -114,6 +117,7 @@ impl CtrlSlashZbus {
} }
/// Set interval between slash animations (0-255) /// Set interval between slash animations (0-255)
#[zbus(property)]
async fn set_slash_mode(&self, slash_mode: SlashMode) { async fn set_slash_mode(&self, slash_mode: SlashMode) {
let mut lock = self.0.lock().await; let mut lock = self.0.lock().await;
+1 -1
View File
@@ -13,7 +13,7 @@ use asusd::ctrl_platform::CtrlPlatform;
use asusd::ctrl_slash::trait_impls::CtrlSlashZbus; use asusd::ctrl_slash::trait_impls::CtrlSlashZbus;
use asusd::ctrl_slash::CtrlSlash; use asusd::ctrl_slash::CtrlSlash;
use asusd::{print_board_info, start_tasks, CtrlTask, DBUS_NAME}; use asusd::{print_board_info, start_tasks, CtrlTask, DBUS_NAME};
use config_traits::{StdConfig, StdConfigLoad3}; use config_traits::{StdConfig, StdConfigLoad1};
use log::{error, info}; use log::{error, info};
use zbus::fdo::ObjectManager; use zbus::fdo::ObjectManager;
+10 -7
View File
@@ -56,7 +56,7 @@ pub static DBUS_IFACE: &str = "org.asuslinux.Daemon";
/// // TODO: this is kind of useless if it can't trigger some action /// // TODO: this is kind of useless if it can't trigger some action
#[macro_export] #[macro_export]
macro_rules! task_watch_item { macro_rules! task_watch_item {
($name:ident $self_inner:ident) => { ($name:ident $name_str:literal $self_inner:ident) => {
concat_idents::concat_idents!(fn_name = watch_, $name { concat_idents::concat_idents!(fn_name = watch_, $name {
async fn fn_name( async fn fn_name(
&self, &self,
@@ -72,12 +72,15 @@ macro_rules! task_watch_item {
let mut buffer = [0; 32]; let mut buffer = [0; 32];
watch.into_event_stream(&mut buffer).unwrap().for_each(|_| async { watch.into_event_stream(&mut buffer).unwrap().for_each(|_| async {
if let Ok(value) = ctrl.$name() { // get new value from zbus method if let Ok(value) = ctrl.$name() { // get new value from zbus method
concat_idents::concat_idents!(notif_fn = $name, _changed { if ctrl.config.lock().await.$name != value {
ctrl.notif_fn(&signal_ctxt).await.ok(); log::debug!("{} was changed to {} externally", $name_str, value);
}); concat_idents::concat_idents!(notif_fn = $name, _changed {
let mut lock = ctrl.config.lock().await; ctrl.notif_fn(&signal_ctxt).await.ok();
lock.$name = value; });
lock.write(); let mut lock = ctrl.config.lock().await;
lock.$name = value;
lock.write();
}
} }
}).await; }).await;
}); });
+22 -94
View File
@@ -27,7 +27,7 @@
power_zones: [Keyboard], power_zones: [Keyboard],
), ),
( (
device_name: "FX505D", device_name: "FX505",
product_id: "", product_id: "",
layout_name: "fx505d", layout_name: "fx505d",
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse], basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
@@ -36,25 +36,7 @@
power_zones: [Keyboard], power_zones: [Keyboard],
), ),
( (
device_name: "FX505G", device_name: "FX506",
product_id: "",
layout_name: "fx505d",
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
basic_zones: [],
advanced_type: None,
power_zones: [Keyboard],
),
(
device_name: "FX506H",
product_id: "",
layout_name: "fa506i",
basic_modes: [Static, Breathe, Strobe, Pulse],
basic_zones: [],
advanced_type: None,
power_zones: [Keyboard],
),
(
device_name: "FX506L",
product_id: "", product_id: "",
layout_name: "fa506i", layout_name: "fa506i",
basic_modes: [Static, Breathe, Strobe, Pulse], basic_modes: [Static, Breathe, Strobe, Pulse],
@@ -98,15 +80,6 @@
advanced_type: None, advanced_type: None,
power_zones: [Keyboard], power_zones: [Keyboard],
), ),
(
device_name: "G512LV",
product_id: "",
layout_name: "ga401q",
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
basic_zones: [Key1, Key2, Key3, Key4],
advanced_type: None,
power_zones: [Keyboard],
),
( (
device_name: "G513I", device_name: "G513I",
product_id: "", product_id: "",
@@ -116,6 +89,15 @@
advanced_type: Zoned([ZonedKbLeft, ZonedKbLeftMid, ZonedKbRightMid, ZonedKbRight, LightbarRight, LightbarRightCorner, LightbarRightBottom, LightbarLeftBottom, LightbarLeftCorner, LightbarLeft]), advanced_type: Zoned([ZonedKbLeft, ZonedKbLeftMid, ZonedKbRightMid, ZonedKbRight, LightbarRight, LightbarRightCorner, LightbarRightBottom, LightbarLeftBottom, LightbarLeftCorner, LightbarLeft]),
power_zones: [Keyboard, Lightbar], power_zones: [Keyboard, Lightbar],
), ),
(
device_name: "G513Q",
product_id: "",
layout_name: "g513i-per-key",
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
basic_zones: [],
advanced_type: PerKey,
power_zones: [Keyboard],
),
( (
device_name: "G513QE", device_name: "G513QE",
product_id: "", product_id: "",
@@ -125,24 +107,6 @@
advanced_type: None, advanced_type: None,
power_zones: [Keyboard], power_zones: [Keyboard],
), ),
(
device_name: "G513QM",
product_id: "",
layout_name: "g513i",
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
basic_zones: [],
advanced_type: PerKey,
power_zones: [Keyboard],
),
(
device_name: "G513QR",
product_id: "",
layout_name: "g513i-per-key",
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
basic_zones: [],
advanced_type: PerKey,
power_zones: [Keyboard],
),
( (
device_name: "G513QY", device_name: "G513QY",
product_id: "", product_id: "",
@@ -153,16 +117,7 @@
power_zones: [Keyboard], power_zones: [Keyboard],
), ),
( (
device_name: "G513RC", device_name: "G513R",
product_id: "",
layout_name: "g513i",
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
basic_zones: [],
advanced_type: Zoned([ZonedKbLeft, ZonedKbLeftMid, ZonedKbRightMid, ZonedKbRight, LightbarRight, LightbarRightCorner, LightbarRightBottom, LightbarLeftBottom, LightbarLeftCorner, LightbarLeft]),
power_zones: [Keyboard, Lightbar],
),
(
device_name: "G513RM",
product_id: "", product_id: "",
layout_name: "g513i", layout_name: "g513i",
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse], basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
@@ -188,15 +143,6 @@
advanced_type: PerKey, advanced_type: PerKey,
power_zones: [Keyboard], power_zones: [Keyboard],
), ),
(
device_name: "G531",
product_id: "",
layout_name: "g513i-per-key",
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
basic_zones: [Key1, Key2, Key3, Key4],
advanced_type: PerKey,
power_zones: [Keyboard],
),
( (
device_name: "G531GD", device_name: "G531GD",
product_id: "", product_id: "",
@@ -253,7 +199,7 @@
), ),
( (
device_name: "G533Q", device_name: "G533Q",
product_id: "", product_id: "1866",
layout_name: "g533q-per-key", layout_name: "g533q-per-key",
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash], basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
basic_zones: [], basic_zones: [],
@@ -382,9 +328,9 @@
product_id: "", product_id: "",
layout_name: "ga401q", layout_name: "ga401q",
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse], basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
basic_zones: [Key1, Key2, Key3, Key4], basic_zones: [Key1, Key2, Key3, Key4, BarLeft, BarRight],
advanced_type: None, advanced_type: None,
power_zones: [Keyboard], power_zones: [Keyboard, Lightbar],
), ),
( (
device_name: "G731", device_name: "G731",
@@ -436,9 +382,9 @@
product_id: "", product_id: "",
layout_name: "g513i-per-key", layout_name: "g513i-per-key",
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash], basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
basic_zones: [Logo, BarLeft, BarRight], basic_zones: [],
advanced_type: PerKey, advanced_type: PerKey,
power_zones: [Keyboard], power_zones: [Keyboard, Lightbar, Logo, Lid],
), ),
( (
device_name: "G733PZ", device_name: "G733PZ",
@@ -468,7 +414,7 @@
power_zones: [Keyboard], power_zones: [Keyboard],
), ),
( (
device_name: "G814JI", device_name: "G814J",
product_id: "", product_id: "",
layout_name: "g814ji-per-key", layout_name: "g814ji-per-key",
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash], basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
@@ -477,16 +423,7 @@
power_zones: [Keyboard, Lightbar], power_zones: [Keyboard, Lightbar],
), ),
( (
device_name: "G814JZ", device_name: "G834J",
product_id: "",
layout_name: "g814ji-per-key",
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
basic_zones: [],
advanced_type: PerKey,
power_zones: [Keyboard, Lightbar],
),
(
device_name: "G834JZ",
product_id: "", product_id: "",
layout_name: "g814ji-per-key", layout_name: "g814ji-per-key",
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash], basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
@@ -534,13 +471,13 @@
device_name: "GA402XV", device_name: "GA402XV",
product_id: "", product_id: "",
layout_name: "ga401q", layout_name: "ga401q",
basic_modes: [Static, Breathe, Pulse], basic_modes: [Static, Breathe, Strobe, Comet],
basic_zones: [], basic_zones: [],
advanced_type: None, advanced_type: None,
power_zones: [Keyboard], power_zones: [Keyboard],
), ),
( (
device_name: "GA403UI", device_name: "GA403U",
product_id: "", product_id: "",
layout_name: "ga401q", layout_name: "ga401q",
basic_modes: [Static, Breathe, Pulse], basic_modes: [Static, Breathe, Pulse],
@@ -647,15 +584,6 @@
advanced_type: PerKey, advanced_type: PerKey,
power_zones: [Keyboard], power_zones: [Keyboard],
), ),
(
device_name: "GU502G",
product_id: "",
layout_name: "gx502",
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
basic_zones: [],
advanced_type: PerKey,
power_zones: [Keyboard],
),
( (
device_name: "GU502L", device_name: "GU502L",
product_id: "", product_id: "",
@@ -684,7 +612,7 @@
power_zones: [Keyboard], power_zones: [Keyboard],
), ),
( (
device_name: "GU603VV", device_name: "GU603V",
product_id: "", product_id: "",
layout_name: "ga401q", layout_name: "ga401q",
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse], basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
+6 -12
View File
@@ -81,16 +81,10 @@ impl AuraPowerState {
if self.sleep { if self.sleep {
a |= OldAuraPower::Sleep as u32; a |= OldAuraPower::Sleep as u32;
} }
if matches!( if matches!(self.zone, PowerZones::Keyboard) {
self.zone,
PowerZones::Keyboard | PowerZones::KeyboardAndLightbar
) {
a |= OldAuraPower::Keyboard as u32; a |= OldAuraPower::Keyboard as u32;
} }
if matches!( if matches!(self.zone, PowerZones::Lightbar) {
self.zone,
PowerZones::Lightbar | PowerZones::KeyboardAndLightbar
) {
a |= OldAuraPower::Lightbar as u32; a |= OldAuraPower::Lightbar as u32;
} }
vec![ vec![
@@ -133,7 +127,7 @@ impl AuraPowerState {
| (self.sleep as u32) << (23 + 3) | (self.sleep as u32) << (23 + 3)
| (self.shutdown as u32) << (23 + 4) | (self.shutdown as u32) << (23 + 4)
} }
PowerZones::KeyboardAndLightbar | PowerZones::None => 0, PowerZones::None => 0,
} }
} }
} }
@@ -196,7 +190,7 @@ impl LaptopAuraPower {
AuraDeviceType::LaptopPre2021 => { AuraDeviceType::LaptopPre2021 => {
if support_data.power_zones.contains(&PowerZones::Lightbar) { if support_data.power_zones.contains(&PowerZones::Lightbar) {
Self { Self {
states: vec![AuraPowerState::default_for(PowerZones::KeyboardAndLightbar)], states: vec![AuraPowerState::default_for(PowerZones::Lightbar)],
} }
} else { } else {
Self { Self {
@@ -326,7 +320,7 @@ mod test {
assert_eq!(bytes, [0xc3, 0x12, 0x09, 0x00]); assert_eq!(bytes, [0xc3, 0x12, 0x09, 0x00]);
let power = AuraPowerState { let power = AuraPowerState {
zone: PowerZones::KeyboardAndLightbar, zone: PowerZones::Keyboard,
awake: true, awake: true,
boot: true, boot: true,
sleep: true, sleep: true,
@@ -335,7 +329,7 @@ mod test {
let bytes = power.old_to_bytes(); let bytes = power.old_to_bytes();
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]); println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
assert_eq!(bytes, [0xff, 0x1f, 0x000f, 0x00]); assert_eq!(bytes, [251, 26, 15, 0]);
} }
#[test] #[test]
-2
View File
@@ -126,7 +126,5 @@ pub enum PowerZones {
Lid = 3, Lid = 3,
/// The led strip on the rear of some laptops /// The led strip on the rear of some laptops
RearGlow = 4, RearGlow = 4,
/// On pre-2021 laptops there is either 1 or 2 zones used
KeyboardAndLightbar = 5,
None = 255, None = 255,
} }
+8 -8
View File
@@ -22,8 +22,6 @@ use rog_control_center::{
get_ipc_file, on_tmp_dir_exists, print_versions, MainWindow, QUIT_APP, SHOWING_GUI, SHOW_GUI, get_ipc_file, on_tmp_dir_exists, print_versions, MainWindow, QUIT_APP, SHOWING_GUI, SHOW_GUI,
}; };
use tokio::runtime::Runtime; use tokio::runtime::Runtime;
// use winit::monitor::VideoMode;
// use winit::window::{Fullscreen, WindowLevel};
#[tokio::main] #[tokio::main]
async fn main() -> Result<()> { async fn main() -> Result<()> {
@@ -73,11 +71,6 @@ async fn main() -> Result<()> {
.format_timestamp(None) .format_timestamp(None)
.init(); .init();
// start tokio
let rt = Runtime::new().expect("Unable to create Runtime");
// Enter the runtime so that `tokio::spawn` is available immediately.
let _enter = rt.enter();
let supported_properties = match proxy.supported_properties() { let supported_properties = match proxy.supported_properties() {
Ok(s) => s, Ok(s) => s,
Err(_e) => { Err(_e) => {
@@ -117,7 +110,13 @@ async fn main() -> Result<()> {
let enable_tray_icon = config.enable_tray_icon; let enable_tray_icon = config.enable_tray_icon;
let startup_in_background = config.startup_in_background; let startup_in_background = config.startup_in_background;
let config = Arc::new(Mutex::new(config)); let config = Arc::new(Mutex::new(config));
start_notifications(config.clone())?;
// start tokio
let rt = Runtime::new().expect("Unable to create Runtime");
// Enter the runtime so that `tokio::spawn` is available immediately.
let _enter = rt.enter();
start_notifications(config.clone(), &rt)?;
if enable_tray_icon { if enable_tray_icon {
init_tray(supported_properties, config.clone()); init_tray(supported_properties, config.clone());
} }
@@ -208,6 +207,7 @@ async fn main() -> Result<()> {
}); });
slint::run_event_loop_until_quit().unwrap(); slint::run_event_loop_until_quit().unwrap();
rt.shutdown_background();
Ok(()) Ok(())
} }
+8 -3
View File
@@ -18,6 +18,8 @@ use serde::{Deserialize, Serialize};
use supergfxctl::actions::UserActionRequired as GfxUserAction; use supergfxctl::actions::UserActionRequired as GfxUserAction;
use supergfxctl::pci_device::{GfxMode, GfxPower}; use supergfxctl::pci_device::{GfxMode, GfxPower};
use supergfxctl::zbus_proxy::DaemonProxy as SuperProxy; use supergfxctl::zbus_proxy::DaemonProxy as SuperProxy;
use tokio::runtime::Runtime;
use tokio::task::JoinHandle;
use tokio::time::sleep; use tokio::time::sleep;
use zbus::export::futures_util::StreamExt; use zbus::export::futures_util::StreamExt;
@@ -44,10 +46,13 @@ impl Default for EnabledNotifications {
} }
} }
pub fn start_notifications(config: Arc<Mutex<Config>>) -> Result<()> { pub fn start_notifications(
config: Arc<Mutex<Config>>,
rt: &Runtime,
) -> Result<Vec<JoinHandle<()>>> {
// Setup the AC/BAT commands that will run on power status change // Setup the AC/BAT commands that will run on power status change
let config_copy = config.clone(); let config_copy = config.clone();
tokio::task::spawn_blocking(move || { let blocking = rt.spawn_blocking(move || {
let power = AsusPower::new() let power = AsusPower::new()
.map_err(|e| { .map_err(|e| {
error!("AsusPower: {e}"); error!("AsusPower: {e}");
@@ -217,7 +222,7 @@ pub fn start_notifications(config: Arc<Mutex<Config>>) -> Result<()> {
}; };
}); });
Ok(()) Ok(vec![blocking])
} }
fn convert_gfx_mode(gfx: GfxMode) -> GpuMode { fn convert_gfx_mode(gfx: GfxMode) -> GpuMode {
+1 -3
View File
@@ -63,8 +63,7 @@ impl From<PowerZones> for SlintPowerZones {
PowerZones::Lightbar => SlintPowerZones::Lightbar, PowerZones::Lightbar => SlintPowerZones::Lightbar,
PowerZones::Lid => SlintPowerZones::Lid, PowerZones::Lid => SlintPowerZones::Lid,
PowerZones::RearGlow => SlintPowerZones::RearGlow, PowerZones::RearGlow => SlintPowerZones::RearGlow,
PowerZones::KeyboardAndLightbar => todo!(), PowerZones::None => SlintPowerZones::Keyboard,
PowerZones::None => todo!(),
} }
} }
} }
@@ -77,7 +76,6 @@ impl From<SlintPowerZones> for PowerZones {
SlintPowerZones::Lightbar => PowerZones::Lightbar, SlintPowerZones::Lightbar => PowerZones::Lightbar,
SlintPowerZones::Lid => PowerZones::Lid, SlintPowerZones::Lid => PowerZones::Lid,
SlintPowerZones::RearGlow => PowerZones::RearGlow, SlintPowerZones::RearGlow => PowerZones::RearGlow,
SlintPowerZones::KeyboardAndLightbar => PowerZones::KeyboardAndLightbar,
} }
} }
} }
@@ -2,7 +2,7 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2024-05-08 04:26+0000\n" "POT-Creation-Date: 2024-05-09 22:04+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -422,192 +422,192 @@ msgctxt "AuraPowerGroup"
msgid "Shutdown" msgid "Shutdown"
msgstr "" msgstr ""
#: rog-control-center/ui/types/aura_types.slint:46 #: rog-control-center/ui/types/aura_types.slint:45
msgctxt "Aura power zone" msgctxt "Aura power zone"
msgid "Logo" msgid "Logo"
msgstr "" msgstr ""
#: rog-control-center/ui/types/aura_types.slint:47 #: rog-control-center/ui/types/aura_types.slint:46
msgctxt "Aura power zone" msgctxt "Aura power zone"
msgid "Keyboard" msgid "Keyboard"
msgstr "" msgstr ""
#: rog-control-center/ui/types/aura_types.slint:48 #: rog-control-center/ui/types/aura_types.slint:47
msgctxt "Aura power zone" msgctxt "Aura power zone"
msgid "Lightbar" msgid "Lightbar"
msgstr "" msgstr ""
#: rog-control-center/ui/types/aura_types.slint:49 #: rog-control-center/ui/types/aura_types.slint:48
msgctxt "Aura power zone" msgctxt "Aura power zone"
msgid "Lid" msgid "Lid"
msgstr "" msgstr ""
#: rog-control-center/ui/types/aura_types.slint:50 #: rog-control-center/ui/types/aura_types.slint:49
msgctxt "Aura power zone" msgctxt "Aura power zone"
msgid "Rear Glow" msgid "Rear Glow"
msgstr "" msgstr ""
#: rog-control-center/ui/types/aura_types.slint:51 #: rog-control-center/ui/types/aura_types.slint:50
msgctxt "Aura power zone" msgctxt "Aura power zone"
msgid "Keyboard and Lightbar" msgid "Keyboard and Lightbar"
msgstr "" msgstr ""
#: rog-control-center/ui/types/aura_types.slint:54 #: rog-control-center/ui/types/aura_types.slint:53
msgctxt "Aura brightness" msgctxt "Aura brightness"
msgid "Off" msgid "Off"
msgstr "" msgstr ""
#: rog-control-center/ui/types/aura_types.slint:55 #: rog-control-center/ui/types/aura_types.slint:54
msgctxt "Aura brightness" msgctxt "Aura brightness"
msgid "Low" msgid "Low"
msgstr "" msgstr ""
#: rog-control-center/ui/types/aura_types.slint:56 #: rog-control-center/ui/types/aura_types.slint:55
msgctxt "Aura brightness" msgctxt "Aura brightness"
msgid "Med" msgid "Med"
msgstr "" msgstr ""
#: rog-control-center/ui/types/aura_types.slint:57 #: rog-control-center/ui/types/aura_types.slint:56
msgctxt "Aura brightness" msgctxt "Aura brightness"
msgid "High" msgid "High"
msgstr "" msgstr ""
#: rog-control-center/ui/types/aura_types.slint:62 rog-control-center/ui/types/aura_types.slint:77 #: rog-control-center/ui/types/aura_types.slint:61 rog-control-center/ui/types/aura_types.slint:76
msgctxt "Basic aura mode" msgctxt "Basic aura mode"
msgid "Static" msgid "Static"
msgstr "" msgstr ""
#: rog-control-center/ui/types/aura_types.slint:63 rog-control-center/ui/types/aura_types.slint:78 #: rog-control-center/ui/types/aura_types.slint:62 rog-control-center/ui/types/aura_types.slint:77
msgctxt "Basic aura mode" msgctxt "Basic aura mode"
msgid "Breathe" msgid "Breathe"
msgstr "" msgstr ""
#: rog-control-center/ui/types/aura_types.slint:64 rog-control-center/ui/types/aura_types.slint:79 #: rog-control-center/ui/types/aura_types.slint:63 rog-control-center/ui/types/aura_types.slint:78
msgctxt "Basic aura mode" msgctxt "Basic aura mode"
msgid "Strobe" msgid "Strobe"
msgstr "" msgstr ""
#: rog-control-center/ui/types/aura_types.slint:65 #: rog-control-center/ui/types/aura_types.slint:64
msgctxt "Basic aura mode" msgctxt "Basic aura mode"
msgid "Rainbow" msgid "Rainbow"
msgstr "" msgstr ""
#: rog-control-center/ui/types/aura_types.slint:66 #: rog-control-center/ui/types/aura_types.slint:65
msgctxt "Basic aura mode" msgctxt "Basic aura mode"
msgid "Star" msgid "Star"
msgstr "" msgstr ""
#: rog-control-center/ui/types/aura_types.slint:67 #: rog-control-center/ui/types/aura_types.slint:66
msgctxt "Basic aura mode" msgctxt "Basic aura mode"
msgid "Rain" msgid "Rain"
msgstr "" msgstr ""
#: rog-control-center/ui/types/aura_types.slint:68 #: rog-control-center/ui/types/aura_types.slint:67
msgctxt "Basic aura mode" msgctxt "Basic aura mode"
msgid "Highlight" msgid "Highlight"
msgstr "" msgstr ""
#: rog-control-center/ui/types/aura_types.slint:69 #: rog-control-center/ui/types/aura_types.slint:68
msgctxt "Basic aura mode" msgctxt "Basic aura mode"
msgid "Laser" msgid "Laser"
msgstr "" msgstr ""
#: rog-control-center/ui/types/aura_types.slint:70 #: rog-control-center/ui/types/aura_types.slint:69
msgctxt "Basic aura mode" msgctxt "Basic aura mode"
msgid "Ripple" msgid "Ripple"
msgstr "" msgstr ""
#: rog-control-center/ui/types/aura_types.slint:71 #: rog-control-center/ui/types/aura_types.slint:70
msgctxt "Basic aura mode" msgctxt "Basic aura mode"
msgid "Nothing" msgid "Nothing"
msgstr "" msgstr ""
#: rog-control-center/ui/types/aura_types.slint:72 #: rog-control-center/ui/types/aura_types.slint:71
msgctxt "Basic aura mode" msgctxt "Basic aura mode"
msgid "Pulse" msgid "Pulse"
msgstr "" msgstr ""
#: rog-control-center/ui/types/aura_types.slint:73 #: rog-control-center/ui/types/aura_types.slint:72
msgctxt "Basic aura mode" msgctxt "Basic aura mode"
msgid "Comet" msgid "Comet"
msgstr "" msgstr ""
#: rog-control-center/ui/types/aura_types.slint:74 #: rog-control-center/ui/types/aura_types.slint:73
msgctxt "Basic aura mode" msgctxt "Basic aura mode"
msgid "Flash" msgid "Flash"
msgstr "" msgstr ""
#: rog-control-center/ui/types/aura_types.slint:86 #: rog-control-center/ui/types/aura_types.slint:85
msgctxt "Aura zone" msgctxt "Aura zone"
msgid "None" msgid "None"
msgstr "" msgstr ""
#: rog-control-center/ui/types/aura_types.slint:87 #: rog-control-center/ui/types/aura_types.slint:86
msgctxt "Aura zone" msgctxt "Aura zone"
msgid "Key1" msgid "Key1"
msgstr "" msgstr ""
#: rog-control-center/ui/types/aura_types.slint:88 #: rog-control-center/ui/types/aura_types.slint:87
msgctxt "Aura zone" msgctxt "Aura zone"
msgid "Key2" msgid "Key2"
msgstr "" msgstr ""
#: rog-control-center/ui/types/aura_types.slint:89 #: rog-control-center/ui/types/aura_types.slint:88
msgctxt "Aura zone" msgctxt "Aura zone"
msgid "Key3" msgid "Key3"
msgstr "" msgstr ""
#: rog-control-center/ui/types/aura_types.slint:90 #: rog-control-center/ui/types/aura_types.slint:89
msgctxt "Aura zone" msgctxt "Aura zone"
msgid "Key4" msgid "Key4"
msgstr "" msgstr ""
#: rog-control-center/ui/types/aura_types.slint:91 #: rog-control-center/ui/types/aura_types.slint:90
msgctxt "Aura zone" msgctxt "Aura zone"
msgid "Logo" msgid "Logo"
msgstr "" msgstr ""
#: rog-control-center/ui/types/aura_types.slint:92 #: rog-control-center/ui/types/aura_types.slint:91
msgctxt "Aura zone" msgctxt "Aura zone"
msgid "Lightbar Left" msgid "Lightbar Left"
msgstr "" msgstr ""
#: rog-control-center/ui/types/aura_types.slint:93 #: rog-control-center/ui/types/aura_types.slint:92
msgctxt "Aura zone" msgctxt "Aura zone"
msgid "Lightbar Right" msgid "Lightbar Right"
msgstr "" msgstr ""
#: rog-control-center/ui/types/aura_types.slint:97 #: rog-control-center/ui/types/aura_types.slint:96
msgctxt "Aura direction" msgctxt "Aura direction"
msgid "Right" msgid "Right"
msgstr "" msgstr ""
#: rog-control-center/ui/types/aura_types.slint:98 #: rog-control-center/ui/types/aura_types.slint:97
msgctxt "Aura direction" msgctxt "Aura direction"
msgid "Left" msgid "Left"
msgstr "" msgstr ""
#: rog-control-center/ui/types/aura_types.slint:99 #: rog-control-center/ui/types/aura_types.slint:98
msgctxt "Aura direction" msgctxt "Aura direction"
msgid "Up" msgid "Up"
msgstr "" msgstr ""
#: rog-control-center/ui/types/aura_types.slint:100 #: rog-control-center/ui/types/aura_types.slint:99
msgctxt "Aura direction" msgctxt "Aura direction"
msgid "Down" msgid "Down"
msgstr "" msgstr ""
#: rog-control-center/ui/types/aura_types.slint:104 #: rog-control-center/ui/types/aura_types.slint:103
msgctxt "Aura speed" msgctxt "Aura speed"
msgid "Low" msgid "Low"
msgstr "" msgstr ""
#: rog-control-center/ui/types/aura_types.slint:105 #: rog-control-center/ui/types/aura_types.slint:104
msgctxt "Aura speed" msgctxt "Aura speed"
msgid "Medium" msgid "Medium"
msgstr "" msgstr ""
#: rog-control-center/ui/types/aura_types.slint:106 #: rog-control-center/ui/types/aura_types.slint:105
msgctxt "Aura speed" msgctxt "Aura speed"
msgid "High" msgid "High"
msgstr "" msgstr ""
@@ -25,7 +25,6 @@ export enum PowerZones {
Lightbar, Lightbar,
Lid, Lid,
RearGlow, RearGlow,
KeyboardAndLightbar
} }
export struct AuraPowerState { export struct AuraPowerState {
@@ -6,6 +6,7 @@ export component ColourSlider inherits VerticalLayout {
property <string> hex: "#FF0000"; property <string> hex: "#FF0000";
in-out property <float> c1value <=> c1.value; in-out property <float> c1value <=> c1.value;
in-out property <float> c2value <=> c2.value; in-out property <float> c2value <=> c2.value;
in-out property <float> c3value <=> c3.value;
property <color> base_colour: Colors.red; property <color> base_colour: Colors.red;
in-out property <color> final_colour: Colors.red; in-out property <color> final_colour: Colors.red;
in-out property <brush> colourbox: final_colour; in-out property <brush> colourbox: final_colour;
@@ -53,39 +54,52 @@ export component ColourSlider inherits VerticalLayout {
hsv(350, 1, 1), hsv(350, 1, 1),
hsv(360, 1, 1), hsv(360, 1, 1),
]; ];
property <[color]> base_shade: [ property <[color]> base_saturation: [
blend_lightness(base_colour, 1.0), hsv(base_colour.to-hsv().hue, 1, 1),
blend_lightness(base_colour, 0.9), hsv(base_colour.to-hsv().hue, 0.9, 1),
blend_lightness(base_colour, 0.8), hsv(base_colour.to-hsv().hue, 0.8, 1),
blend_lightness(base_colour, 0.7), hsv(base_colour.to-hsv().hue, 0.7, 1),
blend_lightness(base_colour, 0.6), hsv(base_colour.to-hsv().hue, 0.6, 1),
blend_lightness(base_colour, 0.5), hsv(base_colour.to-hsv().hue, 0.5, 1),
blend_lightness(base_colour, 0.4), hsv(base_colour.to-hsv().hue, 0.4, 1),
blend_lightness(base_colour, 0.3), hsv(base_colour.to-hsv().hue, 0.3, 1),
blend_lightness(base_colour, 0.2), hsv(base_colour.to-hsv().hue, 0.2, 1),
blend_lightness(base_colour, 0.1), hsv(base_colour.to-hsv().hue, 0.1, 1),
blend_lightness(base_colour, 0.0) hsv(base_colour.to-hsv().hue, 0, 1),
]; ];
function blend_lightness(c1: color,f: float) -> color { property <[color]> base_value: [
rgb(c1.red * f, c1.green * f, c1.blue * f) hsv(base_colour.to-hsv().hue, 1, 1),
} hsv(base_colour.to-hsv().hue, 1, 0.9),
// hsv(base_colour.to-hsv().hue, 1, 0.8),
hsv(base_colour.to-hsv().hue, 1, 0.7),
hsv(base_colour.to-hsv().hue, 1, 0.6),
hsv(base_colour.to-hsv().hue, 1, 0.5),
hsv(base_colour.to-hsv().hue, 1, 0.4),
hsv(base_colour.to-hsv().hue, 1, 0.3),
hsv(base_colour.to-hsv().hue, 1, 0.2),
hsv(base_colour.to-hsv().hue, 1, 0.1),
hsv(base_colour.to-hsv().hue, 1, 0),
];
function set_base_colour(){ function set_base_colour(){
root.base_colour = base_colours[c1.value].mix(base_colours[c1.value + 1], c1.value - Math.floor(c1.value)); root.base_colour = hsv(c1.value / base_colours.length * 360, 1, 1);
root.final_colour = blend_lightness(base_colour, ((base_shade.length - c2.value) / base_shade.length)); root.final_colour = hsv(base_colour.to-hsv().hue, ((base_saturation.length - c2.value) / base_saturation.length), ((base_value.length - c3.value) / base_value.length));
root.colourbox = root.final_colour; root.colourbox = root.final_colour;
} }
//
callback external_colour_change(); callback external_colour_change();
external_colour_change => { external_colour_change => {
if (root.final_colour.to-hsv().hue < 0) { if (root.final_colour.to-hsv().hue < 0) {
c1.value = (root.base_colours.length - 1) * ((root.final_colour.to-hsv().hue + 360) / 360); c1.value = root.base_colours.length * (root.final_colour.to-hsv().hue + 360) / 360;
} else { } else {
c1.value = (root.base_colours.length - 1) * (root.final_colour.to-hsv().hue / 360); c1.value = root.base_colours.length * root.final_colour.to-hsv().hue / 360;
} }
c2.value = root.base_shade.length - (root.base_shade.length * root.final_colour.to-hsv().value); // c1.value = root.base_colours.length * 360 / root.final_colour.to-hsv().hue;
c2.value = root.base_saturation.length - root.base_saturation.length * root.final_colour.to-hsv().saturation;
c3.value = root.base_value.length - root.base_value.length * root.final_colour.to-hsv().value;
root.set_base_colour(); root.set_base_colour();
hex = set_hex_from_colour(final_colour);
} }
Rectangle { Rectangle {
height: 32px; height: 32px;
@@ -100,7 +114,7 @@ export component ColourSlider inherits VerticalLayout {
width: parent.width; width: parent.width;
height: parent.height; height: parent.height;
minimum: 0; minimum: 0;
maximum: root.base_colours.length - 1; maximum: root.base_colours.length;
// One less than the array length // One less than the array length
changed => { changed => {
set_base_colour(); set_base_colour();
@@ -118,14 +132,38 @@ export component ColourSlider inherits VerticalLayout {
border-radius: 7px; border-radius: 7px;
border-color: Palette.border; border-color: Palette.border;
// 11 colours // 11 colours
background: !root.enabled ? Palette.alternate-background : @linear-gradient(90deg, base_shade[0], base_shade[1], base_shade[2], base_shade[3], base_shade[4], base_shade[5], base_shade[6], base_shade[7], base_shade[8], base_shade[9], base_shade[10]); background: !root.enabled ? Palette.alternate-background : @linear-gradient(90deg, base_saturation[0], base_saturation[1], base_saturation[2], base_saturation[3], base_saturation[4], base_saturation[5], base_saturation[6], base_saturation[7], base_saturation[8], base_saturation[9], base_saturation[10]);
clip: true; clip: true;
c2 := Slider { c2 := Slider {
enabled <=> root.enabled; enabled <=> root.enabled;
width: parent.width; width: parent.width;
height: parent.height; height: parent.height;
minimum: 0; minimum: 0;
maximum: 11; maximum: root.base_saturation.length;
changed => {
set_base_colour();
hex = set_hex_from_colour(final_colour);
}
released => {
root.released();
}
}
}
Rectangle {
height: 32px;
border-width: 2px;
border-radius: 7px;
border-color: Palette.border;
// 11 colours
background: !root.enabled ? Palette.alternate-background : @linear-gradient(90deg, base_value[0], base_value[1], base_value[2], base_value[3], base_value[4], base_value[5], base_value[6], base_value[7], base_value[8], base_value[9], base_value[10]);
clip: true;
c3 := Slider {
enabled <=> root.enabled;
width: parent.width;
height: parent.height;
minimum: 0;
maximum: root.base_value.length;
changed => { changed => {
set_base_colour(); set_base_colour();
hex = set_hex_from_colour(final_colour); hex = set_hex_from_colour(final_colour);
+6 -3
View File
@@ -5,12 +5,15 @@ use log::{info, warn};
use crate::error::{PlatformError, Result}; use crate::error::{PlatformError, Result};
use crate::{attr_u8, has_attr, set_attr_u8_array, to_device}; use crate::{attr_u8, has_attr, set_attr_u8_array, to_device};
/// The sysfs control for backlight levels. This is only for the 3-step
/// backlight setting, and for TUF laptops. It is not a hard requirement
/// for Aura keyboards
#[derive(Debug, Default, PartialEq, Eq, PartialOrd, Clone)] #[derive(Debug, Default, PartialEq, Eq, PartialOrd, Clone)]
pub struct KeyboardLed { pub struct KeyboardBacklight {
path: PathBuf, path: PathBuf,
} }
impl KeyboardLed { impl KeyboardBacklight {
attr_u8!("brightness", path); attr_u8!("brightness", path);
has_attr!("kbd_rgb_mode" path); has_attr!("kbd_rgb_mode" path);
@@ -59,7 +62,7 @@ impl KeyboardLed {
}); });
} }
Err(PlatformError::MissingFunction( Err(PlatformError::MissingFunction(
"asus::kbd_backlight not found".into(), "KeyboardLed:new(), asus::kbd_backlight not found".into(),
)) ))
} }
} }
+3 -4
View File
@@ -60,13 +60,12 @@ impl AsusPower {
info!("Found a battery"); info!("Found a battery");
if battery.is_none() { if battery.is_none() {
info!("Checking battery attributes"); info!("Checking battery attributes");
if device if let Some(current) =
.attribute_value("charge_control_end_threshold") device.attribute_value("charge_control_end_threshold")
.is_some()
{ {
info!( info!(
"Found battery power at {:?}, matched \ "Found battery power at {:?}, matched \
charge_control_end_threshold", charge_control_end_threshold. Current level: {current:?}",
device.sysname() device.sysname()
); );
battery = Some(device.syspath().to_path_buf()); battery = Some(device.syspath().to_path_buf());