Compare commits

..

29 Commits
4.6.0 ... 4.6.1

Author SHA1 Message Date
Luke D. Jones
bee5508099 Prep new release 2023-04-26 22:00:22 +12:00
Luke D. Jones
c741204200 Prep new release 2023-04-26 21:59:13 +12:00
Luke D. Jones
858c9841a7 Update deps 2023-04-26 21:35:48 +12:00
Luke D. Jones
fdc7d88a70 More tweaks to notifications 2023-04-26 12:49:29 +12:00
Luke D. Jones
da3017bb89 Update supergfx dep 2023-04-26 12:32:26 +12:00
Luke D. Jones
641e762e80 Update deps 2023-04-26 11:24:50 +12:00
Luke D. Jones
25ecfda095 Various tray and notification improvements 2023-04-26 10:57:13 +12:00
Luke D. Jones
31af8f9511 Use egui without wayland feature due to segfault 2023-04-25 14:44:31 +12:00
Luke D. Jones
8db783d9b4 Better handling of supergfx version check, aura config updates 2023-04-25 13:57:07 +12:00
Luke D. Jones
45a354880a Add support for GV604 LEDs 2023-04-25 12:13:20 +12:00
Luke D. Jones
ca1c67e803 Begin fixing up support of basic modes + supergfx 2023-04-25 10:27:09 +12:00
Luke D. Jones
c819fa458a Optimise keyboard detection 2023-04-24 22:23:42 +12:00
Luke D. Jones
869ab90299 Add 0x18c6 keyboard 2023-04-24 20:54:51 +12:00
Luke D. Jones
c40029f5e7 Merge branch 'fluke/18c6-keyboard' 2023-04-24 20:15:11 +12:00
Luke Jones
e864dfb0e7 Merge branch 'feature/persistent-theme' into 'main'
Persistent dark / light mode

See merge request asus-linux/asusctl!160
2023-04-22 21:29:36 +00:00
Filip
476b394add Persistent dark / light mode 2023-04-22 21:29:36 +00:00
Luke D. Jones
4ea5480e66 Add support for GX650P LED modes 2023-04-21 11:01:54 +12:00
Luke Jones
cfc46a2b70 Merge branch 'guv604vi-support' into 'main'
Add led modes for GU604VI

See merge request asus-linux/asusctl!159
2023-04-20 22:32:50 +00:00
bno1
235763a615 Add led modes for GU604V 2023-04-21 00:36:00 +03:00
Luke D. Jones
6e19c16e70 Begin adding 18c6 keyboard support
This keyboard is found in ROG Flow Z13 machines. A kernel patch is also
required for full support.

Addresses #344.
2023-04-19 12:08:30 +12:00
Luke D. Jones
6ea550b6ff Update egui and supergfxctl deps
Requires running with supergfxctl v5.1.0-RC5 if installed
2023-04-19 10:12:14 +12:00
Luke Jones
dd30c8092b Merge branch 'pr-makefile-split' into 'main'
Makefile: split install into install-{program,data}

See merge request asus-linux/asusctl!158
2023-04-10 08:04:40 +00:00
Cole Mickens
2bd751f841 Makefile: split install into install-{program,data} 2023-04-09 18:44:55 -05:00
Luke Jones
7a6aafded7 Merge branch 'fluke/fix-anime-loops' into 'main'
Bugfix: Adjust how sub-llops and part of anime animation handle

See merge request asus-linux/asusctl!157
2023-04-08 03:40:32 +00:00
Luke Jones
940b93a75f Merge branch 'zpl/fix-anime-loops_fix' into 'fluke/fix-anime-loops'
fix: sleep-animation

See merge request asus-linux/asusctl!156
2023-04-04 21:36:48 +00:00
Armas Spann
5c70fec29a fix: sleep-animation 2023-04-04 01:20:25 +02:00
Luke Jones
8ac505e0dd Merge branch 'main' into 'main'
Add support for FX506LH keyboard layout

See merge request asus-linux/asusctl!155
2023-04-03 08:13:07 +00:00
Luke D. Jones
3bdb03b1d8 Bugfix: Adjust how sub-llops and part of anime animation handle
Attempts to address #332
2023-04-03 20:01:06 +12:00
Winfried
4ac4909881 Add support for FX506LH keyboard layout 2023-03-29 15:12:03 +03:00
27 changed files with 1494 additions and 1326 deletions

View File

@@ -5,6 +5,27 @@ 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.6.1]
### Added
- Support for G733Z LED modes
- Support for GU604V LED modes
- Support for GX650P LED modes
- Support for GV604I LED modes
- Support for FX516P LED modes (this laptop still has further issues, will require a patched kernel when patch is ready)
- Add device code for the Z13 ACRNM keyboard (requires kernel patch, in progress)
- Support for GV301VIC LED modes
- Add device code for the plain Z13 keyboard (requires kernel patch, in progress)
- Support for GV301V LED modes
### Changed
- Adjustments to Anime system events thread
- Add "sleep" animetion config options to anime config
- rog-control-center dark/light mode persistency
- Adjustments to keyboard detection
- Better support of using supergfxctl when available (tray icon and menu)
- Check supergfx version before enabling use in tray (require 5.1.0+)
- Update allowed Aura modes on asusd restart if changed
- Set tray icon for dgpu to "On" if in Vfio mode to prevent confusion
- Add support for Logout/Reboot in notification for KDE
## [v4.6.0]
### Added
@@ -44,7 +65,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [v4.5.7]
### Changed
- ROGCC: Don't notify user if changing to same mux mode
-
-
## [v4.5.7]
### Changed
@@ -609,4 +630,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fix small deadlock with awaits
## [1.0.0]
## [1.0.0]

1501
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -2,7 +2,7 @@
members = ["asusctl", "config-traits", "daemon", "daemon-user", "rog-platform", "rog-dbus", "rog-anime", "rog-aura", "rog-profiles", "rog-control-center"]
[workspace.package]
version = "4.6.0"
version = "4.6.1"
[workspace.dependencies]
async-trait = "^0.1"
@@ -35,6 +35,8 @@ pix = "^0.13"
tinybmp = "^0.4.0"
gif = "^0.12.0"
versions = "4.1"
notify-rust = { git = "https://github.com/flukejones/notify-rust.git", default-features = false, features = ["z"] }
[profile.release]

View File

@@ -38,16 +38,18 @@ clean:
distclean:
rm -rf .cargo vendor vendor.tar.xz
install:
install-program:
$(INSTALL_PROGRAM) "./target/release/$(BIN_ROG)" "$(DESTDIR)$(bindir)/$(BIN_ROG)"
$(INSTALL_DATA) "./rog-control-center/data/$(BIN_ROG).desktop" "$(DESTDIR)$(datarootdir)/applications/$(BIN_ROG).desktop"
$(INSTALL_DATA) "./rog-control-center/data/$(BIN_ROG).png" "$(DESTDIR)$(datarootdir)/icons/hicolor/512x512/apps/$(BIN_ROG).png"
cd rog-aura/data/layouts && find . -type f -name "*.ron" -exec $(INSTALL_DATA) "{}" "$(DESTDIR)$(datarootdir)/rog-gui/layouts/{}" \;
$(INSTALL_PROGRAM) "./target/release/$(BIN_C)" "$(DESTDIR)$(bindir)/$(BIN_C)"
$(INSTALL_PROGRAM) "./target/release/$(BIN_D)" "$(DESTDIR)$(bindir)/$(BIN_D)"
$(INSTALL_PROGRAM) "./target/release/$(BIN_U)" "$(DESTDIR)$(bindir)/$(BIN_U)"
install-data:
$(INSTALL_DATA) "./rog-control-center/data/$(BIN_ROG).desktop" "$(DESTDIR)$(datarootdir)/applications/$(BIN_ROG).desktop"
$(INSTALL_DATA) "./rog-control-center/data/$(BIN_ROG).png" "$(DESTDIR)$(datarootdir)/icons/hicolor/512x512/apps/$(BIN_ROG).png"
cd rog-aura/data/layouts && find . -type f -name "*.ron" -exec $(INSTALL_DATA) "{}" "$(DESTDIR)$(datarootdir)/rog-gui/layouts/{}" \;
$(INSTALL_DATA) "./data/$(BIN_D).rules" "$(DESTDIR)$(libdir)/udev/rules.d/99-$(BIN_D).rules"
$(INSTALL_DATA) "./rog-aura/data/$(LEDCFG)" "$(DESTDIR)$(datarootdir)/asusd/$(LEDCFG)"
$(INSTALL_DATA) "./data/$(BIN_D).conf" "$(DESTDIR)$(datarootdir)/dbus-1/system.d/$(BIN_D).conf"
@@ -71,6 +73,8 @@ install:
cd rog-anime/data && find "./anime" -type f -exec $(INSTALL_DATA) "{}" "$(DESTDIR)$(datarootdir)/asusd/{}" \;
install: install-program install-data
uninstall:
rm -f "$(DESTDIR)$(bindir)/$(BIN_ROG)"
rm -r "$(DESTDIR)$(datarootdir)/applications/$(BIN_ROG).desktop"

View File

@@ -10,7 +10,7 @@ use gumdrop::{Opt, Options};
use profiles_cli::{FanCurveCommand, ProfileCommand};
use rog_anime::usb::get_anime_type;
use rog_anime::{AnimTime, AnimeDataBuffer, AnimeDiagonal, AnimeGif, AnimeImage, Vec2};
use rog_aura::usb::{AuraDev1866, AuraDev19b6, AuraDevTuf, AuraDevice, AuraPowerDev};
use rog_aura::usb::{AuraDevRog1, AuraDevRog2, AuraDevTuf, AuraDevice, AuraPowerDev};
use rog_aura::{self, AuraEffect};
use rog_dbus::RogDbusClientBlocking;
use rog_platform::platform::GpuMode;
@@ -157,7 +157,7 @@ fn do_parsed(
{
return false;
}
if supported.keyboard_led.dev_id != AuraDevice::X19B6
if supported.keyboard_led.dev_id != AuraDevice::X19b6
&& command.trim().starts_with("led-pow-2")
{
return false;
@@ -472,10 +472,10 @@ fn handle_led_power_1_do_1866(
dbus: &RogDbusClientBlocking<'_>,
power: &LedPowerCommand1,
) -> Result<(), Box<dyn std::error::Error>> {
let mut enabled: Vec<AuraDev1866> = Vec::new();
let mut disabled: Vec<AuraDev1866> = Vec::new();
let mut enabled: Vec<AuraDevRog1> = Vec::new();
let mut disabled: Vec<AuraDevRog1> = Vec::new();
let mut check = |e: Option<bool>, a: AuraDev1866| {
let mut check = |e: Option<bool>, a: AuraDevRog1| {
if let Some(arg) = e {
if arg {
enabled.push(a);
@@ -485,11 +485,11 @@ fn handle_led_power_1_do_1866(
}
};
check(power.awake, AuraDev1866::Awake);
check(power.boot, AuraDev1866::Boot);
check(power.sleep, AuraDev1866::Sleep);
check(power.keyboard, AuraDev1866::Keyboard);
check(power.lightbar, AuraDev1866::Lightbar);
check(power.awake, AuraDevRog1::Awake);
check(power.boot, AuraDevRog1::Boot);
check(power.sleep, AuraDevRog1::Sleep);
check(power.keyboard, AuraDevRog1::Keyboard);
check(power.lightbar, AuraDevRog1::Lightbar);
let data = AuraPowerDev {
x1866: enabled,
@@ -576,13 +576,13 @@ fn handle_led_power2(
return Ok(());
}
if supported.dev_id != AuraDevice::X19B6 {
if supported.dev_id != AuraDevice::X19b6 {
println!("This option applies only to keyboards with product ID 0x19b6");
}
let mut enabled: Vec<AuraDev19b6> = Vec::new();
let mut disabled: Vec<AuraDev19b6> = Vec::new();
let mut check = |e: Option<bool>, a: AuraDev19b6| {
let mut enabled: Vec<AuraDevRog2> = Vec::new();
let mut disabled: Vec<AuraDevRog2> = Vec::new();
let mut check = |e: Option<bool>, a: AuraDevRog2| {
if let Some(arg) = e {
if arg {
enabled.push(a);
@@ -594,28 +594,28 @@ fn handle_led_power2(
match pow {
aura_cli::SetAuraEnabled::Boot(arg) => {
check(arg.keyboard, AuraDev19b6::BootKeyb);
check(arg.logo, AuraDev19b6::BootLogo);
check(arg.lightbar, AuraDev19b6::BootBar);
check(arg.lid, AuraDev19b6::AwakeLid);
check(arg.keyboard, AuraDevRog2::BootKeyb);
check(arg.logo, AuraDevRog2::BootLogo);
check(arg.lightbar, AuraDevRog2::BootBar);
check(arg.lid, AuraDevRog2::AwakeLid);
}
aura_cli::SetAuraEnabled::Sleep(arg) => {
check(arg.keyboard, AuraDev19b6::SleepKeyb);
check(arg.logo, AuraDev19b6::SleepLogo);
check(arg.lightbar, AuraDev19b6::SleepBar);
check(arg.lid, AuraDev19b6::SleepLid);
check(arg.keyboard, AuraDevRog2::SleepKeyb);
check(arg.logo, AuraDevRog2::SleepLogo);
check(arg.lightbar, AuraDevRog2::SleepBar);
check(arg.lid, AuraDevRog2::SleepLid);
}
aura_cli::SetAuraEnabled::Awake(arg) => {
check(arg.keyboard, AuraDev19b6::AwakeKeyb);
check(arg.logo, AuraDev19b6::AwakeLogo);
check(arg.lightbar, AuraDev19b6::AwakeBar);
check(arg.lid, AuraDev19b6::AwakeLid);
check(arg.keyboard, AuraDevRog2::AwakeKeyb);
check(arg.logo, AuraDevRog2::AwakeLogo);
check(arg.lightbar, AuraDevRog2::AwakeBar);
check(arg.lid, AuraDevRog2::AwakeLid);
}
aura_cli::SetAuraEnabled::Shutdown(arg) => {
check(arg.keyboard, AuraDev19b6::ShutdownKeyb);
check(arg.logo, AuraDev19b6::ShutdownLogo);
check(arg.lightbar, AuraDev19b6::ShutdownBar);
check(arg.lid, AuraDev19b6::ShutdownBar);
check(arg.keyboard, AuraDevRog2::ShutdownKeyb);
check(arg.logo, AuraDevRog2::ShutdownLogo);
check(arg.lightbar, AuraDevRog2::ShutdownBar);
check(arg.lid, AuraDevRog2::ShutdownBar);
}
}

View File

@@ -33,7 +33,12 @@ impl From<AnimeConfigV341> for AnimeConfig {
} else {
vec![]
},
shutdown: if let Some(ani) = c.shutdown {
shutdown: if let Some(ani) = c.shutdown.clone() {
vec![ani]
} else {
vec![]
},
sleep: if let Some(ani) = c.shutdown.clone() {
vec![ani]
} else {
vec![]
@@ -60,6 +65,32 @@ impl From<AnimeConfigV352> for AnimeConfig {
system: c.system,
boot: c.boot,
wake: c.wake,
sleep: c.shutdown.clone(),
shutdown: c.shutdown,
brightness: 1.0,
awake_enabled: true,
boot_anim_enabled: true,
}
}
}
#[derive(Deserialize, Serialize)]
pub struct AnimeConfigV460 {
pub system: Vec<ActionLoader>,
pub boot: Vec<ActionLoader>,
pub wake: Vec<ActionLoader>,
pub sleep: Vec<ActionLoader>,
pub shutdown: Vec<ActionLoader>,
pub brightness: f32,
}
impl From<AnimeConfigV460> for AnimeConfig {
fn from(c: AnimeConfigV460) -> AnimeConfig {
AnimeConfig {
system: c.system,
boot: c.boot,
wake: c.wake,
sleep: c.sleep,
shutdown: c.shutdown,
brightness: 1.0,
awake_enabled: true,
@@ -73,6 +104,7 @@ pub struct AnimeConfigCached {
pub system: Vec<ActionData>,
pub boot: Vec<ActionData>,
pub wake: Vec<ActionData>,
pub sleep: Vec<ActionData>,
pub shutdown: Vec<ActionData>,
}
@@ -100,6 +132,12 @@ impl AnimeConfigCached {
}
self.wake = wake;
let mut sleep = Vec::with_capacity(config.sleep.len());
for ani in &config.sleep {
sleep.push(ActionData::from_anime_action(anime_type, ani)?);
}
self.sleep = sleep;
let mut shutdown = Vec::with_capacity(config.shutdown.len());
for ani in &config.shutdown {
shutdown.push(ActionData::from_anime_action(anime_type, ani)?);
@@ -115,6 +153,7 @@ pub struct AnimeConfig {
pub system: Vec<ActionLoader>,
pub boot: Vec<ActionLoader>,
pub wake: Vec<ActionLoader>,
pub sleep: Vec<ActionLoader>,
pub shutdown: Vec<ActionLoader>,
pub brightness: f32,
pub awake_enabled: bool,
@@ -127,6 +166,7 @@ impl Default for AnimeConfig {
system: Vec::new(),
boot: Vec::new(),
wake: Vec::new(),
sleep: Vec::new(),
shutdown: Vec::new(),
brightness: 1.0,
awake_enabled: true,
@@ -190,6 +230,14 @@ impl AnimeConfig {
Duration::from_secs(2),
)),
}],
sleep: vec![ActionLoader::ImageAnimation {
file: "/usr/share/asusd/anime/custom/sonic-wait.gif".into(),
scale: 0.9,
angle: 0.0,
translation: Vec2::new(3.0, 2.0),
brightness: 1.0,
time: AnimTime::Infinite,
}],
shutdown: vec![ActionLoader::ImageAnimation {
file: "/usr/share/asusd/anime/custom/sonic-wait.gif".into(),
scale: 0.9,

View File

@@ -113,9 +113,8 @@ impl CtrlAnime {
info!("AniMe no previous system thread running (now)");
thread_exit.store(false, Ordering::SeqCst);
thread_running.store(true, Ordering::SeqCst);
'main: loop {
thread_running.store(true, Ordering::SeqCst);
for action in &actions {
if thread_exit.load(Ordering::SeqCst) {
break 'main;
@@ -124,7 +123,7 @@ impl CtrlAnime {
ActionData::Animation(frames) => {
rog_anime::run_animation(frames, &|frame| {
if thread_exit.load(Ordering::Acquire) {
info!("rog-anime: frame-loop was asked to exit");
info!("rog-anime: animation sub-loop was asked to exit");
return Ok(true); // Do safe exit
}
inner
@@ -148,6 +147,10 @@ impl CtrlAnime {
Ok,
)
});
if thread_exit.load(Ordering::Acquire) {
info!("rog-anime: sub-loop exited and main loop exiting now");
break 'main;
}
}
ActionData::Image(image) => {
once = false;

View File

@@ -3,10 +3,10 @@ use std::sync::Arc;
use async_trait::async_trait;
use config_traits::StdConfig;
use log::{info, warn};
use log::warn;
use rog_anime::usb::{pkt_for_apply, pkt_for_set_boot, pkt_for_set_on};
use rog_anime::{AnimeDataBuffer, AnimePowerStates};
use zbus::export::futures_util::lock::{Mutex, MutexGuard};
use zbus::export::futures_util::lock::Mutex;
use zbus::{dbus_interface, Connection, SignalContext};
use super::CtrlAnime;
@@ -149,50 +149,41 @@ 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>>| {
if start {
info!("CtrlAnimeTask running sleep animation");
CtrlAnime::run_thread(inner, lock.cache.shutdown.clone(), true);
} else {
info!("CtrlAnimeTask running wake animation");
CtrlAnime::run_thread(inner, lock.cache.wake.clone(), true);
}
};
let inner1 = self.0.clone();
let inner2 = self.0.clone();
let inner3 = self.0.clone();
let inner4 = self.0.clone();
self.create_sys_event_tasks(
// Loop is required to try an attempt to get the mutex *without* blocking
// other threads - it is possible to end up with deadlocks otherwise.
move || {
// on_sleep
let inner1 = inner1.clone();
async move {
let lock = inner1.lock().await;
run_action(true, lock, inner1.clone());
CtrlAnime::run_thread(inner1.clone(), lock.cache.sleep.clone(), true);
}
},
move || {
// on_wake
let inner2 = inner2.clone();
async move {
let lock = inner2.lock().await;
run_action(true, lock, inner2.clone());
CtrlAnime::run_thread(inner2.clone(), lock.cache.wake.clone(), true);
}
},
move || {
// on_shutdown
let inner3 = inner3.clone();
async move {
let lock = inner3.lock().await;
run_action(true, lock, inner3.clone());
CtrlAnime::run_thread(inner3.clone(), lock.cache.shutdown.clone(), true);
}
},
move || {
// on_boot
let inner4 = inner4.clone();
async move {
let lock = inner4.lock().await;
run_action(true, lock, inner4.clone());
CtrlAnime::run_thread(inner4.clone(), lock.cache.boot.clone(), true);
}
},
)

View File

@@ -1,11 +1,9 @@
use std::collections::{BTreeMap, HashSet};
use config_traits::{StdConfig, StdConfigLoad};
use rog_aura::aura_detection::{LaptopLedData, ASUS_KEYBOARD_DEVICES};
use rog_aura::usb::{AuraDev1866, AuraDev19b6, AuraDevTuf, AuraDevice, AuraPowerDev};
use rog_aura::aura_detection::LaptopLedData;
use rog_aura::usb::{AuraDevRog1, AuraDevRog2, AuraDevTuf, AuraDevice, AuraPowerDev};
use rog_aura::{AuraEffect, AuraModeNum, AuraZone, Direction, LedBrightness, Speed, GRADIENT};
use rog_platform::hid_raw::HidRaw;
use rog_platform::keyboard_led::KeyboardLed;
use serde_derive::{Deserialize, Serialize};
const CONFIG_FILE: &str = "aura.ron";
@@ -16,8 +14,8 @@ const CONFIG_FILE: &str = "aura.ron";
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum AuraPowerConfig {
AuraDevTuf(HashSet<AuraDevTuf>),
AuraDev1866(HashSet<AuraDev1866>),
AuraDev19b6(HashSet<AuraDev19b6>),
AuraDevRog1(HashSet<AuraDevRog1>),
AuraDevRog2(HashSet<AuraDevRog2>),
}
impl AuraPowerConfig {
@@ -25,13 +23,13 @@ impl AuraPowerConfig {
pub fn to_bytes(control: &Self) -> [u8; 3] {
match control {
AuraPowerConfig::AuraDevTuf(_) => [0, 0, 0],
AuraPowerConfig::AuraDev1866(c) => {
let c: Vec<AuraDev1866> = c.iter().copied().collect();
AuraDev1866::to_bytes(&c)
AuraPowerConfig::AuraDevRog1(c) => {
let c: Vec<AuraDevRog1> = c.iter().copied().collect();
AuraDevRog1::to_bytes(&c)
}
AuraPowerConfig::AuraDev19b6(c) => {
let c: Vec<AuraDev19b6> = c.iter().copied().collect();
AuraDev19b6::to_bytes(&c)
AuraPowerConfig::AuraDevRog2(c) => {
let c: Vec<AuraDevRog2> = c.iter().copied().collect();
AuraDevRog2::to_bytes(&c)
}
}
}
@@ -47,13 +45,13 @@ impl AuraPowerConfig {
]);
}
if let Self::AuraDev1866(c) = control {
if let Self::AuraDevRog1(c) = control {
return Some([
true,
c.contains(&AuraDev1866::Boot),
c.contains(&AuraDev1866::Awake),
c.contains(&AuraDev1866::Sleep),
c.contains(&AuraDev1866::Keyboard),
c.contains(&AuraDevRog1::Boot),
c.contains(&AuraDevRog1::Awake),
c.contains(&AuraDevRog1::Sleep),
c.contains(&AuraDevRog1::Keyboard),
]);
}
@@ -70,8 +68,8 @@ impl AuraPowerConfig {
}
}
pub fn set_0x1866(&mut self, power: AuraDev1866, on: bool) {
if let Self::AuraDev1866(p) = self {
pub fn set_0x1866(&mut self, power: AuraDevRog1, on: bool) {
if let Self::AuraDevRog1(p) = self {
if on {
p.insert(power);
} else {
@@ -80,8 +78,8 @@ impl AuraPowerConfig {
}
}
pub fn set_0x19b6(&mut self, power: AuraDev19b6, on: bool) {
if let Self::AuraDev19b6(p) = self {
pub fn set_0x19b6(&mut self, power: AuraDevRog2, on: bool) {
if let Self::AuraDevRog2(p) = self {
if on {
p.insert(power);
} else {
@@ -99,12 +97,12 @@ impl From<&AuraPowerConfig> for AuraPowerDev {
x1866: vec![],
x19b6: vec![],
},
AuraPowerConfig::AuraDev1866(d) => AuraPowerDev {
AuraPowerConfig::AuraDevRog1(d) => AuraPowerDev {
tuf: vec![],
x1866: d.iter().copied().collect(),
x19b6: vec![],
},
AuraPowerConfig::AuraDev19b6(d) => AuraPowerDev {
AuraPowerConfig::AuraDevRog2(d) => AuraPowerDev {
tuf: vec![],
x1866: vec![],
x19b6: d.iter().copied().collect(),
@@ -113,7 +111,7 @@ impl From<&AuraPowerConfig> for AuraPowerDev {
}
}
#[derive(Deserialize, Serialize, Debug)]
#[derive(Deserialize, Serialize, Debug, Clone)]
// #[serde(default)]
pub struct AuraConfig {
pub brightness: LedBrightness,
@@ -124,70 +122,10 @@ pub struct AuraConfig {
pub enabled: AuraPowerConfig,
}
impl Default for AuraConfig {
fn default() -> Self {
let mut prod_id = AuraDevice::Unknown;
for prod in &ASUS_KEYBOARD_DEVICES {
if HidRaw::new(prod).is_ok() {
prod_id = AuraDevice::from(*prod);
break;
}
}
if prod_id == AuraDevice::Unknown {
if let Ok(p) = KeyboardLed::new() {
if p.has_kbd_rgb_mode() {
prod_id = AuraDevice::Tuf;
}
}
}
let enabled = if prod_id == AuraDevice::X19B6 {
AuraPowerConfig::AuraDev19b6(HashSet::from([
AuraDev19b6::BootLogo,
AuraDev19b6::BootKeyb,
AuraDev19b6::SleepLogo,
AuraDev19b6::SleepKeyb,
AuraDev19b6::AwakeLogo,
AuraDev19b6::AwakeKeyb,
AuraDev19b6::ShutdownLogo,
AuraDev19b6::ShutdownKeyb,
AuraDev19b6::BootBar,
AuraDev19b6::AwakeBar,
AuraDev19b6::SleepBar,
AuraDev19b6::ShutdownBar,
]))
} else if prod_id == AuraDevice::Tuf {
AuraPowerConfig::AuraDevTuf(HashSet::from([
AuraDevTuf::Awake,
AuraDevTuf::Boot,
AuraDevTuf::Sleep,
AuraDevTuf::Keyboard,
]))
} else {
AuraPowerConfig::AuraDev1866(HashSet::from([
AuraDev1866::Awake,
AuraDev1866::Boot,
AuraDev1866::Sleep,
AuraDev1866::Keyboard,
AuraDev1866::Lightbar,
]))
};
AuraConfig {
brightness: LedBrightness::Med,
current_mode: AuraModeNum::Static,
builtins: BTreeMap::new(),
multizone: None,
multizone_on: false,
enabled,
}
}
}
impl StdConfig for AuraConfig {
fn new() -> Self {
Self::create_default(&LaptopLedData::get_data())
// Self::create_default(AuraDevice::X19b6, &LaptopLedData::get_data())
panic!("AuraConfig::new() should not be used, use AuraConfig::create_default() instead");
}
fn config_dir() -> std::path::PathBuf {
@@ -202,9 +140,47 @@ impl StdConfig for AuraConfig {
impl StdConfigLoad for AuraConfig {}
impl AuraConfig {
fn create_default(support_data: &LaptopLedData) -> Self {
pub fn create_default(prod_id: AuraDevice, support_data: &LaptopLedData) -> Self {
// create a default config here
let mut config = AuraConfig::default();
let enabled = if prod_id == AuraDevice::X19b6 {
AuraPowerConfig::AuraDevRog2(HashSet::from([
AuraDevRog2::BootLogo,
AuraDevRog2::BootKeyb,
AuraDevRog2::SleepLogo,
AuraDevRog2::SleepKeyb,
AuraDevRog2::AwakeLogo,
AuraDevRog2::AwakeKeyb,
AuraDevRog2::ShutdownLogo,
AuraDevRog2::ShutdownKeyb,
AuraDevRog2::BootBar,
AuraDevRog2::AwakeBar,
AuraDevRog2::SleepBar,
AuraDevRog2::ShutdownBar,
]))
} else if prod_id == AuraDevice::Tuf {
AuraPowerConfig::AuraDevTuf(HashSet::from([
AuraDevTuf::Awake,
AuraDevTuf::Boot,
AuraDevTuf::Sleep,
AuraDevTuf::Keyboard,
]))
} else {
AuraPowerConfig::AuraDevRog1(HashSet::from([
AuraDevRog1::Awake,
AuraDevRog1::Boot,
AuraDevRog1::Sleep,
AuraDevRog1::Keyboard,
AuraDevRog1::Lightbar,
]))
};
let mut config = AuraConfig {
brightness: LedBrightness::Med,
current_mode: AuraModeNum::Static,
builtins: BTreeMap::new(),
multizone: None,
multizone_on: false,
enabled,
};
for n in &support_data.basic_modes {
config
@@ -276,13 +252,15 @@ impl AuraConfig {
#[cfg(test)]
mod tests {
use rog_aura::aura_detection::LaptopLedData;
use rog_aura::usb::AuraDevice;
use rog_aura::{AuraEffect, AuraModeNum, AuraZone, Colour};
use super::AuraConfig;
#[test]
fn set_multizone_4key_config() {
let mut config = AuraConfig::default();
let mut config = AuraConfig::create_default(AuraDevice::X19b6, &LaptopLedData::default());
let effect = AuraEffect {
colour1: Colour(0xff, 0x00, 0xff),
@@ -328,7 +306,7 @@ mod tests {
#[test]
fn set_multizone_multimode_config() {
let mut config = AuraConfig::default();
let mut config = AuraConfig::create_default(AuraDevice::X19b6, &LaptopLedData::default());
let effect = AuraEffect {
zone: AuraZone::Key1,

View File

@@ -1,6 +1,6 @@
use std::collections::BTreeMap;
use config_traits::StdConfig;
use config_traits::{StdConfig, StdConfigLoad};
use log::{info, warn};
use rog_aura::advanced::{LedUsbPackets, UsbPackets};
use rog_aura::aura_detection::{LaptopLedData, ASUS_KEYBOARD_DEVICES};
@@ -25,9 +25,9 @@ impl GetSupported for CtrlKbdLed {
let advanced_type = laptop.advanced_type;
let mut prod_id = AuraDevice::Unknown;
for prod in &ASUS_KEYBOARD_DEVICES {
if HidRaw::new(prod).is_ok() {
prod_id = AuraDevice::from(*prod);
for prod in ASUS_KEYBOARD_DEVICES {
if HidRaw::new(prod.into()).is_ok() {
prod_id = prod;
break;
}
}
@@ -58,7 +58,7 @@ pub enum LEDNode {
pub struct CtrlKbdLed {
// TODO: config stores the keyboard type as an AuraPower, use or update this
pub led_prod: Option<String>,
pub led_prod: AuraDevice,
pub led_node: LEDNode,
pub kd_brightness: KeyboardLed,
pub supported_modes: LaptopLedData,
@@ -68,34 +68,43 @@ pub struct CtrlKbdLed {
}
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 {
match HidRaw::new(prod) {
pub fn new(supported_modes: LaptopLedData) -> Result<Self, RogError> {
let mut led_prod = AuraDevice::Unknown;
let mut usb_node = None;
for prod in ASUS_KEYBOARD_DEVICES {
match HidRaw::new(prod.into()) {
Ok(node) => {
led_prod = Some((*prod).to_owned());
led_node = Some(node);
info!("Looked for keyboard controller 0x{prod}: Found");
led_prod = prod;
usb_node = Some(node);
info!(
"Looked for keyboard controller 0x{}: Found",
<&str>::from(prod)
);
break;
}
Err(err) => info!("Looked for keyboard controller 0x{prod}: {err}"),
Err(err) => info!(
"Looked for keyboard controller 0x{}: {err}",
<&str>::from(prod)
),
}
}
let rgb_led = KeyboardLed::new()?;
if led_node.is_none() && !rgb_led.has_kbd_rgb_mode() {
if usb_node.is_none() && !rgb_led.has_kbd_rgb_mode() {
let dmi = sysfs_class::DmiId::default();
if let Ok(prod_family) = dmi.product_family() {
if prod_family.contains("TUF") {
warn!("A kernel patch is in progress for TUF RGB support");
warn!(
"kbd_rgb_mode was not found in the /sys/. You require a minimum 6.1 \
kernel and a supported TUF laptop"
);
}
}
return Err(RogError::NoAuraKeyboard);
}
let led_node = if let Some(rog) = led_node {
let led_node = if let Some(rog) = usb_node {
info!("Found ROG USB keyboard");
LEDNode::Rog(rog)
} else if rgb_led.has_kbd_rgb_mode() {
@@ -105,9 +114,18 @@ impl CtrlKbdLed {
LEDNode::None
};
let config_init = AuraConfig::create_default(led_prod, &supported_modes);
let mut config = config_init.clone().load();
// Do updates of supported modes if required
for mode in &config_init.builtins {
if !config.builtins.contains_key(mode.0) {
config.builtins.insert(*mode.0, mode.1.clone());
}
}
let ctrl = CtrlKbdLed {
led_prod,
led_node,
led_node, // on TUF this is the same as rgb_led / kd_brightness
kd_brightness: rgb_led, // If was none then we already returned above
supported_modes,
flip_effect_write: false,
@@ -356,6 +374,7 @@ impl CtrlKbdLed {
#[cfg(test)]
mod tests {
use rog_aura::aura_detection::LaptopLedData;
use rog_aura::usb::AuraDevice;
use rog_aura::{AuraEffect, AuraModeNum, AuraZone, Colour};
use rog_platform::keyboard_led::KeyboardLed;
@@ -367,7 +386,7 @@ mod tests {
// #[ignore = "Must be manually run due to detection stage"]
fn check_set_mode_errors() {
// Checking to ensure set_mode errors when unsupported modes are tried
let config = AuraConfig::default();
let config = AuraConfig::create_default(AuraDevice::X19b6, &LaptopLedData::default());
let supported_modes = LaptopLedData {
board_name: String::new(),
layout_name: "ga401".to_owned(),
@@ -376,7 +395,7 @@ mod tests {
advanced_type: rog_aura::AdvancedAuraType::None,
};
let mut controller = CtrlKbdLed {
led_prod: None,
led_prod: AuraDevice::X19b6,
led_node: LEDNode::None,
kd_brightness: KeyboardLed::default(),
supported_modes,
@@ -430,7 +449,7 @@ mod tests {
#[test]
fn create_multizone_if_no_config() {
// Checking to ensure set_mode errors when unsupported modes are tried
let config = AuraConfig::default();
let config = AuraConfig::create_default(AuraDevice::X19b6, &LaptopLedData::default());
let supported_modes = LaptopLedData {
board_name: String::new(),
layout_name: "ga401".to_owned(),
@@ -439,7 +458,7 @@ mod tests {
advanced_type: rog_aura::AdvancedAuraType::None,
};
let mut controller = CtrlKbdLed {
led_prod: None,
led_prod: AuraDevice::X19b6,
led_node: LEDNode::None,
kd_brightness: KeyboardLed::default(),
supported_modes,
@@ -468,7 +487,7 @@ mod tests {
#[test]
fn next_mode_create_multizone_if_no_config() {
// Checking to ensure set_mode errors when unsupported modes are tried
let config = AuraConfig::default();
let config = AuraConfig::create_default(AuraDevice::X19b6, &LaptopLedData::default());
let supported_modes = LaptopLedData {
board_name: String::new(),
layout_name: "ga401".to_owned(),
@@ -477,7 +496,7 @@ mod tests {
advanced_type: rog_aura::AdvancedAuraType::None,
};
let mut controller = CtrlKbdLed {
led_prod: None,
led_prod: AuraDevice::X19b6,
led_node: LEDNode::None,
kd_brightness: KeyboardLed::default(),
supported_modes,

View File

@@ -11,7 +11,6 @@ use daemon::config::Config;
use daemon::ctrl_anime::config::AnimeConfig;
use daemon::ctrl_anime::trait_impls::CtrlAnimeZbus;
use daemon::ctrl_anime::CtrlAnime;
use daemon::ctrl_aura::config::AuraConfig;
use daemon::ctrl_aura::controller::CtrlKbdLed;
use daemon::ctrl_aura::trait_impls::CtrlKbdLedZbus;
use daemon::ctrl_platform::CtrlPlatform;
@@ -124,8 +123,9 @@ async fn start_daemon() -> Result<(), Box<dyn Error>> {
}
let laptop = LaptopLedData::get_data();
let aura_config = AuraConfig::new().load();
match CtrlKbdLed::new(laptop, aura_config) {
// CtrlKbdLed deviates from the config pattern above due to requiring a keyboard
// detection first
match CtrlKbdLed::new(laptop) {
Ok(ctrl) => {
let zbus = CtrlKbdLedZbus(Arc::new(Mutex::new(ctrl)));
let sig_ctx = CtrlKbdLedZbus::signal_context(&connection)?;

View File

@@ -32,7 +32,7 @@ zbus = { workspace = true, optional = true }
sysfs-class = { workspace = true, optional = true }
uhid-virt = "^0.0.5"
uhid-virt = "^0.0.6"
[dev-dependencies]
cargo-husky.workspace = true

View File

@@ -212,7 +212,7 @@ pub fn run_animation(frames: &AnimeGif, callback: &dyn Fn(AnimeDataBuffer) -> Re
// TODO: Log this error
if matches!(callback(output), Ok(true)) {
info!("rog-anime: frame-loop callback asked to exit early");
info!("rog-anime: animation frame-loop callback asked to exit early");
return;
}

View File

@@ -34,6 +34,20 @@
basic_zones: [],
advanced_type: None,
),
(
board_name: "FX506LH",
layout_name: "fa506i",
basic_modes: [Static, Breathe, Strobe, Pulse],
basic_zones: [],
advanced_type: None,
),
(
board_name: "FX516P",
layout_name: "fa506i",
basic_modes: [Static, Breathe, Strobe],
basic_zones: [],
advanced_type: None,
),
(
board_name: "G512",
layout_name: "g512",
@@ -293,6 +307,13 @@
basic_zones: [],
advanced_type: PerKey,
),
(
board_name: "G733Z",
layout_name: "g513i-per-key",
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
basic_zones: [],
advanced_type: PerKey,
),
(
board_name: "GA401Q",
layout_name: "ga401q",
@@ -405,6 +426,13 @@
basic_zones: [],
advanced_type: Zoned([SingleZone]),
),
(
board_name: "GU604V",
layout_name: "ga401q",
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
basic_zones: [],
advanced_type: Zoned([SingleZone]),
),
(
board_name: "GV301Q",
layout_name: "ga401q",
@@ -412,6 +440,20 @@
basic_zones: [],
advanced_type: None,
),
(
board_name: "GV301V",
layout_name: "ga401q",
basic_modes: [Static, Breathe, Pulse],
basic_zones: [],
advanced_type: None,
),
(
board_name: "GV301VIC",
layout_name: "ga401q",
basic_modes: [Static, Breathe, Pulse],
basic_zones: [],
advanced_type: None,
),
(
board_name: "GV601R",
layout_name: "ga401q",
@@ -419,6 +461,13 @@
basic_zones: [],
advanced_type: None,
),
(
board_name: "GV604V",
layout_name: "ga401q",
basic_modes: [Static, Breathe, Strobe, Pulse],
basic_zones: [],
advanced_type: None,
),
(
board_name: "GX502",
layout_name: "gx502",
@@ -447,6 +496,13 @@
basic_zones: [],
advanced_type: PerKey,
),
(
board_name: "GX650P",
layout_name: "gx531-per-key",
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
basic_zones: [],
advanced_type: PerKey,
),
(
board_name: "GX701",
layout_name: "gx531-per-key",
@@ -461,4 +517,18 @@
basic_zones: [],
advanced_type: None,
),
(
board_name: "GZ301V",
layout_name: "ga401q",
basic_modes: [Static, Breathe, Pulse],
basic_zones: [],
advanced_type: None,
),
(
board_name: "GZ301VIC",
layout_name: "ga401q",
basic_modes: [Static, Breathe, Pulse],
basic_zones: [],
advanced_type: None,
),
])

View File

@@ -1,11 +1,20 @@
use log::{error, info, warn};
use serde_derive::{Deserialize, Serialize};
use crate::usb::AuraDevice;
use crate::{AdvancedAuraType, AuraModeNum, AuraZone};
pub const ASUS_LED_MODE_CONF: &str = "/usr/share/asusd/aura_support.ron";
pub const ASUS_LED_MODE_USER_CONF: &str = "/etc/asusd/asusd_user_ledmodes.ron";
pub const ASUS_KEYBOARD_DEVICES: [&str; 4] = ["1866", "1869", "1854", "19b6"];
pub const ASUS_KEYBOARD_DEVICES: [AuraDevice; 7] = [
AuraDevice::Tuf,
AuraDevice::X1854,
AuraDevice::X1869,
AuraDevice::X1866,
AuraDevice::X18c6,
AuraDevice::X19b6,
AuraDevice::X1a30,
];
#[derive(Debug, Default, Clone, PartialEq, Eq, Deserialize, Serialize)]
pub struct LedSupportFile(Vec<LaptopLedData>);

View File

@@ -280,7 +280,13 @@ impl KeyLayout {
/// Find a layout matching the name in `LaptopLedData` in the provided dir
pub fn find_layout(led_data: LaptopLedData, mut data_path: PathBuf) -> Result<Self, Error> {
// TODO: locales
let layout_file = format!("{}_US.ron", led_data.layout_name);
let layout_name = if led_data.layout_name.is_empty() {
"ga401q".to_owned() // Need some sort of default here due to ROGCC
// expecting it
} else {
led_data.layout_name
};
let layout_file = format!("{layout_name}_US.ron");
data_path.push("layouts");
data_path.push(layout_file);
let path = data_path.as_path();

View File

@@ -23,25 +23,44 @@ pub const fn aura_brightness_bytes(brightness: u8) -> [u8; 17] {
}
#[cfg_attr(feature = "dbus", derive(Type))]
#[derive(Clone, PartialEq, Eq, PartialOrd, Serialize, Deserialize, Default)]
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Serialize, Deserialize, Default)]
pub enum AuraDevice {
Tuf,
X1854,
X1869,
X1866,
X18c6,
#[default]
X19B6,
X19b6,
X1a30,
Unknown,
}
impl From<AuraDevice> for &str {
fn from(a: AuraDevice) -> Self {
match a {
AuraDevice::Tuf => "tuf",
AuraDevice::X1854 => "1854",
AuraDevice::X1869 => "1869",
AuraDevice::X1866 => "1866",
AuraDevice::X18c6 => "18c6",
AuraDevice::X19b6 => "19b6",
AuraDevice::X1a30 => "1a30",
AuraDevice::Unknown => "unknown",
}
}
}
impl From<&str> for AuraDevice {
fn from(s: &str) -> Self {
match s.to_lowercase().as_str() {
"tuf" => AuraDevice::Tuf,
"1866" | "0x1866" => AuraDevice::X1866,
"18c6" | "0x18c6" => AuraDevice::X18c6,
"1869" | "0x1869" => AuraDevice::X1869,
"1854" | "0x1854" => AuraDevice::X1854,
"19b6" | "0x19b6" => AuraDevice::X19B6,
"19b6" | "0x19b6" => AuraDevice::X19b6,
"1a30" | "0x1a30" => AuraDevice::X1a30,
_ => AuraDevice::Unknown,
}
}
@@ -54,7 +73,9 @@ impl Debug for AuraDevice {
Self::X1854 => write!(f, "0x1854"),
Self::X1869 => write!(f, "0x1869"),
Self::X1866 => write!(f, "0x1866"),
Self::X19B6 => write!(f, "0x19B6"),
Self::X18c6 => write!(f, "0x18c6"),
Self::X19b6 => write!(f, "0x19B6"),
Self::X1a30 => write!(f, "0x1A30"),
Self::Unknown => write!(f, "Unknown"),
}
}
@@ -65,8 +86,8 @@ impl Debug for AuraDevice {
#[derive(Clone, Default, Debug, Serialize, Deserialize)]
pub struct AuraPowerDev {
pub tuf: Vec<AuraDevTuf>,
pub x1866: Vec<AuraDev1866>,
pub x19b6: Vec<AuraDev19b6>,
pub x1866: Vec<AuraDevRog1>,
pub x19b6: Vec<AuraDevRog2>,
}
#[cfg_attr(feature = "dbus", derive(Type))]
@@ -85,7 +106,7 @@ impl AuraDevTuf {
}
}
/// # Bits for older 0x1866 keyboard model
/// # Bits for older 0x1866, 0x1869, 0x1854 keyboard models
///
/// Keybord and Lightbar require Awake, Boot and Sleep apply to both
/// Keybord and Lightbar regardless of if either are enabled (or Awake is
@@ -102,7 +123,7 @@ impl AuraDevTuf {
#[cfg_attr(feature = "dbus", derive(Type))]
#[derive(Clone, Copy, Debug, PartialEq, PartialOrd, Eq, Ord, Hash, Serialize, Deserialize)]
#[repr(u32)]
pub enum AuraDev1866 {
pub enum AuraDevRog1 {
Awake = 0x000002,
Keyboard = 0x080000,
Lightbar = 0x040500,
@@ -110,13 +131,13 @@ pub enum AuraDev1866 {
Sleep = 0x300804,
}
impl From<AuraDev1866> for u32 {
fn from(a: AuraDev1866) -> Self {
impl From<AuraDevRog1> for u32 {
fn from(a: AuraDevRog1) -> Self {
a as u32
}
}
impl AuraDev1866 {
impl AuraDevRog1 {
pub fn to_bytes(control: &[Self]) -> [u8; 3] {
let mut a: u32 = 0;
for n in control {
@@ -134,23 +155,23 @@ impl AuraDev1866 {
}
}
impl BitOr<AuraDev1866> for AuraDev1866 {
impl BitOr<AuraDevRog1> for AuraDevRog1 {
type Output = u32;
fn bitor(self, rhs: AuraDev1866) -> Self::Output {
fn bitor(self, rhs: AuraDevRog1) -> Self::Output {
self as u32 | rhs as u32
}
}
impl BitAnd<AuraDev1866> for AuraDev1866 {
impl BitAnd<AuraDevRog1> for AuraDevRog1 {
type Output = u32;
fn bitand(self, rhs: AuraDev1866) -> Self::Output {
fn bitand(self, rhs: AuraDevRog1) -> Self::Output {
self as u32 & rhs as u32
}
}
/// # Bits for 0x19b6 keyboard model
/// # Bits for newer 0x18c6, 0x19B6, 0x1a30, keyboard models
///
/// byte 4 in the USB packet is for keyboard + logo power states
/// default is on, `ff`
@@ -179,7 +200,7 @@ impl BitAnd<AuraDev1866> for AuraDev1866 {
#[cfg_attr(feature = "dbus", derive(Type))]
#[derive(Clone, Copy, Debug, PartialEq, PartialOrd, Eq, Ord, Hash, Serialize, Deserialize)]
#[repr(u32)]
pub enum AuraDev19b6 {
pub enum AuraDevRog2 {
BootLogo = 1,
BootKeyb = 1 << 1,
AwakeLogo = 1 << 2,
@@ -198,13 +219,13 @@ pub enum AuraDev19b6 {
ShutdownLid = 1 << (15 + 4),
}
impl From<AuraDev19b6> for u32 {
fn from(a: AuraDev19b6) -> Self {
impl From<AuraDevRog2> for u32 {
fn from(a: AuraDevRog2) -> Self {
a as u32
}
}
impl AuraDev19b6 {
impl AuraDevRog2 {
pub fn to_bytes(control: &[Self]) -> [u8; 3] {
let mut a: u32 = 0;
for n in control {
@@ -222,58 +243,58 @@ impl AuraDev19b6 {
}
}
impl BitOr<AuraDev19b6> for AuraDev19b6 {
impl BitOr<AuraDevRog2> for AuraDevRog2 {
type Output = u16;
fn bitor(self, rhs: AuraDev19b6) -> Self::Output {
fn bitor(self, rhs: AuraDevRog2) -> Self::Output {
self as u16 | rhs as u16
}
}
impl BitAnd<AuraDev19b6> for AuraDev19b6 {
impl BitAnd<AuraDevRog2> for AuraDevRog2 {
type Output = u16;
fn bitand(self, rhs: AuraDev19b6) -> Self::Output {
fn bitand(self, rhs: AuraDevRog2) -> Self::Output {
self as u16 & rhs as u16
}
}
#[cfg(test)]
mod tests {
use super::AuraDev1866;
use crate::usb::AuraDev19b6;
use super::AuraDevRog1;
use crate::usb::AuraDevRog2;
#[test]
fn check_0x1866_control_bytes() {
let bytes = [AuraDev1866::Keyboard, AuraDev1866::Awake];
let bytes = AuraDev1866::to_bytes(&bytes);
let bytes = [AuraDevRog1::Keyboard, AuraDevRog1::Awake];
let bytes = AuraDevRog1::to_bytes(&bytes);
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
assert_eq!(bytes, [0x08, 0x00, 0x02]);
let bytes = [AuraDev1866::Lightbar, AuraDev1866::Awake];
let bytes = AuraDev1866::to_bytes(&bytes);
let bytes = [AuraDevRog1::Lightbar, AuraDevRog1::Awake];
let bytes = AuraDevRog1::to_bytes(&bytes);
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
assert_eq!(bytes, [0x04, 0x05, 0x02]);
let bytes = [AuraDev1866::Sleep];
let bytes = AuraDev1866::to_bytes(&bytes);
let bytes = [AuraDevRog1::Sleep];
let bytes = AuraDevRog1::to_bytes(&bytes);
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
assert_eq!(bytes, [0x30, 0x08, 0x04]);
let bytes = [AuraDev1866::Boot];
let bytes = AuraDev1866::to_bytes(&bytes);
let bytes = [AuraDevRog1::Boot];
let bytes = AuraDevRog1::to_bytes(&bytes);
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
assert_eq!(bytes, [0xc3, 0x12, 0x09]);
let bytes = [
AuraDev1866::Keyboard,
AuraDev1866::Lightbar,
AuraDev1866::Awake,
AuraDev1866::Sleep,
AuraDev1866::Boot,
AuraDevRog1::Keyboard,
AuraDevRog1::Lightbar,
AuraDevRog1::Awake,
AuraDevRog1::Sleep,
AuraDevRog1::Boot,
];
let bytes = AuraDev1866::to_bytes(&bytes);
let bytes = AuraDevRog1::to_bytes(&bytes);
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
assert_eq!(bytes, [0xff, 0x1f, 0x000f]);
}
@@ -282,143 +303,143 @@ mod tests {
fn check_0x19b6_control_bytes() {
// All on
let byte1 = [
AuraDev19b6::BootLogo,
AuraDev19b6::BootKeyb,
AuraDev19b6::SleepLogo,
AuraDev19b6::SleepKeyb,
AuraDev19b6::AwakeLogo,
AuraDev19b6::AwakeKeyb,
AuraDev19b6::ShutdownLogo,
AuraDev19b6::ShutdownKeyb,
AuraDevRog2::BootLogo,
AuraDevRog2::BootKeyb,
AuraDevRog2::SleepLogo,
AuraDevRog2::SleepKeyb,
AuraDevRog2::AwakeLogo,
AuraDevRog2::AwakeKeyb,
AuraDevRog2::ShutdownLogo,
AuraDevRog2::ShutdownKeyb,
];
let bytes = AuraDev19b6::to_bytes(&byte1);
let bytes = AuraDevRog2::to_bytes(&byte1);
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
assert_eq!(bytes[0], 0xff);
//
let byte1 = [
// AuraControl::BootLogo,
AuraDev19b6::BootKeyb,
AuraDev19b6::SleepLogo,
AuraDev19b6::SleepKeyb,
AuraDev19b6::AwakeLogo,
AuraDev19b6::AwakeKeyb,
AuraDev19b6::ShutdownLogo,
AuraDev19b6::ShutdownKeyb,
AuraDevRog2::BootKeyb,
AuraDevRog2::SleepLogo,
AuraDevRog2::SleepKeyb,
AuraDevRog2::AwakeLogo,
AuraDevRog2::AwakeKeyb,
AuraDevRog2::ShutdownLogo,
AuraDevRog2::ShutdownKeyb,
];
let bytes = AuraDev19b6::to_bytes(&byte1);
let bytes = AuraDevRog2::to_bytes(&byte1);
println!("{:08b}", bytes[0]);
assert_eq!(bytes[0], 0xfe);
let byte1 = [
AuraDev19b6::BootLogo,
AuraDevRog2::BootLogo,
// AuraControl::BootKeyb,
AuraDev19b6::SleepLogo,
AuraDev19b6::SleepKeyb,
AuraDev19b6::AwakeLogo,
AuraDev19b6::AwakeKeyb,
AuraDev19b6::ShutdownLogo,
AuraDev19b6::ShutdownKeyb,
AuraDevRog2::SleepLogo,
AuraDevRog2::SleepKeyb,
AuraDevRog2::AwakeLogo,
AuraDevRog2::AwakeKeyb,
AuraDevRog2::ShutdownLogo,
AuraDevRog2::ShutdownKeyb,
];
let bytes = AuraDev19b6::to_bytes(&byte1);
let bytes = AuraDevRog2::to_bytes(&byte1);
println!("{:08b}", bytes[0]);
assert_eq!(bytes[0], 0xfd);
let byte1 = [
AuraDev19b6::BootLogo,
AuraDev19b6::BootKeyb,
AuraDevRog2::BootLogo,
AuraDevRog2::BootKeyb,
// AuraControl::SleepLogo,
AuraDev19b6::SleepKeyb,
AuraDev19b6::AwakeLogo,
AuraDev19b6::AwakeKeyb,
AuraDev19b6::ShutdownLogo,
AuraDev19b6::ShutdownKeyb,
AuraDevRog2::SleepKeyb,
AuraDevRog2::AwakeLogo,
AuraDevRog2::AwakeKeyb,
AuraDevRog2::ShutdownLogo,
AuraDevRog2::ShutdownKeyb,
];
let bytes = AuraDev19b6::to_bytes(&byte1);
let bytes = AuraDevRog2::to_bytes(&byte1);
println!("{:08b}", bytes[0]);
assert_eq!(bytes[0], 0xef);
let byte1 = [
AuraDev19b6::BootLogo,
AuraDev19b6::BootKeyb,
AuraDev19b6::SleepLogo,
AuraDevRog2::BootLogo,
AuraDevRog2::BootKeyb,
AuraDevRog2::SleepLogo,
// AuraControl::SleepKeyb,
AuraDev19b6::AwakeLogo,
AuraDev19b6::AwakeKeyb,
AuraDev19b6::ShutdownLogo,
AuraDev19b6::ShutdownKeyb,
AuraDevRog2::AwakeLogo,
AuraDevRog2::AwakeKeyb,
AuraDevRog2::ShutdownLogo,
AuraDevRog2::ShutdownKeyb,
];
let bytes = AuraDev19b6::to_bytes(&byte1);
let bytes = AuraDevRog2::to_bytes(&byte1);
println!("{:08b}", bytes[0]);
assert_eq!(bytes[0], 0xdf);
let byte2 = [
AuraDev19b6::BootBar,
AuraDev19b6::AwakeBar,
AuraDev19b6::SleepBar,
AuraDev19b6::ShutdownBar,
AuraDevRog2::BootBar,
AuraDevRog2::AwakeBar,
AuraDevRog2::SleepBar,
AuraDevRog2::ShutdownBar,
];
let bytes = AuraDev19b6::to_bytes(&byte2);
let bytes = AuraDevRog2::to_bytes(&byte2);
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
assert_eq!(bytes[1], 0x1e);
let byte2 = [
AuraDev19b6::BootBar,
AuraDev19b6::AwakeBar,
AuraDevRog2::BootBar,
AuraDevRog2::AwakeBar,
// AuraControl::SleepBar,
AuraDev19b6::ShutdownBar,
AuraDevRog2::ShutdownBar,
];
let bytes = AuraDev19b6::to_bytes(&byte2);
let bytes = AuraDevRog2::to_bytes(&byte2);
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
assert_eq!(bytes[1], 0x16);
let byte3 = [
AuraDev19b6::AwakeLid,
AuraDev19b6::BootLid,
AuraDev19b6::SleepLid,
AuraDev19b6::ShutdownLid,
AuraDevRog2::AwakeLid,
AuraDevRog2::BootLid,
AuraDevRog2::SleepLid,
AuraDevRog2::ShutdownLid,
];
let bytes = AuraDev19b6::to_bytes(&byte3);
let bytes = AuraDevRog2::to_bytes(&byte3);
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
assert_eq!(bytes[2], 0x0f);
let byte3 = [
// AuraDev19b6::AwakeLid,
AuraDev19b6::BootLid,
AuraDev19b6::SleepLid,
AuraDev19b6::ShutdownLid,
AuraDevRog2::BootLid,
AuraDevRog2::SleepLid,
AuraDevRog2::ShutdownLid,
];
let bytes = AuraDev19b6::to_bytes(&byte3);
let bytes = AuraDevRog2::to_bytes(&byte3);
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
assert_eq!(bytes[2], 0x0d);
let byte3 = [
AuraDev19b6::AwakeLid,
AuraDev19b6::BootLid,
AuraDevRog2::AwakeLid,
AuraDevRog2::BootLid,
// AuraControl::SleepLid,
AuraDev19b6::ShutdownLid,
AuraDevRog2::ShutdownLid,
];
let bytes = AuraDev19b6::to_bytes(&byte3);
let bytes = AuraDevRog2::to_bytes(&byte3);
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
assert_eq!(bytes[2], 0x0b);
let byte3 = [
AuraDev19b6::AwakeLid,
AuraDev19b6::BootLid,
AuraDev19b6::SleepLid,
AuraDevRog2::AwakeLid,
AuraDevRog2::BootLid,
AuraDevRog2::SleepLid,
// AuraDev19b6::ShutdownLid,
];
let bytes = AuraDev19b6::to_bytes(&byte3);
let bytes = AuraDevRog2::to_bytes(&byte3);
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
assert_eq!(bytes[2], 0x07);
let byte3 = [
AuraDev19b6::AwakeLid,
AuraDevRog2::AwakeLid,
// AuraDev19b6::BootLid,
AuraDev19b6::SleepLid,
AuraDevRog2::SleepLid,
// AuraDev19b6::ShutdownLid,
];
let bytes = AuraDev19b6::to_bytes(&byte3);
let bytes = AuraDevRog2::to_bytes(&byte3);
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
assert_eq!(bytes[2], 0x06);
}

View File

@@ -10,11 +10,13 @@ edition = "2021"
mocking = []
[dependencies]
egui = { git = "https://github.com/flukejones/egui", branch = "wayland_dark_theme" }
eframe = { git = "https://github.com/flukejones/egui", branch = "wayland_dark_theme" }
egui = { git = "https://github.com/emilk/egui", rev = "b8e798777de519de3a1878798097ab2ab0bd4def"}
eframe = { git = "https://github.com/emilk/egui", rev = "b8e798777de519de3a1878798097ab2ab0bd4def"}
# egui = { path = "../../egui/crates/egui" }
# eframe = { path = "../../egui/crates/eframe" }
libappindicator = "0.7" # Tray icon
gtk = "0.15.5"
libappindicator = "0.8" # Tray icon
gtk = "0.16"
daemon = { path = "../daemon" }
rog_anime = { path = "../rog-anime" }
@@ -39,8 +41,14 @@ notify-rust.workspace = true
png_pong.workspace = true
versions.workspace = true
nix = "^0.26.1"
tempfile = "3.3.0"
# [patch.crates-io]
# egui = { git = "https://github.com/flukejones/egui" }
# eframe = { git = "https://github.com/flukejones/egui" }
[dev-dependencies]
cargo-husky.workspace = true

View File

@@ -17,6 +17,7 @@ pub struct Config {
pub ac_command: String,
pub bat_command: String,
pub enable_notifications: bool,
pub dark_mode: bool,
// This field must be last
pub enabled_notifications: EnabledNotifications,
}
@@ -27,6 +28,7 @@ impl Default for Config {
run_in_background: true,
startup_in_background: false,
enable_notifications: true,
dark_mode: true,
enabled_notifications: EnabledNotifications::default(),
ac_command: String::new(),
bat_command: String::new(),
@@ -72,6 +74,9 @@ impl Config {
} else if let Ok(data) = toml::from_str::<Config>(&buf) {
info!("Loaded config file {path:?}");
return Ok(data);
} else if let Ok(data) = toml::from_str::<Config460>(&buf) {
info!("Loaded old v4.6.0 config file {path:?}");
return Ok(data.into());
} else if let Ok(data) = toml::from_str::<Config455>(&buf) {
info!("Loaded old v4.5.5 config file {path:?}");
return Ok(data.into());
@@ -124,8 +129,33 @@ impl From<Config455> for Config {
startup_in_background: c.startup_in_background,
enable_notifications: c.enable_notifications,
enabled_notifications: c.enabled_notifications,
dark_mode: true,
ac_command: String::new(),
bat_command: String::new(),
}
}
}
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct Config460 {
pub run_in_background: bool,
pub startup_in_background: bool,
pub ac_command: String,
pub bat_command: String,
pub enable_notifications: bool,
pub enabled_notifications: EnabledNotifications,
}
impl From<Config460> for Config {
fn from(c: Config460) -> Self {
Self {
run_in_background: c.run_in_background,
startup_in_background: c.startup_in_background,
ac_command: c.ac_command,
bat_command: c.bat_command,
dark_mode: true,
enable_notifications: c.enable_notifications,
enabled_notifications: c.enabled_notifications,
}
}
}

View File

@@ -11,6 +11,7 @@ pub enum Error {
XdgVars,
Zbus(zbus::Error),
Notification(notify_rust::error::Error),
Eframe(eframe::Error),
}
impl fmt::Display for Error {
@@ -24,6 +25,7 @@ impl fmt::Display for Error {
Error::XdgVars => write!(f, "XDG environment vars appear unset"),
Error::Zbus(err) => write!(f, "Error: {}", err),
Error::Notification(err) => write!(f, "Notification Error: {}", err),
Error::Eframe(err) => write!(f, "Eframe Error: {}", err),
}
}
}
@@ -53,3 +55,9 @@ impl From<notify_rust::error::Error> for Error {
Error::Notification(err)
}
}
impl From<eframe::Error> for Error {
fn from(err: eframe::Error) -> Self {
Error::Eframe(err)
}
}

View File

@@ -105,6 +105,6 @@ pub fn get_ipc_file() -> Result<File, crate::error::Error> {
Ok(OpenOptions::new()
.read(true)
.write(true)
.truncate(true)
// .truncate(true)
.open(&fifo_path)?)
}

View File

@@ -1,11 +1,14 @@
use std::env::args;
use std::io::{Read, Write};
use std::path::{Path, PathBuf};
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, Mutex};
use std::thread;
use std::time::Duration;
use eframe::{IconData, NativeOptions};
use gumdrop::Options;
use log::{error, info, warn};
use log::{error, info, warn, LevelFilter};
use rog_aura::aura_detection::{LaptopLedData, LedSupportFile};
use rog_aura::layouts::KeyLayout;
use rog_control_center::cli_options::CliStart;
@@ -45,6 +48,7 @@ fn main() -> Result<()> {
let mut logger = env_logger::Builder::new();
logger
.filter_level(LevelFilter::Warn)
.parse_default_env()
.target(env_logger::Target::Stdout)
.format(|buf, record| writeln!(buf, "{}: {}", record.level(), record.args()))
@@ -72,7 +76,9 @@ fn main() -> Result<()> {
"ROG Control Center",
native_options.clone(),
Box::new(move |_| Box::new(AppErrorShow::new(e.to_string()))),
);
)
.map_err(|e| error!("{e}"))
.ok();
})
.unwrap();
@@ -83,14 +89,16 @@ fn main() -> Result<()> {
"ROG Control Center",
native_options.clone(),
Box::new(move |_| Box::new(AppErrorShow::new(e.to_string()))),
);
)
.map_err(|e| error!("{e}"))
.ok();
SupportedFunctions::default()
}
};
// Startup
let mut config = Config::load()?;
let mut start_closed = config.startup_in_background;
let running_in_bg = Arc::new(AtomicBool::new(config.startup_in_background));
if config.startup_in_background {
config.run_in_background = true;
@@ -184,7 +192,8 @@ fn main() -> Result<()> {
init_tray(supported, states.clone());
loop {
if !start_closed {
if !running_in_bg.load(Ordering::Acquire) {
// blocks until window is closed
start_app(states.clone(), native_options.clone())?;
}
@@ -194,15 +203,21 @@ fn main() -> Result<()> {
break;
}
if config.run_in_background {
let mut buf = [0u8; 4];
// blocks until it is read, typically the read will happen after a second
// process writes to the IPC (so there is data to actually read)
if get_ipc_file()?.read(&mut buf).is_ok() && buf[0] == SHOW_GUI {
start_closed = false;
continue;
}
if config.run_in_background && !running_in_bg.load(Ordering::Acquire) {
running_in_bg.store(true, Ordering::SeqCst);
let running_in_bg = running_in_bg.clone();
thread::spawn(move || {
let mut buf = [0u8; 4];
// blocks until it is read, typically the read will happen after a second
// process writes to the IPC (so there is data to actually read)
if get_ipc_file().unwrap().read(&mut buf).is_ok() && buf[0] == SHOW_GUI {
running_in_bg.store(false, Ordering::SeqCst);
}
});
}
// Prevent hogging CPU
thread::sleep(Duration::from_millis(500));
}
// loop {
@@ -240,7 +255,7 @@ fn start_app(states: Arc<Mutex<SystemState>>, native_options: NativeOptions) ->
"ROG Control Center",
native_options,
Box::new(move |cc| Box::new(RogApp::new(Config::load().unwrap(), states, cc).unwrap())),
);
)?;
Ok(())
}

View File

@@ -2,7 +2,6 @@
//! commands over an MPSC channel.
use std::io::Write;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::mpsc::{channel, Receiver};
use std::sync::{Arc, Mutex};
use std::time::Duration;
@@ -14,8 +13,10 @@ use log::{debug, error, info, trace, warn};
use rog_dbus::zbus_platform::RogBiosProxyBlocking;
use rog_platform::platform::GpuMode;
use rog_platform::supported::SupportedFunctions;
use supergfxctl::actions::UserActionRequired as GfxUserActionRequired;
use supergfxctl::pci_device::{GfxMode, GfxPower};
use supergfxctl::zbus_proxy::DaemonProxyBlocking as GfxProxyBlocking;
use versions::Versioning;
use crate::error::Result;
use crate::system_state::SystemState;
@@ -79,6 +80,8 @@ pub struct ROGTray {
menu: gtk::Menu,
icon: &'static str,
bios_proxy: RogBiosProxyBlocking<'static>,
gfx_proxy_is_active: bool,
gfx_action: Arc<Mutex<GfxUserActionRequired>>,
gfx_proxy: GfxProxyBlocking<'static>,
}
@@ -88,6 +91,12 @@ impl ROGTray {
error!("ROGTray: {e}");
e
})?;
let gfx_proxy = GfxProxyBlocking::new(&conn).map_err(|e| {
error!("ROGTray: {e}");
e
})?;
let rog_tray = Self {
tray: AppIndicator::new(TRAY_LABEL, TRAY_APP_ICON),
menu: gtk::Menu::new(),
@@ -96,10 +105,9 @@ impl ROGTray {
error!("ROGTray: {e}");
e
})?,
gfx_proxy: GfxProxyBlocking::new(&conn).map_err(|e| {
error!("ROGTray: {e}");
e
})?,
gfx_proxy_is_active: gfx_proxy.mode().is_ok(),
gfx_action: Arc::new(Mutex::new(GfxUserActionRequired::Nothing)),
gfx_proxy,
};
Ok(rog_tray)
}
@@ -238,133 +246,64 @@ impl ROGTray {
}
}
fn menu_add_gpu(&mut self, supported: &SupportedFunctions, current_mode: GfxMode) {
let set_mux_off = Arc::new(AtomicBool::new(false));
fn menu_add_supergfx(&mut self, supported_gfx: &[GfxMode], current_mode: GfxMode) {
if !self.gfx_proxy_is_active {
trace!("menu_add_supergfx: gfx_proxy_is_active is false");
return;
}
let gfx_dbus = self.gfx_proxy.clone();
let set_mux_off1 = set_mux_off.clone();
let gfx_action = self.gfx_action.clone();
let mut gpu_menu = RadioGroup::new("Integrated", move |_| {
let mode = gfx_dbus
.mode()
.map_err(|e| {
error!("ROGTray: mode: {e}");
if current_mode != GfxMode::Integrated {
if let Ok(res) = gfx_dbus.set_mode(&GfxMode::Integrated).map_err(|e| {
error!("ROGTray: srt_mode: {e}");
e
})
.unwrap_or(GfxMode::None);
if mode != GfxMode::Integrated {
gfx_dbus
.set_mode(&GfxMode::Integrated)
.map_err(|e| {
error!("ROGTray: srt_mode: {e}");
e
})
.ok();
}) {
if let Ok(mut lock) = gfx_action.lock() {
*lock = res;
}
}
}
set_mux_off1.store(true, Ordering::Relaxed);
});
let gfx_dbus = self.gfx_proxy.clone();
let set_mux_off1 = set_mux_off.clone();
gpu_menu.add("Hybrid", move |_| {
let mode = gfx_dbus
.mode()
.map_err(|e| {
error!("ROGTray: mode: {e}");
e
})
.unwrap_or(GfxMode::None);
if mode != GfxMode::Hybrid {
gfx_dbus
.set_mode(&GfxMode::Hybrid)
.map_err(|e| {
error!("ROGTray: set_mode: {e}");
e
})
.ok();
}
set_mux_off1.store(true, Ordering::Relaxed);
});
if supported.rog_bios_ctrl.egpu_enable {
let set_mux_off1 = set_mux_off.clone();
let mut func = |menu_mode: GfxMode| {
let gfx_dbus = self.gfx_proxy.clone();
gpu_menu.add("eGPU", move |_| {
let mode = gfx_dbus
.mode()
.map_err(|e| {
error!("ROGTray: mode: {e}");
e
})
.unwrap_or(GfxMode::None);
if mode != GfxMode::Egpu {
gfx_dbus
.set_mode(&GfxMode::Egpu)
.map_err(|e| {
error!("ROGTray: set_mode: {e}");
e
})
.ok();
}
set_mux_off1.store(true, Ordering::Relaxed);
});
}
let mut reboot_required = false;
if supported.rog_bios_ctrl.gpu_mux {
let gfx_dbus = self.bios_proxy.clone();
gpu_menu.add("Ultimate (Reboot required)", move |_| {
let mode = gfx_dbus
.gpu_mux_mode()
.map_err(|e| {
error!("ROGTray: mode: {e}");
e
})
.unwrap_or(GpuMode::Error);
if mode != GpuMode::Discrete {
gfx_dbus
.set_gpu_mux_mode(GpuMode::Discrete)
.map_err(|e| {
error!("ROGTray: set_mode: {e}");
e
})
.ok();
}
});
if set_mux_off.load(Ordering::Relaxed) {
warn!("Selected non-dgpu mode, must set MUX to optimus");
self.bios_proxy
.set_gpu_mux_mode(GpuMode::Optimus)
.map_err(|e| {
let gfx_action = self.gfx_action.clone();
gpu_menu.add(&format!("{menu_mode}"), move |_| {
if current_mode != menu_mode {
if let Ok(res) = gfx_dbus.set_mode(&menu_mode).map_err(|e| {
error!("ROGTray: set_mode: {e}");
e
})
.ok();
}
if let Ok(mode) = self.bios_proxy.gpu_mux_mode() {
// TODO: this is not taking in to account supergfxctl
let mode = match mode {
GpuMode::Discrete => GfxMode::AsusMuxDiscreet,
_ => GfxMode::Hybrid,
};
reboot_required = mode != current_mode;
}
}
let active = match current_mode {
GfxMode::AsusMuxDiscreet => "Discreet".to_owned(),
_ => current_mode.to_string(),
}) {
if let Ok(mut lock) = gfx_action.lock() {
*lock = res;
}
}
}
});
};
let reboot_required = if reboot_required {
"(Reboot required)"
for item in supported_gfx {
if *item == GfxMode::Integrated {
continue;
}
func(*item);
}
let action_required = if let Ok(lock) = self.gfx_action.lock() {
if matches!(*lock, GfxUserActionRequired::Nothing) {
""
} else {
<&str>::from(*lock)
}
} else {
""
};
self.add_radio_sub_menu(
&format!("GPU Mode: {active} {reboot_required}"),
active.as_str(),
&format!("GPU Mode: {current_mode} {action_required}"),
&current_mode.to_string(),
&gpu_menu,
);
@@ -377,7 +316,7 @@ impl ROGTray {
let mut reboot_required = false;
if let Ok(mode) = gfx_dbus.gpu_mux_mode() {
let mode = match mode {
GpuMode::Discrete => GfxMode::AsusMuxDiscreet,
GpuMode::Discrete => GfxMode::AsusMuxDgpu,
_ => GfxMode::Hybrid,
};
reboot_required = mode != current_mode;
@@ -407,7 +346,7 @@ impl ROGTray {
});
let active = match current_mode {
GfxMode::AsusMuxDiscreet => "Ultimate".to_owned(),
GfxMode::AsusMuxDgpu => "Ultimate".to_owned(),
GfxMode::Hybrid => "Optimus".to_owned(),
_ => current_mode.to_string(),
};
@@ -442,7 +381,7 @@ impl ROGTray {
fn rebuild_and_update(
&mut self,
supported: &SupportedFunctions,
has_supergfx: bool,
supported_gfx: &[GfxMode],
current_gfx_mode: GfxMode,
charge_limit: u8,
panel_od: bool,
@@ -451,8 +390,9 @@ impl ROGTray {
self.menu_add_base();
self.menu_add_charge_limit(supported, charge_limit);
self.menu_add_panel_od(supported, panel_od);
if has_supergfx {
self.menu_add_gpu(supported, current_gfx_mode);
if self.gfx_proxy_is_active {
// Add a supergfxctl specific menu
self.menu_add_supergfx(supported_gfx, current_gfx_mode);
} else if supported.rog_bios_ctrl.gpu_mux {
self.menu_add_mux(current_gfx_mode);
}
@@ -467,12 +407,6 @@ 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 || {
let gtk_init = gtk::init().map_err(|e| {
error!("ROGTray: gtk init {e}");
@@ -496,7 +430,29 @@ pub fn init_tray(
return;
}
};
tray.rebuild_and_update(&supported, has_supergfx, GfxMode::Hybrid, 100, false);
let supported_gfx = if tray.gfx_proxy_is_active {
if let Ok(version) = tray.gfx_proxy.version() {
if let Some(version) = Versioning::new(&version) {
let curr_gfx = Versioning::new("5.0.3-RC4").unwrap();
warn!("supergfxd version = {version}");
if version < curr_gfx {
// Don't allow mode changing if too old a version
warn!("supergfxd found but is too old to use");
tray.gfx_proxy_is_active = false;
}
}
}
if tray.gfx_proxy_is_active {
tray.gfx_proxy.supported().unwrap()
} else {
Default::default()
}
} else {
Default::default()
};
tray.rebuild_and_update(&supported, &supported_gfx, GfxMode::Hybrid, 100, false);
tray.set_icon(TRAY_APP_ICON);
info!("Started ROGTray");
@@ -508,13 +464,13 @@ pub fn init_tray(
lock.gfx_state.mode
} else {
match lock.bios.dedicated_gfx {
GpuMode::Discrete => GfxMode::AsusMuxDiscreet,
GpuMode::Discrete => GfxMode::AsusMuxDgpu,
_ => GfxMode::Hybrid,
}
};
tray.rebuild_and_update(
&supported,
has_supergfx,
&supported_gfx,
current_gpu_mode,
lock.power_state.charge_limit,
lock.bios.panel_overdrive,
@@ -524,13 +480,19 @@ pub fn init_tray(
match lock.gfx_state.power_status {
GfxPower::Suspended => tray.set_icon("asus_notif_blue"),
GfxPower::Off => tray.set_icon("asus_notif_green"),
GfxPower::Off => {
if lock.gfx_state.mode == GfxMode::Vfio {
tray.set_icon("asus_notif_red")
} else {
tray.set_icon("asus_notif_green")
}
}
GfxPower::AsusDisabled => tray.set_icon("asus_notif_white"),
GfxPower::AsusMuxDiscreet | GfxPower::Active => {
tray.set_icon("asus_notif_red");
}
GfxPower::Unknown => {
if has_supergfx {
if tray.gfx_proxy_is_active {
tray.set_icon("gpu-integrated");
} else {
tray.set_icon("asus_notif_red");

View File

@@ -17,7 +17,8 @@ use rog_dbus::zbus_profile::ProfileProxy;
use rog_platform::platform::GpuMode;
use rog_profiles::Profile;
use serde::{Deserialize, Serialize};
use supergfxctl::pci_device::GfxPower;
use supergfxctl::actions::UserActionRequired as GfxUserAction;
use supergfxctl::pci_device::{GfxMode, GfxPower};
use supergfxctl::zbus_proxy::DaemonProxy as SuperProxy;
use tokio::time::sleep;
use zbus::export::futures_util::{future, StreamExt};
@@ -406,6 +407,7 @@ pub fn start_notifications(
do_notification
);
let page_states1 = page_states.clone();
tokio::spawn(async move {
let conn = zbus::Connection::system()
.await
@@ -426,15 +428,25 @@ pub fn start_notifications(
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:?}",),
)
let mode = if let Ok(lock) = page_states1.lock() {
convert_gfx_mode(lock.gfx_state.mode)
} else {
GpuMode::Error
};
match action {
supergfxctl::actions::UserActionRequired::Reboot => {
do_mux_notification(
"Graphics mode change requires reboot",
&mode,
)
}
_ => do_gfx_action_notif(<&str>::from(action), *action, mode),
}
.map_err(|e| {
error!("zbus signal: do_gfx_action_notif: {e}");
e
})
.unwrap();
.ok();
}
}
};
@@ -445,6 +457,18 @@ pub fn start_notifications(
Ok(())
}
fn convert_gfx_mode(gfx: GfxMode) -> GpuMode {
match gfx {
GfxMode::Hybrid => GpuMode::Optimus,
GfxMode::Integrated => GpuMode::Integrated,
GfxMode::NvidiaNoModeset => GpuMode::Discrete,
GfxMode::Vfio => GpuMode::Vfio,
GfxMode::AsusEgpu => GpuMode::Egpu,
GfxMode::AsusMuxDgpu => GpuMode::Ultimate,
GfxMode::None => GpuMode::Error,
}
}
fn base_notification<T>(message: &str, data: &T) -> Notification
where
T: Display,
@@ -516,47 +540,91 @@ fn do_gpu_status_notif(message: &str, data: &GfxPower) -> Result<NotificationHan
Ok(Notification::show(&notif)?)
}
fn do_gfx_action_notif<T>(message: &str, data: &T) -> Result<()>
where
T: Display,
{
let mut notif = base_notification(message, data);
notif.action("gnome-session-quit", "Logout");
notif.urgency(Urgency::Critical);
notif.timeout(3000);
notif.icon("dialog-warning");
notif.hint(Hint::Transient(true));
let handle = notif.show()?;
handle.wait_for_action(|id| {
if id == "gnome-session-quit" {
let mut cmd = Command::new("gnome-session-quit");
cmd.spawn().ok();
} else if id == "__closed" {
// TODO: cancel the switching
fn do_gfx_action_notif(message: &str, action: GfxUserAction, mode: GpuMode) -> Result<()> {
if matches!(action, GfxUserAction::Reboot) {
do_mux_notification("Graphics mode change requires reboot", &mode).ok();
return Ok(());
}
let mut notif = Notification::new();
notif
.summary(NOTIF_HEADER)
.body(&format!("Changing to {mode}. {message}"))
.timeout(2000)
//.hint(Hint::Resident(true))
.hint(Hint::Category("device".into()))
.urgency(Urgency::Critical)
.timeout(3000)
.icon("dialog-warning")
.hint(Hint::Transient(true));
if matches!(action, GfxUserAction::Logout) {
notif.action("gfx-mode-session-action", "Logout");
let handle = notif.show()?;
if let Ok(desktop) = std::env::var("XDG_CURRENT_DESKTOP") {
if desktop.to_lowercase() == "gnome" {
handle.wait_for_action(|id| {
if id == "gfx-mode-session-action" {
let mut cmd = Command::new("gnome-session-quit");
cmd.spawn().ok();
} else if id == "__closed" {
// TODO: cancel the switching
}
});
} else if desktop.to_lowercase() == "kde" {
handle.wait_for_action(|id| {
if id == "gfx-mode-session-action" {
let mut cmd = Command::new("qdbus");
cmd.args(["org.kde.ksmserver", "/KSMServer", "logout", "1", "0", "0"]);
cmd.spawn().ok();
} else if id == "__closed" {
// TODO: cancel the switching
}
});
} else {
// todo: handle alternatives
}
}
});
} else {
notif.show()?;
}
Ok(())
}
/// Actual `GpuMode` unused as data is never correct until switched by reboot
fn do_mux_notification(message: &str, m: &GpuMode) -> Result<()> {
let mut notif = base_notification(message, &m.to_string());
notif.action("gnome-session-quit", "Reboot");
notif.urgency(Urgency::Critical);
notif.icon("system-reboot-symbolic");
notif.hint(Hint::Transient(true));
notif
.action("gfx-mode-session-action", "Reboot")
.urgency(Urgency::Critical)
.icon("system-reboot-symbolic")
.hint(Hint::Transient(true));
let handle = notif.show()?;
std::thread::spawn(|| {
handle.wait_for_action(|id| {
if id == "gnome-session-quit" {
let mut cmd = Command::new("gnome-session-quit");
cmd.arg("--reboot");
cmd.spawn().ok();
} else if id == "__closed" {
// TODO: cancel the switching
if let Ok(desktop) = std::env::var("XDG_CURRENT_DESKTOP") {
if desktop.to_lowercase() == "gnome" {
handle.wait_for_action(|id| {
if id == "gfx-mode-session-action" {
let mut cmd = Command::new("gnome-session-quit");
cmd.arg("--reboot");
cmd.spawn().ok();
} else if id == "__closed" {
// TODO: cancel the switching
}
});
} else if desktop.to_lowercase() == "kde" {
handle.wait_for_action(|id| {
if id == "gfx-mode-session-action" {
let mut cmd = Command::new("qdbus");
cmd.args(["org.kde.ksmserver", "/KSMServer", "logout", "1", "1", "0"]);
cmd.spawn().ok();
} else if id == "__closed" {
// TODO: cancel the switching
}
});
}
});
}
});
Ok(())
}

View File

@@ -1,5 +1,5 @@
use egui::{RichText, Ui};
use rog_aura::usb::{AuraDev1866, AuraDev19b6, AuraDevTuf, AuraDevice, AuraPowerDev};
use rog_aura::usb::{AuraDevRog1, AuraDevRog2, AuraDevTuf, AuraDevice, AuraPowerDev};
use rog_aura::AuraZone;
use rog_platform::supported::SupportedFunctions;
@@ -12,7 +12,9 @@ pub fn aura_power_group(supported: &SupportedFunctions, states: &mut SystemState
AuraDevice::X1854 | AuraDevice::X1869 | AuraDevice::X1866 => {
aura_power1(supported, states, ui);
}
AuraDevice::X19B6 => aura_power2(supported, states, ui),
AuraDevice::X19b6 | AuraDevice::X18c6 | AuraDevice::X1a30 => {
aura_power2(supported, states, ui)
}
AuraDevice::Tuf => aura_power1(supported, states, ui),
AuraDevice::Unknown => {}
}
@@ -20,10 +22,10 @@ pub fn aura_power_group(supported: &SupportedFunctions, states: &mut SystemState
fn aura_power1(supported: &SupportedFunctions, states: &mut SystemState, ui: &mut Ui) {
let enabled_states = &mut states.aura.enabled;
let mut boot = enabled_states.x1866.contains(&AuraDev1866::Boot);
let mut sleep = enabled_states.x1866.contains(&AuraDev1866::Sleep);
let mut keyboard = enabled_states.x1866.contains(&AuraDev1866::Keyboard);
let mut lightbar = enabled_states.x1866.contains(&AuraDev1866::Lightbar);
let mut boot = enabled_states.x1866.contains(&AuraDevRog1::Boot);
let mut sleep = enabled_states.x1866.contains(&AuraDevRog1::Sleep);
let mut keyboard = enabled_states.x1866.contains(&AuraDevRog1::Keyboard);
let mut lightbar = enabled_states.x1866.contains(&AuraDevRog1::Lightbar);
if supported.keyboard_led.dev_id == AuraDevice::Tuf {
boot = enabled_states.tuf.contains(&AuraDevTuf::Boot);
sleep = enabled_states.tuf.contains(&AuraDevTuf::Sleep);
@@ -148,7 +150,7 @@ fn aura_power1(supported: &SupportedFunctions, states: &mut SystemState, ui: &mu
let mut enabled = Vec::new();
let mut disabled = Vec::new();
let mut modify_x1866 = |b: bool, a: AuraDev1866| {
let mut modify_x1866 = |b: bool, a: AuraDevRog1| {
if b {
enabled.push(a);
if !enabled_states.x1866.contains(&a) {
@@ -169,14 +171,14 @@ fn aura_power1(supported: &SupportedFunctions, states: &mut SystemState, ui: &mu
}
}
};
modify_x1866(boot, AuraDev1866::Boot);
modify_x1866(sleep, AuraDev1866::Sleep);
modify_x1866(keyboard, AuraDev1866::Keyboard);
modify_x1866(boot, AuraDevRog1::Boot);
modify_x1866(sleep, AuraDevRog1::Sleep);
modify_x1866(keyboard, AuraDevRog1::Keyboard);
if !supported.keyboard_led.basic_zones.is_empty() {
modify_x1866(lightbar, AuraDev1866::Lightbar);
modify_x1866(lightbar, AuraDevRog1::Lightbar);
}
let mut send = |enable: bool, data: Vec<AuraDev1866>| {
let mut send = |enable: bool, data: Vec<AuraDevRog1>| {
let options = AuraPowerDev {
tuf: vec![],
x1866: data,
@@ -211,17 +213,17 @@ fn aura_power2(supported: &SupportedFunctions, states: &mut SystemState, ui: &mu
.basic_zones
.contains(&AuraZone::BarRight);
let boot_bar = &mut enabled_states.x19b6.contains(&AuraDev19b6::AwakeBar);
let boot_logo = &mut enabled_states.x19b6.contains(&AuraDev19b6::BootLogo);
let boot_keyb = &mut enabled_states.x19b6.contains(&AuraDev19b6::BootKeyb);
let boot_bar = &mut enabled_states.x19b6.contains(&AuraDevRog2::AwakeBar);
let boot_logo = &mut enabled_states.x19b6.contains(&AuraDevRog2::BootLogo);
let boot_keyb = &mut enabled_states.x19b6.contains(&AuraDevRog2::BootKeyb);
let awake_bar = &mut enabled_states.x19b6.contains(&AuraDev19b6::BootBar);
let awake_logo = &mut enabled_states.x19b6.contains(&AuraDev19b6::AwakeLogo);
let awake_keyb = &mut enabled_states.x19b6.contains(&AuraDev19b6::AwakeKeyb);
let awake_bar = &mut enabled_states.x19b6.contains(&AuraDevRog2::BootBar);
let awake_logo = &mut enabled_states.x19b6.contains(&AuraDevRog2::AwakeLogo);
let awake_keyb = &mut enabled_states.x19b6.contains(&AuraDevRog2::AwakeKeyb);
let sleep_bar = &mut enabled_states.x19b6.contains(&AuraDev19b6::SleepBar);
let sleep_logo = &mut enabled_states.x19b6.contains(&AuraDev19b6::SleepLogo);
let sleep_keyb = &mut enabled_states.x19b6.contains(&AuraDev19b6::SleepKeyb);
let sleep_bar = &mut enabled_states.x19b6.contains(&AuraDevRog2::SleepBar);
let sleep_logo = &mut enabled_states.x19b6.contains(&AuraDevRog2::SleepLogo);
let sleep_keyb = &mut enabled_states.x19b6.contains(&AuraDevRog2::SleepKeyb);
let mut changed = false;
@@ -265,7 +267,7 @@ fn aura_power2(supported: &SupportedFunctions, states: &mut SystemState, ui: &mu
let mut enabled = Vec::new();
let mut disabled = Vec::new();
let mut modify = |b: bool, a: AuraDev19b6| {
let mut modify = |b: bool, a: AuraDevRog2| {
if b {
enabled.push(a);
if !enabled_states.x19b6.contains(&a) {
@@ -286,25 +288,25 @@ fn aura_power2(supported: &SupportedFunctions, states: &mut SystemState, ui: &mu
}
}
};
modify(*boot_keyb, AuraDev19b6::BootKeyb);
modify(*sleep_keyb, AuraDev19b6::SleepKeyb);
modify(*awake_keyb, AuraDev19b6::AwakeKeyb);
modify(*boot_keyb, AuraDevRog2::BootKeyb);
modify(*sleep_keyb, AuraDevRog2::SleepKeyb);
modify(*awake_keyb, AuraDevRog2::AwakeKeyb);
if supported.keyboard_led.basic_zones.contains(&AuraZone::Logo) {
modify(*boot_logo, AuraDev19b6::BootLogo);
modify(*sleep_logo, AuraDev19b6::SleepLogo);
modify(*awake_logo, AuraDev19b6::AwakeLogo);
modify(*boot_logo, AuraDevRog2::BootLogo);
modify(*sleep_logo, AuraDevRog2::SleepLogo);
modify(*awake_logo, AuraDevRog2::AwakeLogo);
}
if supported
.keyboard_led
.basic_zones
.contains(&AuraZone::BarLeft)
{
modify(*boot_bar, AuraDev19b6::AwakeBar);
modify(*sleep_bar, AuraDev19b6::SleepBar);
modify(*awake_bar, AuraDev19b6::BootBar);
modify(*boot_bar, AuraDevRog2::AwakeBar);
modify(*sleep_bar, AuraDevRog2::SleepBar);
modify(*awake_bar, AuraDevRog2::BootBar);
}
let mut send = |enable: bool, data: Vec<AuraDev19b6>| {
let mut send = |enable: bool, data: Vec<AuraDevRog2>| {
let options = AuraPowerDev {
tuf: vec![],
x1866: vec![],

View File

@@ -8,7 +8,7 @@ impl RogApp {
// The top panel is often a good place for a menu bar:
egui::menu::bar(ui, |ui| {
ui.horizontal(|ui| {
egui::global_dark_light_mode_buttons(ui);
self.dark_light_mode_buttons(ui);
egui::warn_if_debug_build(ui);
});
@@ -45,4 +45,34 @@ impl RogApp {
});
});
}
fn dark_light_mode_buttons(&mut self, ui: &mut egui::Ui) {
let load_from_cfg = self.config.dark_mode != ui.ctx().style().visuals.dark_mode;
if ui
.add(egui::SelectableLabel::new(
!self.config.dark_mode,
"☀ Light",
))
.clicked()
|| (load_from_cfg && !self.config.dark_mode)
{
ui.ctx().set_visuals(egui::Visuals::light());
}
if ui
.add(egui::SelectableLabel::new(self.config.dark_mode, "🌙 Dark"))
.clicked()
|| (load_from_cfg && self.config.dark_mode)
{
ui.ctx().set_visuals(egui::Visuals::dark());
}
let applied_dark_mode = ui.ctx().style().visuals.dark_mode;
if self.config.dark_mode != applied_dark_mode {
self.config.dark_mode = applied_dark_mode;
let tmp = self.config.enabled_notifications.clone();
self.config.save(&tmp).ok();
}
}
}

View File

@@ -76,6 +76,8 @@ pub enum GpuMode {
Optimus,
Integrated,
Egpu,
Vfio,
Ultimate,
#[default]
Error,
NotSupported,
@@ -135,6 +137,8 @@ impl Display for GpuMode {
GpuMode::Optimus => write!(f, "Optimus"),
GpuMode::Integrated => write!(f, "Integrated"),
GpuMode::Egpu => write!(f, "eGPU"),
GpuMode::Vfio => write!(f, "VFIO"),
GpuMode::Ultimate => write!(f, "Ultimate"),
GpuMode::Error => write!(f, "Error"),
GpuMode::NotSupported => write!(f, "Not Supported"),
}