mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 73b1a7050a | |||
| 762bfea102 | |||
| b41fdf5cfe | |||
| bf13ebebd3 | |||
| 3a73e3a526 |
@@ -5,6 +5,9 @@ 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).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
## [v4.5.1- RC2]
|
||||||
|
- Share pagestates with tray process in ROGCC
|
||||||
|
|
||||||
## [v4.5.1- RC1]
|
## [v4.5.1- RC1]
|
||||||
### Added
|
### Added
|
||||||
- Support for FA506IE LED modes (Author: Herohtar)
|
- Support for FA506IE LED modes (Author: Herohtar)
|
||||||
@@ -12,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Add a basic system tray with dGPU status and gpu mode switch actions
|
- Add a basic system tray with dGPU status and gpu mode switch actions
|
||||||
- Fixup some notifications in ROGCC
|
- Fixup some notifications in ROGCC
|
||||||
- Add config options for notifications for ROGCC
|
- Add config options for notifications for ROGCC
|
||||||
|
- Share pagestates with tray process in ROGCC
|
||||||
|
|
||||||
## [v4.5.0]
|
## [v4.5.0]
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
Generated
+9
-9
@@ -83,7 +83,7 @@ checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "asusctl"
|
name = "asusctl"
|
||||||
version = "4.5.1-RC1"
|
version = "4.5.1-RC2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"daemon",
|
"daemon",
|
||||||
"gif",
|
"gif",
|
||||||
@@ -662,7 +662,7 @@ checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "daemon"
|
name = "daemon"
|
||||||
version = "4.5.1-RC1"
|
version = "4.5.1-RC2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"concat-idents",
|
"concat-idents",
|
||||||
@@ -686,7 +686,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "daemon-user"
|
name = "daemon-user"
|
||||||
version = "4.5.1-RC1"
|
version = "4.5.1-RC2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dirs",
|
"dirs",
|
||||||
"rog_anime",
|
"rog_anime",
|
||||||
@@ -2398,7 +2398,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rog-control-center"
|
name = "rog-control-center"
|
||||||
version = "4.5.1-RC1"
|
version = "4.5.1-RC2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"daemon",
|
"daemon",
|
||||||
"dirs",
|
"dirs",
|
||||||
@@ -2428,7 +2428,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rog_anime"
|
name = "rog_anime"
|
||||||
version = "4.5.1-RC1"
|
version = "4.5.1-RC2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"gif",
|
"gif",
|
||||||
"glam",
|
"glam",
|
||||||
@@ -2444,7 +2444,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rog_aura"
|
name = "rog_aura"
|
||||||
version = "4.5.1-RC1"
|
version = "4.5.1-RC2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
@@ -2455,7 +2455,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rog_dbus"
|
name = "rog_dbus"
|
||||||
version = "4.5.1-RC1"
|
version = "4.5.1-RC2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"rog_anime",
|
"rog_anime",
|
||||||
"rog_aura",
|
"rog_aura",
|
||||||
@@ -2468,7 +2468,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rog_platform"
|
name = "rog_platform"
|
||||||
version = "4.5.1-RC1"
|
version = "4.5.1-RC2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"concat-idents",
|
"concat-idents",
|
||||||
"inotify",
|
"inotify",
|
||||||
@@ -2485,7 +2485,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rog_profiles"
|
name = "rog_profiles"
|
||||||
version = "4.5.1-RC1"
|
version = "4.5.1-RC2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
members = ["asusctl", "daemon", "daemon-user", "rog-platform", "rog-dbus", "rog-anime", "rog-aura", "rog-profiles", "rog-control-center"]
|
members = ["asusctl", "daemon", "daemon-user", "rog-platform", "rog-dbus", "rog-anime", "rog-aura", "rog-profiles", "rog-control-center"]
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
version = "4.5.1-RC1"
|
version = "4.5.1-RC2"
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
async-trait = "^0.1"
|
async-trait = "^0.1"
|
||||||
|
|||||||
@@ -539,7 +539,6 @@ fn handle_led_power_1_do_tuf(
|
|||||||
x19b6: vec![],
|
x19b6: vec![],
|
||||||
tuf: enabled,
|
tuf: enabled,
|
||||||
};
|
};
|
||||||
dbg!(&data);
|
|
||||||
dbus.proxies().led().set_leds_power(data, true)?;
|
dbus.proxies().led().set_leds_power(data, true)?;
|
||||||
|
|
||||||
let data = AuraPowerDev {
|
let data = AuraPowerDev {
|
||||||
|
|||||||
@@ -64,7 +64,6 @@ macro_rules! task_watch_item {
|
|||||||
let mut buffer = [0; 32];
|
let mut buffer = [0; 32];
|
||||||
watch.event_stream(&mut buffer).unwrap().for_each(|_| async {
|
watch.event_stream(&mut buffer).unwrap().for_each(|_| async {
|
||||||
let value = ctrl.$name();
|
let value = ctrl.$name();
|
||||||
dbg!(&value);
|
|
||||||
concat_idents::concat_idents!(notif_fn = notify_, $name {
|
concat_idents::concat_idents!(notif_fn = notify_, $name {
|
||||||
Self::notif_fn(&signal_ctxt, value).await.ok();
|
Self::notif_fn(&signal_ctxt, value).await.ok();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ pub const LED_INIT4: &str = "^ASUS Tech.Inc."; // ^ == 0x5e
|
|||||||
pub const LED_INIT5: [u8; 6] = [0x5e, 0x05, 0x20, 0x31, 0, 0x08];
|
pub const LED_INIT5: [u8; 6] = [0x5e, 0x05, 0x20, 0x31, 0, 0x08];
|
||||||
|
|
||||||
use serde_derive::{Deserialize, Serialize};
|
use serde_derive::{Deserialize, Serialize};
|
||||||
use std::str::FromStr;
|
use std::{fmt::Display, str::FromStr};
|
||||||
#[cfg(feature = "dbus")]
|
#[cfg(feature = "dbus")]
|
||||||
use zvariant::Type;
|
use zvariant::Type;
|
||||||
|
|
||||||
@@ -171,6 +171,12 @@ pub enum AuraModeNum {
|
|||||||
Flash = 12,
|
Flash = 12,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Display for AuraModeNum {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
write!(f, "{}", <&str>::from(self))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl From<AuraModeNum> for String {
|
impl From<AuraModeNum> for String {
|
||||||
fn from(mode: AuraModeNum) -> Self {
|
fn from(mode: AuraModeNum) -> Self {
|
||||||
match mode {
|
match mode {
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
use std::{
|
use std::{
|
||||||
f64::consts::PI,
|
f64::consts::PI,
|
||||||
io::Write,
|
|
||||||
sync::{
|
sync::{
|
||||||
atomic::{AtomicBool, AtomicU8, Ordering},
|
atomic::{AtomicBool, AtomicU8, Ordering},
|
||||||
mpsc::Receiver,
|
Arc, Mutex,
|
||||||
Arc,
|
|
||||||
},
|
},
|
||||||
time::{Duration, Instant},
|
time::{Duration, Instant},
|
||||||
};
|
};
|
||||||
@@ -13,17 +11,15 @@ use egui::{Button, RichText};
|
|||||||
use rog_platform::supported::SupportedFunctions;
|
use rog_platform::supported::SupportedFunctions;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
config::Config, error::Result, get_ipc_file, page_states::PageDataStates, tray::TrayToApp,
|
config::Config, error::Result, page_states::PageDataStates, Page, RogDbusClientBlocking,
|
||||||
Page, RogDbusClientBlocking, SHOW_GUI,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct RogApp<'a> {
|
pub struct RogApp {
|
||||||
pub page: Page,
|
pub page: Page,
|
||||||
pub states: PageDataStates,
|
pub states: Arc<Mutex<PageDataStates>>,
|
||||||
pub supported: SupportedFunctions,
|
pub supported: SupportedFunctions,
|
||||||
// TODO: can probably just open and read whenever
|
// TODO: can probably just open and read whenever
|
||||||
pub config: Config,
|
pub config: Config,
|
||||||
pub asus_dbus: RogDbusClientBlocking<'a>,
|
|
||||||
/// Oscillator in percentage
|
/// Oscillator in percentage
|
||||||
pub oscillator1: Arc<AtomicU8>,
|
pub oscillator1: Arc<AtomicU8>,
|
||||||
pub oscillator2: Arc<AtomicU8>,
|
pub oscillator2: Arc<AtomicU8>,
|
||||||
@@ -32,15 +28,13 @@ pub struct RogApp<'a> {
|
|||||||
pub oscillator_freq: Arc<AtomicU8>,
|
pub oscillator_freq: Arc<AtomicU8>,
|
||||||
/// A toggle that toggles true/false when the oscillator reaches 0
|
/// A toggle that toggles true/false when the oscillator reaches 0
|
||||||
pub oscillator_toggle: Arc<AtomicBool>,
|
pub oscillator_toggle: Arc<AtomicBool>,
|
||||||
pub app_cmd: Arc<Receiver<TrayToApp>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> RogApp<'a> {
|
impl RogApp {
|
||||||
/// Called once before the first frame.
|
/// Called once before the first frame.
|
||||||
pub fn new(
|
pub fn new(
|
||||||
config: Config,
|
config: Config,
|
||||||
states: PageDataStates,
|
states: Arc<Mutex<PageDataStates>>,
|
||||||
app_cmd: Arc<Receiver<TrayToApp>>,
|
|
||||||
_cc: &eframe::CreationContext<'_>,
|
_cc: &eframe::CreationContext<'_>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let (dbus, _) = RogDbusClientBlocking::new()?;
|
let (dbus, _) = RogDbusClientBlocking::new()?;
|
||||||
@@ -60,6 +54,7 @@ impl<'a> RogApp<'a> {
|
|||||||
let oscillator_freq1 = oscillator_freq.clone();
|
let oscillator_freq1 = oscillator_freq.clone();
|
||||||
let oscillator_toggle = Arc::new(AtomicBool::new(false));
|
let oscillator_toggle = Arc::new(AtomicBool::new(false));
|
||||||
let oscillator_toggle1 = oscillator_toggle.clone();
|
let oscillator_toggle1 = oscillator_toggle.clone();
|
||||||
|
|
||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || {
|
||||||
let started = Instant::now();
|
let started = Instant::now();
|
||||||
let mut toggled = false;
|
let mut toggled = false;
|
||||||
@@ -88,6 +83,7 @@ impl<'a> RogApp<'a> {
|
|||||||
oscillator1_1.store(tmp1, Ordering::SeqCst);
|
oscillator1_1.store(tmp1, Ordering::SeqCst);
|
||||||
oscillator1_2.store(tmp2, Ordering::SeqCst);
|
oscillator1_2.store(tmp2, Ordering::SeqCst);
|
||||||
oscillator1_3.store(tmp3, Ordering::SeqCst);
|
oscillator1_3.store(tmp3, Ordering::SeqCst);
|
||||||
|
|
||||||
std::thread::sleep(Duration::from_millis(33));
|
std::thread::sleep(Duration::from_millis(33));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -97,88 +93,72 @@ impl<'a> RogApp<'a> {
|
|||||||
states,
|
states,
|
||||||
page: Page::System,
|
page: Page::System,
|
||||||
config,
|
config,
|
||||||
asus_dbus: dbus,
|
|
||||||
oscillator1,
|
oscillator1,
|
||||||
oscillator2,
|
oscillator2,
|
||||||
oscillator3,
|
oscillator3,
|
||||||
oscillator_toggle,
|
oscillator_toggle,
|
||||||
oscillator_freq,
|
oscillator_freq,
|
||||||
app_cmd,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_app_cmds(&mut self, _ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
|
||||||
let Self { app_cmd, .. } = self;
|
|
||||||
|
|
||||||
if let Ok(cmd) = app_cmd.try_recv() {
|
|
||||||
match cmd {
|
|
||||||
TrayToApp::Open => {
|
|
||||||
dbg!();
|
|
||||||
get_ipc_file().unwrap().write_all(&[SHOW_GUI]).ok();
|
|
||||||
}
|
|
||||||
TrayToApp::Quit => _frame.close(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> eframe::App for RogApp<'a> {
|
impl eframe::App for RogApp {
|
||||||
/// Called each time the UI needs repainting, which may be many times per second.
|
/// Called each time the UI needs repainting, which may be many times per second.
|
||||||
/// Put your widgets into a `SidePanel`, `TopPanel`, `CentralPanel`, `Window` or `Area`.
|
/// Put your widgets into a `SidePanel`, `TopPanel`, `CentralPanel`, `Window` or `Area`.
|
||||||
fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) {
|
fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) {
|
||||||
self.check_app_cmds(ctx, frame);
|
let states = self.states.clone();
|
||||||
|
|
||||||
let Self {
|
if let Ok(mut states) = states.try_lock() {
|
||||||
supported,
|
if states.app_should_update {
|
||||||
asus_dbus: dbus,
|
states.app_should_update = false;
|
||||||
states,
|
ctx.request_repaint();
|
||||||
..
|
}
|
||||||
} = self;
|
}
|
||||||
|
|
||||||
states
|
|
||||||
.refresh_if_notfied(supported, dbus)
|
|
||||||
.map(|repaint| {
|
|
||||||
if repaint {
|
|
||||||
ctx.request_repaint();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.map_err(|e| self.states.error = Some(e.to_string()))
|
|
||||||
.ok();
|
|
||||||
|
|
||||||
let page = self.page;
|
let page = self.page;
|
||||||
|
|
||||||
self.top_bar(ctx, frame);
|
self.top_bar(ctx, frame);
|
||||||
self.side_panel(ctx);
|
self.side_panel(ctx);
|
||||||
|
|
||||||
if let Some(err) = self.states.error.clone() {
|
let mut was_error = false;
|
||||||
egui::CentralPanel::default().show(ctx, |ui| {
|
|
||||||
ui.heading(RichText::new("Error!").size(28.0));
|
|
||||||
|
|
||||||
ui.centered_and_justified(|ui| {
|
if let Ok(mut states) = states.try_lock() {
|
||||||
ui.label(RichText::new(format!("The error was: {:?}", err)).size(22.0));
|
if let Some(err) = states.error.clone() {
|
||||||
});
|
was_error = true;
|
||||||
});
|
egui::CentralPanel::default().show(ctx, |ui| {
|
||||||
egui::TopBottomPanel::bottom("error_bar")
|
ui.heading(RichText::new("Error!").size(28.0));
|
||||||
.default_height(26.0)
|
|
||||||
.show(ctx, |ui| {
|
ui.centered_and_justified(|ui| {
|
||||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::TOP), |ui| {
|
ui.label(RichText::new(format!("The error was: {:?}", err)).size(22.0));
|
||||||
if ui
|
|
||||||
.add(Button::new(RichText::new("Okay").size(20.0)))
|
|
||||||
.clicked()
|
|
||||||
{
|
|
||||||
self.states.error = None;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else if page == Page::System {
|
egui::TopBottomPanel::bottom("error_bar")
|
||||||
self.system_page(ctx);
|
.default_height(26.0)
|
||||||
} else if page == Page::AuraEffects {
|
.show(ctx, |ui| {
|
||||||
self.aura_page(ctx);
|
ui.with_layout(egui::Layout::right_to_left(egui::Align::TOP), |ui| {
|
||||||
// TODO: Anime page is not complete
|
if ui
|
||||||
// } else if page == Page::AnimeMatrix {
|
.add(Button::new(RichText::new("Okay").size(20.0)))
|
||||||
// self.anime_page(ctx);
|
.clicked()
|
||||||
} else if page == Page::FanCurves {
|
{
|
||||||
self.fan_curve_page(ctx);
|
states.error = None;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !was_error {
|
||||||
|
if let Ok(mut states) = states.try_lock() {
|
||||||
|
if page == Page::System {
|
||||||
|
self.system_page(&mut states, ctx);
|
||||||
|
} else if page == Page::AuraEffects {
|
||||||
|
self.aura_page(&mut states, ctx);
|
||||||
|
// TODO: Anime page is not complete
|
||||||
|
// } else if page == Page::AnimeMatrix {
|
||||||
|
// self.anime_page(ctx);
|
||||||
|
} else if page == Page::FanCurves {
|
||||||
|
self.fan_curve_page(&mut states, ctx);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,20 +2,19 @@ use eframe::{IconData, NativeOptions};
|
|||||||
use log::{error, LevelFilter};
|
use log::{error, LevelFilter};
|
||||||
use rog_aura::layouts::KeyLayout;
|
use rog_aura::layouts::KeyLayout;
|
||||||
use rog_control_center::notify::EnabledNotifications;
|
use rog_control_center::notify::EnabledNotifications;
|
||||||
use rog_control_center::tray::{AppToTray, TrayToApp};
|
use rog_control_center::tray::init_tray;
|
||||||
use rog_control_center::{
|
use rog_control_center::{
|
||||||
config::Config, error::Result, get_ipc_file, notify::start_notifications, on_tmp_dir_exists,
|
config::Config, error::Result, get_ipc_file, notify::start_notifications, on_tmp_dir_exists,
|
||||||
page_states::PageDataStates, print_versions, startup_error::AppErrorShow, tray::init_tray,
|
page_states::PageDataStates, print_versions, startup_error::AppErrorShow, RogApp,
|
||||||
RogApp, RogDbusClientBlocking, SHOWING_GUI, SHOW_GUI,
|
RogDbusClientBlocking, SHOWING_GUI, SHOW_GUI,
|
||||||
};
|
};
|
||||||
use rog_platform::supported::SupportedFunctions;
|
use rog_platform::supported::SupportedFunctions;
|
||||||
use std::sync::mpsc::{channel, Receiver, Sender};
|
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
use std::{
|
use std::{
|
||||||
fs::OpenOptions,
|
fs::OpenOptions,
|
||||||
io::{Read, Write},
|
io::{Read, Write},
|
||||||
path::PathBuf,
|
path::PathBuf,
|
||||||
sync::{atomic::AtomicBool, Arc},
|
sync::Arc,
|
||||||
};
|
};
|
||||||
use tokio::runtime::Runtime;
|
use tokio::runtime::Runtime;
|
||||||
|
|
||||||
@@ -73,10 +72,6 @@ fn main() -> Result<()> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let (send, recv) = channel();
|
|
||||||
let update_tray = Arc::new(Mutex::new(send));
|
|
||||||
let app_cmd = Arc::new(init_tray(supported.clone(), recv));
|
|
||||||
|
|
||||||
// Startup
|
// Startup
|
||||||
let mut config = Config::load()?;
|
let mut config = Config::load()?;
|
||||||
let mut start_closed = config.startup_in_background;
|
let mut start_closed = config.startup_in_background;
|
||||||
@@ -123,18 +118,13 @@ fn main() -> Result<()> {
|
|||||||
Err(_) => on_tmp_dir_exists().unwrap(),
|
Err(_) => on_tmp_dir_exists().unwrap(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let states = setup_page_state_and_notifs(
|
let states = setup_page_state_and_notifs(layout, enabled_notifications, &supported).unwrap();
|
||||||
layout,
|
|
||||||
&dbus,
|
init_tray(supported, states.clone());
|
||||||
enabled_notifications,
|
|
||||||
update_tray,
|
|
||||||
&supported,
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
if !start_closed {
|
if !start_closed {
|
||||||
start_app(states.clone(), native_options.clone(), app_cmd.clone())?;
|
start_app(states.clone(), native_options.clone())?;
|
||||||
}
|
}
|
||||||
|
|
||||||
let config = Config::load().unwrap();
|
let config = Config::load().unwrap();
|
||||||
@@ -162,58 +152,27 @@ fn main() -> Result<()> {
|
|||||||
|
|
||||||
fn setup_page_state_and_notifs(
|
fn setup_page_state_and_notifs(
|
||||||
keyboard_layout: KeyLayout,
|
keyboard_layout: KeyLayout,
|
||||||
dbus: &RogDbusClientBlocking,
|
|
||||||
enabled_notifications: Arc<Mutex<EnabledNotifications>>,
|
enabled_notifications: Arc<Mutex<EnabledNotifications>>,
|
||||||
update_tray: Arc<Mutex<Sender<AppToTray>>>,
|
|
||||||
supported: &SupportedFunctions,
|
supported: &SupportedFunctions,
|
||||||
) -> Result<PageDataStates> {
|
) -> Result<Arc<Mutex<PageDataStates>>> {
|
||||||
// Cheap method to alert to notifications rather than spinning a thread for each
|
let page_states = Arc::new(Mutex::new(PageDataStates::new(
|
||||||
// This is quite different when done in a retained mode app
|
|
||||||
let charge_notified = Arc::new(AtomicBool::new(false));
|
|
||||||
let bios_notified = Arc::new(AtomicBool::new(false));
|
|
||||||
let aura_notified = Arc::new(AtomicBool::new(false));
|
|
||||||
let anime_notified = Arc::new(AtomicBool::new(false));
|
|
||||||
let profiles_notified = Arc::new(AtomicBool::new(false));
|
|
||||||
let fans_notified = Arc::new(AtomicBool::new(false));
|
|
||||||
|
|
||||||
start_notifications(
|
|
||||||
charge_notified.clone(),
|
|
||||||
bios_notified.clone(),
|
|
||||||
aura_notified.clone(),
|
|
||||||
anime_notified.clone(),
|
|
||||||
profiles_notified.clone(),
|
|
||||||
fans_notified.clone(),
|
|
||||||
enabled_notifications.clone(),
|
|
||||||
update_tray,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
PageDataStates::new(
|
|
||||||
keyboard_layout,
|
keyboard_layout,
|
||||||
enabled_notifications,
|
enabled_notifications.clone(),
|
||||||
charge_notified,
|
|
||||||
bios_notified,
|
|
||||||
aura_notified,
|
|
||||||
anime_notified,
|
|
||||||
profiles_notified,
|
|
||||||
fans_notified,
|
|
||||||
supported,
|
supported,
|
||||||
dbus,
|
)?));
|
||||||
)
|
|
||||||
|
start_notifications(page_states.clone(), enabled_notifications)?;
|
||||||
|
|
||||||
|
Ok(page_states)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn start_app(
|
fn start_app(states: Arc<Mutex<PageDataStates>>, native_options: NativeOptions) -> Result<()> {
|
||||||
states: PageDataStates,
|
|
||||||
native_options: NativeOptions,
|
|
||||||
app_cmd: Arc<Receiver<TrayToApp>>,
|
|
||||||
) -> Result<()> {
|
|
||||||
let mut ipc_file = get_ipc_file().unwrap();
|
let mut ipc_file = get_ipc_file().unwrap();
|
||||||
ipc_file.write_all(&[SHOWING_GUI]).unwrap();
|
ipc_file.write_all(&[SHOWING_GUI]).unwrap();
|
||||||
eframe::run_native(
|
eframe::run_native(
|
||||||
"ROG Control Center",
|
"ROG Control Center",
|
||||||
native_options,
|
native_options,
|
||||||
Box::new(move |cc| {
|
Box::new(move |cc| Box::new(RogApp::new(Config::load().unwrap(), states, cc).unwrap())),
|
||||||
Box::new(RogApp::new(Config::load().unwrap(), states, app_cmd, cc).unwrap())
|
|
||||||
}),
|
|
||||||
);
|
);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use crate::{config::Config, error::Result, tray::AppToTray};
|
use crate::{config::Config, error::Result, page_states::PageDataStates};
|
||||||
use notify_rust::{Hint, Notification, NotificationHandle, Urgency};
|
use notify_rust::{Hint, Notification, NotificationHandle, Urgency};
|
||||||
use rog_dbus::{
|
use rog_dbus::{
|
||||||
zbus_anime::AnimeProxy, zbus_led::LedProxy, zbus_platform::RogBiosProxy,
|
zbus_anime::AnimeProxy, zbus_led::LedProxy, zbus_platform::RogBiosProxy,
|
||||||
@@ -10,11 +10,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
use std::{
|
use std::{
|
||||||
fmt::Display,
|
fmt::Display,
|
||||||
process::Command,
|
process::Command,
|
||||||
sync::{
|
sync::{Arc, Mutex},
|
||||||
atomic::{AtomicBool, Ordering},
|
|
||||||
mpsc::Sender,
|
|
||||||
Arc, Mutex,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
use supergfxctl::{pci_device::GfxPower, zbus_proxy::DaemonProxy as SuperProxy};
|
use supergfxctl::{pci_device::GfxPower, zbus_proxy::DaemonProxy as SuperProxy};
|
||||||
use zbus::export::futures_util::{future, StreamExt};
|
use zbus::export::futures_util::{future, StreamExt};
|
||||||
@@ -77,19 +73,22 @@ macro_rules! notify {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: drop the macro and use generics plus closure
|
||||||
macro_rules! recv_notif {
|
macro_rules! recv_notif {
|
||||||
($proxy:ident,
|
($proxy:ident,
|
||||||
$signal:ident,
|
$signal:ident,
|
||||||
$was_notified:ident,
|
|
||||||
$last_notif:ident,
|
$last_notif:ident,
|
||||||
$notif_enabled:ident,
|
$notif_enabled:ident,
|
||||||
[$($out_arg:ident)+],
|
$page_states:ident,
|
||||||
|
($($args: tt)*),
|
||||||
|
($($out_arg:tt)+),
|
||||||
$msg:literal,
|
$msg:literal,
|
||||||
$notifier:ident) => {
|
$notifier:ident) => {
|
||||||
|
|
||||||
let last_notif = $last_notif.clone();
|
let last_notif = $last_notif.clone();
|
||||||
let notifs_enabled1 = $notif_enabled.clone();
|
let notifs_enabled1 = $notif_enabled.clone();
|
||||||
let notified = $was_notified.clone();
|
let page_states1 = $page_states.clone();
|
||||||
// TODO: make a macro or generic function or something...
|
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
let conn = zbus::Connection::system().await.unwrap();
|
let conn = zbus::Connection::system().await.unwrap();
|
||||||
let proxy = $proxy::new(&conn).await.unwrap();
|
let proxy = $proxy::new(&conn).await.unwrap();
|
||||||
@@ -98,12 +97,15 @@ macro_rules! recv_notif {
|
|||||||
if let Ok(out) = e.args() {
|
if let Ok(out) = e.args() {
|
||||||
if let Ok(config) = notifs_enabled1.lock() {
|
if let Ok(config) = notifs_enabled1.lock() {
|
||||||
if config.all_enabled && config.$signal {
|
if config.all_enabled && config.$signal {
|
||||||
if let Ok(ref mut lock) = last_notif.try_lock() {
|
if let Ok(ref mut lock) = last_notif.lock() {
|
||||||
notify!($notifier($msg, &out$(.$out_arg)+()), lock);
|
notify!($notifier($msg, &out.$($out_arg)+()), lock);
|
||||||
}
|
}
|
||||||
notified.store(true, Ordering::SeqCst);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if let Ok(mut lock) = page_states1.lock() {
|
||||||
|
lock.$($args)+ = *out.$($out_arg)+();
|
||||||
|
lock.set_notified();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -114,14 +116,8 @@ macro_rules! recv_notif {
|
|||||||
type SharedHandle = Arc<Mutex<Option<NotificationHandle>>>;
|
type SharedHandle = Arc<Mutex<Option<NotificationHandle>>>;
|
||||||
|
|
||||||
pub fn start_notifications(
|
pub fn start_notifications(
|
||||||
charge_notified: Arc<AtomicBool>,
|
page_states: Arc<Mutex<PageDataStates>>,
|
||||||
bios_notified: Arc<AtomicBool>,
|
|
||||||
aura_notified: Arc<AtomicBool>,
|
|
||||||
anime_notified: Arc<AtomicBool>,
|
|
||||||
profiles_notified: Arc<AtomicBool>,
|
|
||||||
_fans_notified: Arc<AtomicBool>,
|
|
||||||
enabled_notifications: Arc<Mutex<EnabledNotifications>>,
|
enabled_notifications: Arc<Mutex<EnabledNotifications>>,
|
||||||
update_tray: Arc<std::sync::Mutex<Sender<AppToTray>>>,
|
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let last_notification: SharedHandle = Arc::new(Mutex::new(None));
|
let last_notification: SharedHandle = Arc::new(Mutex::new(None));
|
||||||
|
|
||||||
@@ -129,10 +125,11 @@ pub fn start_notifications(
|
|||||||
recv_notif!(
|
recv_notif!(
|
||||||
RogBiosProxy,
|
RogBiosProxy,
|
||||||
receive_notify_post_boot_sound,
|
receive_notify_post_boot_sound,
|
||||||
bios_notified,
|
|
||||||
last_notification,
|
last_notification,
|
||||||
enabled_notifications,
|
enabled_notifications,
|
||||||
[on],
|
page_states,
|
||||||
|
(bios.post_sound),
|
||||||
|
(on),
|
||||||
"BIOS Post sound",
|
"BIOS Post sound",
|
||||||
do_notification
|
do_notification
|
||||||
);
|
);
|
||||||
@@ -140,10 +137,11 @@ pub fn start_notifications(
|
|||||||
recv_notif!(
|
recv_notif!(
|
||||||
RogBiosProxy,
|
RogBiosProxy,
|
||||||
receive_notify_panel_od,
|
receive_notify_panel_od,
|
||||||
bios_notified,
|
|
||||||
last_notification,
|
last_notification,
|
||||||
enabled_notifications,
|
enabled_notifications,
|
||||||
[overdrive],
|
page_states,
|
||||||
|
(bios.panel_overdrive),
|
||||||
|
(overdrive),
|
||||||
"Panel Overdrive enabled:",
|
"Panel Overdrive enabled:",
|
||||||
do_notification
|
do_notification
|
||||||
);
|
);
|
||||||
@@ -151,10 +149,11 @@ pub fn start_notifications(
|
|||||||
recv_notif!(
|
recv_notif!(
|
||||||
RogBiosProxy,
|
RogBiosProxy,
|
||||||
receive_notify_dgpu_disable,
|
receive_notify_dgpu_disable,
|
||||||
bios_notified,
|
|
||||||
last_notification,
|
last_notification,
|
||||||
enabled_notifications,
|
enabled_notifications,
|
||||||
[disable],
|
page_states,
|
||||||
|
(bios.dgpu_disable),
|
||||||
|
(disable),
|
||||||
"BIOS dGPU disabled",
|
"BIOS dGPU disabled",
|
||||||
do_notification
|
do_notification
|
||||||
);
|
);
|
||||||
@@ -162,10 +161,11 @@ pub fn start_notifications(
|
|||||||
recv_notif!(
|
recv_notif!(
|
||||||
RogBiosProxy,
|
RogBiosProxy,
|
||||||
receive_notify_egpu_enable,
|
receive_notify_egpu_enable,
|
||||||
bios_notified,
|
|
||||||
last_notification,
|
last_notification,
|
||||||
enabled_notifications,
|
enabled_notifications,
|
||||||
[enable],
|
page_states,
|
||||||
|
(bios.egpu_enable),
|
||||||
|
(enable),
|
||||||
"BIOS eGPU enabled",
|
"BIOS eGPU enabled",
|
||||||
do_notification
|
do_notification
|
||||||
);
|
);
|
||||||
@@ -173,10 +173,11 @@ pub fn start_notifications(
|
|||||||
recv_notif!(
|
recv_notif!(
|
||||||
RogBiosProxy,
|
RogBiosProxy,
|
||||||
receive_notify_gpu_mux_mode,
|
receive_notify_gpu_mux_mode,
|
||||||
bios_notified,
|
|
||||||
last_notification,
|
last_notification,
|
||||||
enabled_notifications,
|
enabled_notifications,
|
||||||
[mode],
|
page_states,
|
||||||
|
(bios.dedicated_gfx),
|
||||||
|
(mode),
|
||||||
"Reboot required. BIOS GPU MUX mode set to",
|
"Reboot required. BIOS GPU MUX mode set to",
|
||||||
do_mux_notification
|
do_mux_notification
|
||||||
);
|
);
|
||||||
@@ -185,10 +186,11 @@ pub fn start_notifications(
|
|||||||
recv_notif!(
|
recv_notif!(
|
||||||
PowerProxy,
|
PowerProxy,
|
||||||
receive_notify_charge_control_end_threshold,
|
receive_notify_charge_control_end_threshold,
|
||||||
charge_notified,
|
|
||||||
last_notification,
|
last_notification,
|
||||||
enabled_notifications,
|
enabled_notifications,
|
||||||
[limit],
|
page_states,
|
||||||
|
(power_state.charge_limit),
|
||||||
|
(limit),
|
||||||
"Battery charge limit changed to",
|
"Battery charge limit changed to",
|
||||||
do_notification
|
do_notification
|
||||||
);
|
);
|
||||||
@@ -196,10 +198,11 @@ pub fn start_notifications(
|
|||||||
recv_notif!(
|
recv_notif!(
|
||||||
PowerProxy,
|
PowerProxy,
|
||||||
receive_notify_mains_online,
|
receive_notify_mains_online,
|
||||||
bios_notified,
|
|
||||||
last_notification,
|
last_notification,
|
||||||
enabled_notifications,
|
enabled_notifications,
|
||||||
[on],
|
page_states,
|
||||||
|
(power_state.ac_power),
|
||||||
|
(on),
|
||||||
"AC Power power is",
|
"AC Power power is",
|
||||||
ac_power_notification
|
ac_power_notification
|
||||||
);
|
);
|
||||||
@@ -208,10 +211,11 @@ pub fn start_notifications(
|
|||||||
recv_notif!(
|
recv_notif!(
|
||||||
ProfileProxy,
|
ProfileProxy,
|
||||||
receive_notify_profile,
|
receive_notify_profile,
|
||||||
profiles_notified,
|
|
||||||
last_notification,
|
last_notification,
|
||||||
enabled_notifications,
|
enabled_notifications,
|
||||||
[profile],
|
page_states,
|
||||||
|
(profiles.current),
|
||||||
|
(profile),
|
||||||
"Profile changed to",
|
"Profile changed to",
|
||||||
do_thermal_notif
|
do_thermal_notif
|
||||||
);
|
);
|
||||||
@@ -221,32 +225,24 @@ pub fn start_notifications(
|
|||||||
recv_notif!(
|
recv_notif!(
|
||||||
LedProxy,
|
LedProxy,
|
||||||
receive_notify_led,
|
receive_notify_led,
|
||||||
aura_notified,
|
|
||||||
last_notification,
|
last_notification,
|
||||||
enabled_notifications,
|
enabled_notifications,
|
||||||
[data mode_name],
|
page_states,
|
||||||
|
(aura.current_mode),
|
||||||
|
(data.mode),
|
||||||
"Keyboard LED mode changed to",
|
"Keyboard LED mode changed to",
|
||||||
do_notification
|
do_notification
|
||||||
);
|
);
|
||||||
|
|
||||||
tokio::spawn(async move {
|
let page_states1 = page_states.clone();
|
||||||
let conn = zbus::Connection::system().await.unwrap();
|
|
||||||
let proxy = LedProxy::new(&conn).await.unwrap();
|
|
||||||
if let Ok(p) = proxy.receive_all_signals().await {
|
|
||||||
p.for_each(|_| {
|
|
||||||
aura_notified.store(true, Ordering::SeqCst);
|
|
||||||
future::ready(())
|
|
||||||
})
|
|
||||||
.await;
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
let conn = zbus::Connection::system().await.unwrap();
|
let conn = zbus::Connection::system().await.unwrap();
|
||||||
let proxy = AnimeProxy::new(&conn).await.unwrap();
|
let proxy = AnimeProxy::new(&conn).await.unwrap();
|
||||||
if let Ok(p) = proxy.receive_power_states().await {
|
if let Ok(p) = proxy.receive_power_states().await {
|
||||||
p.for_each(|_| {
|
p.for_each(|_| {
|
||||||
anime_notified.store(true, Ordering::SeqCst);
|
if let Ok(_lock) = page_states1.lock() {
|
||||||
|
// TODO: lock.anime.
|
||||||
|
}
|
||||||
future::ready(())
|
future::ready(())
|
||||||
})
|
})
|
||||||
.await;
|
.await;
|
||||||
@@ -256,10 +252,11 @@ pub fn start_notifications(
|
|||||||
recv_notif!(
|
recv_notif!(
|
||||||
SuperProxy,
|
SuperProxy,
|
||||||
receive_notify_gfx,
|
receive_notify_gfx,
|
||||||
bios_notified,
|
|
||||||
last_notification,
|
last_notification,
|
||||||
enabled_notifications,
|
enabled_notifications,
|
||||||
[mode],
|
page_states,
|
||||||
|
(gfx_state.mode),
|
||||||
|
(mode),
|
||||||
"Gfx mode changed to",
|
"Gfx mode changed to",
|
||||||
do_notification
|
do_notification
|
||||||
);
|
);
|
||||||
@@ -275,7 +272,6 @@ pub fn start_notifications(
|
|||||||
// do_gfx_action_notif
|
// do_gfx_action_notif
|
||||||
// );
|
// );
|
||||||
|
|
||||||
let bios_notified1 = bios_notified.clone();
|
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
let conn = zbus::Connection::system().await.unwrap();
|
let conn = zbus::Connection::system().await.unwrap();
|
||||||
let proxy = SuperProxy::new(&conn).await.unwrap();
|
let proxy = SuperProxy::new(&conn).await.unwrap();
|
||||||
@@ -287,39 +283,37 @@ pub fn start_notifications(
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bios_notified1.store(true, Ordering::SeqCst);
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
let notifs_enabled1 = enabled_notifications;
|
let notifs_enabled1 = enabled_notifications;
|
||||||
let last_notif = last_notification;
|
let last_notif = last_notification;
|
||||||
let bios_notified1 = bios_notified;
|
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
let conn = zbus::Connection::system().await.unwrap();
|
let conn = zbus::Connection::system().await.unwrap();
|
||||||
let proxy = SuperProxy::new(&conn).await.unwrap();
|
let proxy = SuperProxy::new(&conn).await.unwrap();
|
||||||
if let Ok(mut p) = proxy.receive_notify_gfx_status().await {
|
if let Ok(mut p) = proxy.receive_notify_gfx_status().await {
|
||||||
while let Some(e) = p.next().await {
|
while let Some(e) = p.next().await {
|
||||||
if let Ok(out) = e.args() {
|
if let Ok(out) = e.args() {
|
||||||
let status = out.status();
|
let status = out.status;
|
||||||
if *status != GfxPower::Unknown {
|
if status != GfxPower::Unknown {
|
||||||
if let Ok(config) = notifs_enabled1.lock() {
|
if let Ok(config) = notifs_enabled1.lock() {
|
||||||
if config.all_enabled && config.receive_notify_gfx_status {
|
if config.all_enabled && config.receive_notify_gfx_status {
|
||||||
// Required check because status cycles through active/unknown/suspended
|
// Required check because status cycles through active/unknown/suspended
|
||||||
if let Ok(ref mut lock) = last_notif.try_lock() {
|
if let Ok(ref mut lock) = last_notif.lock() {
|
||||||
notify!(
|
notify!(
|
||||||
do_gpu_status_notif("dGPU status changed:", status),
|
do_gpu_status_notif("dGPU status changed:", &status),
|
||||||
lock
|
lock
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Ok(lock) = update_tray.try_lock() {
|
if let Ok(mut lock) = page_states.lock() {
|
||||||
lock.send(AppToTray::DgpuStatus(*status)).ok();
|
lock.gfx_state.power_status = status;
|
||||||
|
lock.set_notified();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bios_notified1.store(true, Ordering::SeqCst);
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,16 @@
|
|||||||
use std::{
|
use std::{
|
||||||
collections::{BTreeMap, HashSet},
|
collections::{BTreeMap, HashSet},
|
||||||
sync::{
|
sync::{Arc, Mutex},
|
||||||
atomic::{AtomicBool, Ordering},
|
|
||||||
Arc, Mutex,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use egui::Vec2;
|
use egui::Vec2;
|
||||||
use rog_aura::{layouts::KeyLayout, usb::AuraPowerDev, AuraEffect, AuraModeNum};
|
use rog_aura::{layouts::KeyLayout, usb::AuraPowerDev, AuraEffect, AuraModeNum};
|
||||||
use rog_platform::{platform::GpuMode, supported::SupportedFunctions};
|
use rog_platform::{platform::GpuMode, supported::SupportedFunctions};
|
||||||
use rog_profiles::{fan_curve_set::FanCurveSet, FanCurvePU, Profile};
|
use rog_profiles::{fan_curve_set::FanCurveSet, FanCurvePU, Profile};
|
||||||
|
use supergfxctl::{
|
||||||
|
pci_device::{GfxMode, GfxPower},
|
||||||
|
zbus_proxy::DaemonProxyBlocking as GfxProxyBlocking,
|
||||||
|
};
|
||||||
|
|
||||||
use crate::{error::Result, notify::EnabledNotifications, RogDbusClientBlocking};
|
use crate::{error::Result, notify::EnabledNotifications, RogDbusClientBlocking};
|
||||||
|
|
||||||
@@ -18,7 +19,6 @@ pub struct BiosState {
|
|||||||
/// To be shared to a thread that checks notifications.
|
/// To be shared to a thread that checks notifications.
|
||||||
/// It's a bit general in that it won't provide *what* was
|
/// It's a bit general in that it won't provide *what* was
|
||||||
/// updated, so the full state needs refresh
|
/// updated, so the full state needs refresh
|
||||||
pub was_notified: Arc<AtomicBool>,
|
|
||||||
pub post_sound: bool,
|
pub post_sound: bool,
|
||||||
pub dedicated_gfx: GpuMode,
|
pub dedicated_gfx: GpuMode,
|
||||||
pub panel_overdrive: bool,
|
pub panel_overdrive: bool,
|
||||||
@@ -27,13 +27,8 @@ pub struct BiosState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl BiosState {
|
impl BiosState {
|
||||||
pub fn new(
|
pub fn new(supported: &SupportedFunctions, dbus: &RogDbusClientBlocking) -> Result<Self> {
|
||||||
was_notified: Arc<AtomicBool>,
|
|
||||||
supported: &SupportedFunctions,
|
|
||||||
dbus: &RogDbusClientBlocking,
|
|
||||||
) -> Result<Self> {
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
was_notified,
|
|
||||||
post_sound: if supported.rog_bios_ctrl.post_sound {
|
post_sound: if supported.rog_bios_ctrl.post_sound {
|
||||||
dbus.proxies().rog_bios().post_boot_sound()? != 0
|
dbus.proxies().rog_bios().post_boot_sound()? != 0
|
||||||
} else {
|
} else {
|
||||||
@@ -58,19 +53,13 @@ impl BiosState {
|
|||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct ProfilesState {
|
pub struct ProfilesState {
|
||||||
pub was_notified: Arc<AtomicBool>,
|
|
||||||
pub list: Vec<Profile>,
|
pub list: Vec<Profile>,
|
||||||
pub current: Profile,
|
pub current: Profile,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ProfilesState {
|
impl ProfilesState {
|
||||||
pub fn new(
|
pub fn new(supported: &SupportedFunctions, dbus: &RogDbusClientBlocking) -> Result<Self> {
|
||||||
was_notified: Arc<AtomicBool>,
|
|
||||||
supported: &SupportedFunctions,
|
|
||||||
dbus: &RogDbusClientBlocking,
|
|
||||||
) -> Result<Self> {
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
was_notified,
|
|
||||||
list: if supported.platform_profile.platform_profile {
|
list: if supported.platform_profile.platform_profile {
|
||||||
let mut list = dbus.proxies().profile().profiles()?;
|
let mut list = dbus.proxies().profile().profiles()?;
|
||||||
list.sort();
|
list.sort();
|
||||||
@@ -89,7 +78,6 @@ impl ProfilesState {
|
|||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct FanCurvesState {
|
pub struct FanCurvesState {
|
||||||
pub was_notified: Arc<AtomicBool>,
|
|
||||||
pub show_curve: Profile,
|
pub show_curve: Profile,
|
||||||
pub show_graph: FanCurvePU,
|
pub show_graph: FanCurvePU,
|
||||||
pub enabled: HashSet<Profile>,
|
pub enabled: HashSet<Profile>,
|
||||||
@@ -98,11 +86,7 @@ pub struct FanCurvesState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl FanCurvesState {
|
impl FanCurvesState {
|
||||||
pub fn new(
|
pub fn new(supported: &SupportedFunctions, dbus: &RogDbusClientBlocking) -> Result<Self> {
|
||||||
was_notified: Arc<AtomicBool>,
|
|
||||||
supported: &SupportedFunctions,
|
|
||||||
dbus: &RogDbusClientBlocking,
|
|
||||||
) -> Result<Self> {
|
|
||||||
let profiles = if supported.platform_profile.platform_profile {
|
let profiles = if supported.platform_profile.platform_profile {
|
||||||
dbus.proxies().profile().profiles()?
|
dbus.proxies().profile().profiles()?
|
||||||
} else {
|
} else {
|
||||||
@@ -143,7 +127,6 @@ impl FanCurvesState {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
was_notified,
|
|
||||||
show_curve,
|
show_curve,
|
||||||
show_graph: FanCurvePU::CPU,
|
show_graph: FanCurvePU::CPU,
|
||||||
enabled,
|
enabled,
|
||||||
@@ -155,7 +138,6 @@ impl FanCurvesState {
|
|||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct AuraState {
|
pub struct AuraState {
|
||||||
pub was_notified: Arc<AtomicBool>,
|
|
||||||
pub current_mode: AuraModeNum,
|
pub current_mode: AuraModeNum,
|
||||||
pub modes: BTreeMap<AuraModeNum, AuraEffect>,
|
pub modes: BTreeMap<AuraModeNum, AuraEffect>,
|
||||||
pub enabled: AuraPowerDev,
|
pub enabled: AuraPowerDev,
|
||||||
@@ -167,13 +149,8 @@ pub struct AuraState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl AuraState {
|
impl AuraState {
|
||||||
pub fn new(
|
pub fn new(supported: &SupportedFunctions, dbus: &RogDbusClientBlocking) -> Result<Self> {
|
||||||
was_notified: Arc<AtomicBool>,
|
|
||||||
supported: &SupportedFunctions,
|
|
||||||
dbus: &RogDbusClientBlocking,
|
|
||||||
) -> Result<Self> {
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
was_notified,
|
|
||||||
current_mode: if !supported.keyboard_led.stock_led_modes.is_empty() {
|
current_mode: if !supported.keyboard_led.stock_led_modes.is_empty() {
|
||||||
dbus.proxies().led().led_mode().unwrap_or_default()
|
dbus.proxies().led().led_mode().unwrap_or_default()
|
||||||
} else {
|
} else {
|
||||||
@@ -214,7 +191,6 @@ impl AuraState {
|
|||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct AnimeState {
|
pub struct AnimeState {
|
||||||
pub was_notified: Arc<AtomicBool>,
|
|
||||||
pub bright: u8,
|
pub bright: u8,
|
||||||
pub boot: bool,
|
pub boot: bool,
|
||||||
pub awake: bool,
|
pub awake: bool,
|
||||||
@@ -222,13 +198,8 @@ pub struct AnimeState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl AnimeState {
|
impl AnimeState {
|
||||||
pub fn new(
|
pub fn new(supported: &SupportedFunctions, dbus: &RogDbusClientBlocking) -> Result<Self> {
|
||||||
was_notified: Arc<AtomicBool>,
|
|
||||||
supported: &SupportedFunctions,
|
|
||||||
dbus: &RogDbusClientBlocking,
|
|
||||||
) -> Result<Self> {
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
was_notified,
|
|
||||||
boot: if supported.anime_ctrl.0 {
|
boot: if supported.anime_ctrl.0 {
|
||||||
dbus.proxies().anime().boot_enabled()?
|
dbus.proxies().anime().boot_enabled()?
|
||||||
} else {
|
} else {
|
||||||
@@ -246,11 +217,39 @@ impl AnimeState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Clone, Debug)]
|
||||||
|
pub struct GfxState {
|
||||||
|
pub mode: GfxMode,
|
||||||
|
pub power_status: GfxPower,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl GfxState {
|
||||||
|
pub fn new(_supported: &SupportedFunctions, dbus: &GfxProxyBlocking) -> Result<Self> {
|
||||||
|
Ok(Self {
|
||||||
|
mode: dbus.mode()?,
|
||||||
|
power_status: dbus.power()?,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug)]
|
||||||
|
pub struct PowerState {
|
||||||
|
pub charge_limit: u8,
|
||||||
|
pub ac_power: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PowerState {
|
||||||
|
pub fn new(_supported: &SupportedFunctions, dbus: &RogDbusClientBlocking) -> Result<Self> {
|
||||||
|
Ok(Self {
|
||||||
|
charge_limit: dbus.proxies().charge().charge_control_end_threshold()?,
|
||||||
|
ac_power: dbus.proxies().charge().mains_online()?,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub struct PageDataStates {
|
pub struct PageDataStates {
|
||||||
pub keyboard_layout: KeyLayout,
|
pub keyboard_layout: KeyLayout,
|
||||||
pub enabled_notifications: Arc<Mutex<EnabledNotifications>>,
|
pub enabled_notifications: Arc<Mutex<EnabledNotifications>>,
|
||||||
pub was_notified: Arc<AtomicBool>,
|
|
||||||
/// Because much of the app state here is the same as `RogBiosSupportedFunctions`
|
/// Because much of the app state here is the same as `RogBiosSupportedFunctions`
|
||||||
/// we can re-use that structure.
|
/// we can re-use that structure.
|
||||||
pub bios: BiosState,
|
pub bios: BiosState,
|
||||||
@@ -258,87 +257,59 @@ pub struct PageDataStates {
|
|||||||
pub anime: AnimeState,
|
pub anime: AnimeState,
|
||||||
pub profiles: ProfilesState,
|
pub profiles: ProfilesState,
|
||||||
pub fan_curves: FanCurvesState,
|
pub fan_curves: FanCurvesState,
|
||||||
pub charge_limit: u8,
|
pub gfx_state: GfxState,
|
||||||
|
pub power_state: PowerState,
|
||||||
pub error: Option<String>,
|
pub error: Option<String>,
|
||||||
|
/// Specific field for the tray only so that we can know when it does need update.
|
||||||
|
/// The tray should set this to false when done.
|
||||||
|
pub tray_should_update: bool,
|
||||||
|
pub app_should_update: bool,
|
||||||
|
pub asus_dbus: RogDbusClientBlocking<'static>,
|
||||||
|
pub gfx_dbus: GfxProxyBlocking<'static>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
|
||||||
impl PageDataStates {
|
impl PageDataStates {
|
||||||
|
/// Creates self, including the relevant dbus connections and proixies for internal use
|
||||||
pub fn new(
|
pub fn new(
|
||||||
keyboard_layout: KeyLayout,
|
keyboard_layout: KeyLayout,
|
||||||
enabled_notifications: Arc<Mutex<EnabledNotifications>>,
|
enabled_notifications: Arc<Mutex<EnabledNotifications>>,
|
||||||
charge_notified: Arc<AtomicBool>,
|
|
||||||
bios_notified: Arc<AtomicBool>,
|
|
||||||
aura_notified: Arc<AtomicBool>,
|
|
||||||
anime_notified: Arc<AtomicBool>,
|
|
||||||
profiles_notified: Arc<AtomicBool>,
|
|
||||||
fans_notified: Arc<AtomicBool>,
|
|
||||||
supported: &SupportedFunctions,
|
supported: &SupportedFunctions,
|
||||||
dbus: &RogDbusClientBlocking,
|
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
|
let (asus_dbus, conn) = RogDbusClientBlocking::new().unwrap();
|
||||||
|
let gfx_dbus = GfxProxyBlocking::new(&conn).unwrap();
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
keyboard_layout,
|
keyboard_layout,
|
||||||
enabled_notifications,
|
enabled_notifications,
|
||||||
was_notified: charge_notified,
|
power_state: PowerState::new(supported, &asus_dbus)?,
|
||||||
charge_limit: dbus.proxies().charge().charge_control_end_threshold()?,
|
bios: BiosState::new(supported, &asus_dbus)?,
|
||||||
bios: BiosState::new(bios_notified, supported, dbus)?,
|
aura: AuraState::new(supported, &asus_dbus)?,
|
||||||
aura: AuraState::new(aura_notified, supported, dbus)?,
|
anime: AnimeState::new(supported, &asus_dbus)?,
|
||||||
anime: AnimeState::new(anime_notified, supported, dbus)?,
|
profiles: ProfilesState::new(supported, &asus_dbus)?,
|
||||||
profiles: ProfilesState::new(profiles_notified, supported, dbus)?,
|
fan_curves: FanCurvesState::new(supported, &asus_dbus)?,
|
||||||
fan_curves: FanCurvesState::new(fans_notified, supported, dbus)?,
|
gfx_state: GfxState::new(supported, &gfx_dbus)?,
|
||||||
error: None,
|
error: None,
|
||||||
|
tray_should_update: true,
|
||||||
|
app_should_update: true,
|
||||||
|
asus_dbus,
|
||||||
|
gfx_dbus,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn refresh_if_notfied(
|
pub fn set_notified(&mut self) {
|
||||||
&mut self,
|
self.tray_should_update = true;
|
||||||
supported: &SupportedFunctions,
|
self.app_should_update = true;
|
||||||
dbus: &RogDbusClientBlocking,
|
|
||||||
) -> Result<bool> {
|
|
||||||
let mut notified = false;
|
|
||||||
if self.was_notified.load(Ordering::SeqCst) {
|
|
||||||
self.charge_limit = dbus.proxies().charge().charge_control_end_threshold()?;
|
|
||||||
self.was_notified.store(false, Ordering::SeqCst);
|
|
||||||
notified = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if self.aura.was_notified.load(Ordering::SeqCst) {
|
|
||||||
self.aura = AuraState::new(self.aura.was_notified.clone(), supported, dbus)?;
|
|
||||||
self.aura.was_notified.store(false, Ordering::SeqCst);
|
|
||||||
notified = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if self.bios.was_notified.load(Ordering::SeqCst) {
|
|
||||||
self.bios = BiosState::new(self.bios.was_notified.clone(), supported, dbus)?;
|
|
||||||
self.bios.was_notified.store(false, Ordering::SeqCst);
|
|
||||||
notified = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if self.profiles.was_notified.load(Ordering::SeqCst) {
|
|
||||||
self.profiles =
|
|
||||||
ProfilesState::new(self.profiles.was_notified.clone(), supported, dbus)?;
|
|
||||||
self.profiles.was_notified.store(false, Ordering::SeqCst);
|
|
||||||
notified = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if self.fan_curves.was_notified.load(Ordering::SeqCst) {
|
|
||||||
self.fan_curves =
|
|
||||||
FanCurvesState::new(self.fan_curves.was_notified.clone(), supported, dbus)?;
|
|
||||||
self.fan_curves.was_notified.store(false, Ordering::SeqCst);
|
|
||||||
notified = true;
|
|
||||||
}
|
|
||||||
Ok(notified)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for PageDataStates {
|
impl Default for PageDataStates {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
|
let (asus_dbus, conn) = RogDbusClientBlocking::new().unwrap();
|
||||||
|
let gfx_dbus = GfxProxyBlocking::new(&conn).unwrap();
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
keyboard_layout: KeyLayout::ga401_layout(),
|
keyboard_layout: KeyLayout::ga401_layout(),
|
||||||
enabled_notifications: Default::default(),
|
enabled_notifications: Default::default(),
|
||||||
was_notified: Default::default(),
|
|
||||||
bios: BiosState {
|
bios: BiosState {
|
||||||
was_notified: Default::default(),
|
|
||||||
post_sound: Default::default(),
|
post_sound: Default::default(),
|
||||||
dedicated_gfx: GpuMode::NotSupported,
|
dedicated_gfx: GpuMode::NotSupported,
|
||||||
panel_overdrive: Default::default(),
|
panel_overdrive: Default::default(),
|
||||||
@@ -346,7 +317,6 @@ impl Default for PageDataStates {
|
|||||||
egpu_enable: Default::default(),
|
egpu_enable: Default::default(),
|
||||||
},
|
},
|
||||||
aura: AuraState {
|
aura: AuraState {
|
||||||
was_notified: Default::default(),
|
|
||||||
current_mode: AuraModeNum::Static,
|
current_mode: AuraModeNum::Static,
|
||||||
modes: Default::default(),
|
modes: Default::default(),
|
||||||
enabled: AuraPowerDev {
|
enabled: AuraPowerDev {
|
||||||
@@ -360,27 +330,35 @@ impl Default for PageDataStates {
|
|||||||
wave_blue: Default::default(),
|
wave_blue: Default::default(),
|
||||||
},
|
},
|
||||||
anime: AnimeState {
|
anime: AnimeState {
|
||||||
was_notified: Default::default(),
|
|
||||||
bright: Default::default(),
|
bright: Default::default(),
|
||||||
boot: Default::default(),
|
boot: Default::default(),
|
||||||
awake: Default::default(),
|
awake: Default::default(),
|
||||||
sleep: Default::default(),
|
sleep: Default::default(),
|
||||||
},
|
},
|
||||||
profiles: ProfilesState {
|
profiles: ProfilesState {
|
||||||
was_notified: Default::default(),
|
|
||||||
list: Default::default(),
|
list: Default::default(),
|
||||||
current: Default::default(),
|
current: Default::default(),
|
||||||
},
|
},
|
||||||
fan_curves: FanCurvesState {
|
fan_curves: FanCurvesState {
|
||||||
was_notified: Default::default(),
|
|
||||||
show_curve: Default::default(),
|
show_curve: Default::default(),
|
||||||
show_graph: Default::default(),
|
show_graph: Default::default(),
|
||||||
enabled: Default::default(),
|
enabled: Default::default(),
|
||||||
curves: Default::default(),
|
curves: Default::default(),
|
||||||
drag_delta: Default::default(),
|
drag_delta: Default::default(),
|
||||||
},
|
},
|
||||||
charge_limit: Default::default(),
|
gfx_state: GfxState {
|
||||||
|
mode: GfxMode::None,
|
||||||
|
power_status: GfxPower::Unknown,
|
||||||
|
},
|
||||||
|
power_state: PowerState {
|
||||||
|
charge_limit: 99,
|
||||||
|
ac_power: false,
|
||||||
|
},
|
||||||
error: Default::default(),
|
error: Default::default(),
|
||||||
|
tray_should_update: true,
|
||||||
|
app_should_update: true,
|
||||||
|
asus_dbus,
|
||||||
|
gfx_dbus,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use crate::RogApp;
|
use crate::RogApp;
|
||||||
|
|
||||||
impl<'a> RogApp<'a> {
|
impl RogApp {
|
||||||
pub fn anime_page(&mut self, ctx: &egui::Context) {
|
pub fn anime_page(&mut self, ctx: &egui::Context) {
|
||||||
egui::CentralPanel::default().show(ctx, |ui| {
|
egui::CentralPanel::default().show(ctx, |ui| {
|
||||||
ui.label("In progress");
|
ui.label("In progress");
|
||||||
|
|||||||
@@ -4,16 +4,15 @@ use egui::Color32;
|
|||||||
use rog_aura::{AuraEffect, AuraModeNum};
|
use rog_aura::{AuraEffect, AuraModeNum};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
page_states::PageDataStates,
|
||||||
widgets::{aura_modes_group, keyboard},
|
widgets::{aura_modes_group, keyboard},
|
||||||
RogApp,
|
RogApp,
|
||||||
};
|
};
|
||||||
|
|
||||||
impl<'a> RogApp<'a> {
|
impl RogApp {
|
||||||
pub fn aura_page(&mut self, ctx: &egui::Context) {
|
pub fn aura_page(&mut self, states: &mut PageDataStates, ctx: &egui::Context) {
|
||||||
let Self {
|
let Self {
|
||||||
supported,
|
supported,
|
||||||
states,
|
|
||||||
asus_dbus: dbus,
|
|
||||||
oscillator1,
|
oscillator1,
|
||||||
oscillator2,
|
oscillator2,
|
||||||
oscillator3,
|
oscillator3,
|
||||||
@@ -26,7 +25,6 @@ impl<'a> RogApp<'a> {
|
|||||||
let blue = oscillator3.load(Ordering::SeqCst) as u32;
|
let blue = oscillator3.load(Ordering::SeqCst) as u32;
|
||||||
states.aura.nudge_wave(red as u8, green as u8, blue as u8);
|
states.aura.nudge_wave(red as u8, green as u8, blue as u8);
|
||||||
// let osc = c.0 * 255 / osc;
|
// let osc = c.0 * 255 / osc;
|
||||||
// dbg!(osc);
|
|
||||||
let c1 = states
|
let c1 = states
|
||||||
.aura
|
.aura
|
||||||
.modes
|
.modes
|
||||||
@@ -72,7 +70,7 @@ impl<'a> RogApp<'a> {
|
|||||||
|
|
||||||
// TODO: animation of colour changes/periods/blending
|
// TODO: animation of colour changes/periods/blending
|
||||||
egui::CentralPanel::default().show(ctx, |ui| {
|
egui::CentralPanel::default().show(ctx, |ui| {
|
||||||
aura_modes_group(supported, states, oscillator_freq, dbus, ui);
|
aura_modes_group(supported, states, oscillator_freq, ui);
|
||||||
|
|
||||||
keyboard(ui, &states.keyboard_layout, &mut states.aura, colour);
|
keyboard(ui, &states.keyboard_layout, &mut states.aura, colour);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
page_states::{FanCurvesState, ProfilesState},
|
page_states::{FanCurvesState, PageDataStates, ProfilesState},
|
||||||
widgets::fan_graphs,
|
widgets::fan_graphs,
|
||||||
RogApp, RogDbusClientBlocking,
|
RogApp, RogDbusClientBlocking,
|
||||||
};
|
};
|
||||||
@@ -7,14 +7,9 @@ use egui::Ui;
|
|||||||
use rog_platform::supported::SupportedFunctions;
|
use rog_platform::supported::SupportedFunctions;
|
||||||
use rog_profiles::Profile;
|
use rog_profiles::Profile;
|
||||||
|
|
||||||
impl<'a> RogApp<'a> {
|
impl RogApp {
|
||||||
pub fn fan_curve_page(&mut self, ctx: &egui::Context) {
|
pub fn fan_curve_page(&mut self, states: &mut PageDataStates, ctx: &egui::Context) {
|
||||||
let Self {
|
let Self { supported, .. } = self;
|
||||||
supported,
|
|
||||||
states,
|
|
||||||
asus_dbus: dbus,
|
|
||||||
..
|
|
||||||
} = self;
|
|
||||||
|
|
||||||
egui::CentralPanel::default().show(ctx, |ui| {
|
egui::CentralPanel::default().show(ctx, |ui| {
|
||||||
ui.heading("Custom fan curves");
|
ui.heading("Custom fan curves");
|
||||||
@@ -23,11 +18,11 @@ impl<'a> RogApp<'a> {
|
|||||||
supported,
|
supported,
|
||||||
&mut states.profiles,
|
&mut states.profiles,
|
||||||
&mut states.fan_curves,
|
&mut states.fan_curves,
|
||||||
dbus, &mut states.error,
|
&states.asus_dbus, &mut states.error,
|
||||||
ui,
|
ui,
|
||||||
);
|
);
|
||||||
|
|
||||||
fan_graphs(supported, &mut states.profiles, &mut states.fan_curves, dbus, &mut states.error, ui);
|
fan_graphs(supported, &mut states.profiles, &mut states.fan_curves, &states.asus_dbus, &mut states.error, ui);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,8 +71,7 @@ impl<'a> RogApp<'a> {
|
|||||||
let selected_profile = curves.show_curve;
|
let selected_profile = curves.show_curve;
|
||||||
let selected_pu = curves.show_graph;
|
let selected_pu = curves.show_graph;
|
||||||
|
|
||||||
let notif = curves.was_notified.clone();
|
match FanCurvesState::new(supported, dbus) {
|
||||||
match FanCurvesState::new(notif, supported, dbus) {
|
|
||||||
Ok(f) => *curves = f,
|
Ok(f) => *curves = f,
|
||||||
Err(e) => *do_error = Some(e.to_string()),
|
Err(e) => *do_error = Some(e.to_string()),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,15 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
|
page_states::PageDataStates,
|
||||||
widgets::{
|
widgets::{
|
||||||
anime_power_group, app_settings, aura_power_group, platform_profile, rog_bios_group,
|
anime_power_group, app_settings, aura_power_group, platform_profile, rog_bios_group,
|
||||||
},
|
},
|
||||||
RogApp,
|
RogApp,
|
||||||
};
|
};
|
||||||
|
|
||||||
impl<'a> RogApp<'a> {
|
impl RogApp {
|
||||||
pub fn system_page(&mut self, ctx: &egui::Context) {
|
pub fn system_page(&mut self, states: &mut PageDataStates, ctx: &egui::Context) {
|
||||||
let Self {
|
let Self {
|
||||||
config,
|
config, supported, ..
|
||||||
supported,
|
|
||||||
states,
|
|
||||||
asus_dbus: dbus,
|
|
||||||
..
|
|
||||||
} = self;
|
} = self;
|
||||||
|
|
||||||
egui::CentralPanel::default().show(ctx, |ui| {
|
egui::CentralPanel::default().show(ctx, |ui| {
|
||||||
@@ -28,12 +25,12 @@ impl<'a> RogApp<'a> {
|
|||||||
ui.vertical(|ui| {
|
ui.vertical(|ui| {
|
||||||
ui.separator();
|
ui.separator();
|
||||||
if supported.platform_profile.platform_profile {
|
if supported.platform_profile.platform_profile {
|
||||||
platform_profile(states, dbus, ui);
|
platform_profile(states, ui);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
ui.vertical(|ui| {
|
ui.vertical(|ui| {
|
||||||
ui.separator();
|
ui.separator();
|
||||||
aura_power_group(supported, states, dbus, ui);
|
aura_power_group(supported, states, ui);
|
||||||
});
|
});
|
||||||
ui.end_row();
|
ui.end_row();
|
||||||
|
|
||||||
@@ -44,7 +41,7 @@ impl<'a> RogApp<'a> {
|
|||||||
});
|
});
|
||||||
ui.vertical(|ui| {
|
ui.vertical(|ui| {
|
||||||
ui.separator();
|
ui.separator();
|
||||||
rog_bios_group(supported, states, dbus, ui);
|
rog_bios_group(supported, states, ui);
|
||||||
});
|
});
|
||||||
ui.end_row();
|
ui.end_row();
|
||||||
|
|
||||||
@@ -52,7 +49,7 @@ impl<'a> RogApp<'a> {
|
|||||||
ui.vertical(|ui| {
|
ui.vertical(|ui| {
|
||||||
ui.separator();
|
ui.separator();
|
||||||
if supported.anime_ctrl.0 {
|
if supported.anime_ctrl.0 {
|
||||||
anime_power_group(supported, states, dbus, ui);
|
anime_power_group(supported, states, ui);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
ui.vertical(|ui| {
|
ui.vertical(|ui| {
|
||||||
|
|||||||
+153
-91
@@ -10,12 +10,18 @@ use std::{
|
|||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
|
|
||||||
use gtk::{gio::Icon, prelude::*, MenuItem};
|
use gtk::{gio::Icon, prelude::*};
|
||||||
|
use rog_dbus::zbus_platform::RogBiosProxyBlocking;
|
||||||
use rog_platform::{platform::GpuMode, supported::SupportedFunctions};
|
use rog_platform::{platform::GpuMode, supported::SupportedFunctions};
|
||||||
|
|
||||||
use crate::{error::Result, get_ipc_file, SHOW_GUI};
|
use crate::{error::Result, get_ipc_file, page_states::PageDataStates, SHOW_GUI};
|
||||||
use libappindicator::{AppIndicator, AppIndicatorStatus};
|
use libappindicator::{AppIndicator, AppIndicatorStatus};
|
||||||
use supergfxctl::pci_device::{GfxMode, GfxPower};
|
use supergfxctl::{
|
||||||
|
pci_device::{GfxMode, GfxPower},
|
||||||
|
zbus_proxy::DaemonProxyBlocking as GfxProxyBlocking,
|
||||||
|
};
|
||||||
|
|
||||||
|
use log::trace;
|
||||||
|
|
||||||
const TRAY_APP_ICON: &str = "rog-control-center";
|
const TRAY_APP_ICON: &str = "rog-control-center";
|
||||||
const TRAY_LABEL: &str = "ROG Control Center";
|
const TRAY_LABEL: &str = "ROG Control Center";
|
||||||
@@ -73,29 +79,27 @@ impl RadioGroup {
|
|||||||
pub struct ROGTray {
|
pub struct ROGTray {
|
||||||
tray: AppIndicator,
|
tray: AppIndicator,
|
||||||
menu: gtk::Menu,
|
menu: gtk::Menu,
|
||||||
items: Vec<MenuItem>,
|
icon: &'static str,
|
||||||
|
bios_proxy: RogBiosProxyBlocking<'static>,
|
||||||
|
gfx_proxy: GfxProxyBlocking<'static>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ROGTray {
|
impl ROGTray {
|
||||||
pub fn new() -> Result<Self> {
|
pub fn new() -> Result<Self> {
|
||||||
let mut rog_tray = Self {
|
let conn = zbus::blocking::Connection::system().unwrap();
|
||||||
|
let rog_tray = Self {
|
||||||
tray: AppIndicator::new(TRAY_LABEL, TRAY_APP_ICON),
|
tray: AppIndicator::new(TRAY_LABEL, TRAY_APP_ICON),
|
||||||
menu: gtk::Menu::new(),
|
menu: gtk::Menu::new(),
|
||||||
items: Vec::new(),
|
icon: TRAY_APP_ICON,
|
||||||
|
bios_proxy: RogBiosProxyBlocking::new(&conn).unwrap(),
|
||||||
|
gfx_proxy: GfxProxyBlocking::new(&conn).unwrap(),
|
||||||
};
|
};
|
||||||
// rog_tray.set_icon(TRAY_APP_ICON);
|
|
||||||
|
|
||||||
rog_tray.add_icon_menu_item("Open app", "asus_notif_red", move || {
|
|
||||||
get_ipc_file().unwrap().write_all(&[SHOW_GUI]).ok();
|
|
||||||
});
|
|
||||||
|
|
||||||
rog_tray.add_inactive_label("----");
|
|
||||||
|
|
||||||
Ok(rog_tray)
|
Ok(rog_tray)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_icon(&mut self, icon: &str) {
|
pub fn set_icon(&mut self, icon: &'static str) {
|
||||||
self.tray.set_icon(icon);
|
self.icon = icon;
|
||||||
|
self.tray.set_icon(self.icon);
|
||||||
self.tray.set_status(AppIndicatorStatus::Active);
|
self.tray.set_status(AppIndicatorStatus::Active);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,7 +109,14 @@ impl ROGTray {
|
|||||||
item.set_sensitive(false);
|
item.set_sensitive(false);
|
||||||
self.menu.append(&item);
|
self.menu.append(&item);
|
||||||
self.menu.show_all();
|
self.menu.show_all();
|
||||||
self.tray.set_menu(&mut self.menu);
|
}
|
||||||
|
|
||||||
|
/// Add a separator
|
||||||
|
fn add_separator(&mut self) {
|
||||||
|
let item = gtk::SeparatorMenuItem::new();
|
||||||
|
item.set_sensitive(false);
|
||||||
|
self.menu.append(&item);
|
||||||
|
self.menu.show_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_radio_sub_menu(&mut self, header_label: &str, active_label: &str, sub_menu: RadioGroup) {
|
fn add_radio_sub_menu(&mut self, header_label: &str, active_label: &str, sub_menu: RadioGroup) {
|
||||||
@@ -129,14 +140,24 @@ impl ROGTray {
|
|||||||
F: Fn() + Send + 'static,
|
F: Fn() + Send + 'static,
|
||||||
{
|
{
|
||||||
let item = gtk::MenuItem::with_label(label);
|
let item = gtk::MenuItem::with_label(label);
|
||||||
self.items.push(item);
|
|
||||||
let item = self.items.last().unwrap();
|
|
||||||
item.connect_activate(move |_| {
|
item.connect_activate(move |_| {
|
||||||
cb();
|
cb();
|
||||||
});
|
});
|
||||||
self.menu.append(item);
|
self.menu.append(&item);
|
||||||
|
self.menu.show_all();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn add_check_menu_item<F>(&mut self, label: &str, is_active: bool, cb: F)
|
||||||
|
where
|
||||||
|
F: Fn(>k::CheckMenuItem) + Send + 'static,
|
||||||
|
{
|
||||||
|
let item = gtk::CheckMenuItem::with_label(label);
|
||||||
|
item.set_active(is_active);
|
||||||
|
item.connect_activate(move |this| {
|
||||||
|
cb(this);
|
||||||
|
});
|
||||||
|
self.menu.append(&item);
|
||||||
self.menu.show_all();
|
self.menu.show_all();
|
||||||
self.tray.set_menu(&mut self.menu);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Add a menu item with an icon to the right
|
/// Add a menu item with an icon to the right
|
||||||
@@ -147,19 +168,17 @@ impl ROGTray {
|
|||||||
let g_box = gtk::Box::new(gtk::Orientation::Horizontal, 6);
|
let g_box = gtk::Box::new(gtk::Orientation::Horizontal, 6);
|
||||||
let icon = gtk::Image::from_gicon(&Icon::for_string(icon).unwrap(), gtk::IconSize::Menu);
|
let icon = gtk::Image::from_gicon(&Icon::for_string(icon).unwrap(), gtk::IconSize::Menu);
|
||||||
let label = gtk::Label::new(Some(label));
|
let label = gtk::Label::new(Some(label));
|
||||||
let menu_item = gtk::MenuItem::new();
|
let item = gtk::MenuItem::new();
|
||||||
g_box.add(&icon);
|
g_box.add(&icon);
|
||||||
g_box.add(&label);
|
g_box.add(&label);
|
||||||
|
|
||||||
menu_item.add(&g_box);
|
item.add(&g_box);
|
||||||
menu_item.show_all();
|
item.show_all();
|
||||||
|
|
||||||
self.items.push(menu_item);
|
|
||||||
let item = self.items.last().unwrap();
|
|
||||||
item.connect_activate(move |_| {
|
item.connect_activate(move |_| {
|
||||||
cb();
|
cb();
|
||||||
});
|
});
|
||||||
self.menu.append(item);
|
self.menu.append(&item);
|
||||||
self.menu.show_all();
|
self.menu.show_all();
|
||||||
self.tray.set_menu(&mut self.menu);
|
self.tray.set_menu(&mut self.menu);
|
||||||
}
|
}
|
||||||
@@ -167,55 +186,102 @@ impl ROGTray {
|
|||||||
fn set_status(&mut self, status: AppIndicatorStatus) {
|
fn set_status(&mut self, status: AppIndicatorStatus) {
|
||||||
self.tray.set_status(status)
|
self.tray.set_status(status)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fn init_gpu_menu(supported: &SupportedFunctions, tray: &mut ROGTray) {
|
fn menu_add_base(&mut self) {
|
||||||
let conn = zbus::blocking::Connection::system().unwrap();
|
self.add_icon_menu_item("Open app", "asus_notif_red", move || {
|
||||||
let gfx_dbus = supergfxctl::zbus_proxy::DaemonProxyBlocking::new(&conn).unwrap();
|
get_ipc_file().unwrap().write_all(&[SHOW_GUI]).ok();
|
||||||
|
});
|
||||||
|
|
||||||
let mode = gfx_dbus.mode().unwrap();
|
self.add_separator();
|
||||||
let mut gpu_menu = RadioGroup::new("Integrated", move |_| {
|
}
|
||||||
let mode = gfx_dbus.mode().unwrap();
|
|
||||||
if mode != GfxMode::Integrated {
|
fn menu_add_charge_limit(&mut self, limit: u8) {
|
||||||
gfx_dbus.set_mode(&GfxMode::Integrated).unwrap();
|
self.add_inactive_label(&format!("Charge limit: {limit}"));
|
||||||
}
|
}
|
||||||
});
|
|
||||||
let gfx_dbus = supergfxctl::zbus_proxy::DaemonProxyBlocking::new(&conn).unwrap();
|
fn menu_add_panel_od(&mut self, panel_od: bool) {
|
||||||
gpu_menu.add("Hybrid", move |_| {
|
let bios = self.bios_proxy.clone();
|
||||||
let mode = gfx_dbus.mode().unwrap();
|
self.add_check_menu_item("Panel Overdrive", panel_od, move |this| {
|
||||||
if mode != GfxMode::Hybrid {
|
bios.set_panel_od(this.is_active()).unwrap();
|
||||||
gfx_dbus.set_mode(&GfxMode::Hybrid).unwrap();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if supported.rog_bios_ctrl.gpu_mux {
|
|
||||||
let gfx_dbus = rog_dbus::zbus_platform::RogBiosProxyBlocking::new(&conn).unwrap();
|
|
||||||
gpu_menu.add("Ultimate (Reboot required)", move |_| {
|
|
||||||
let mode = gfx_dbus.gpu_mux_mode().unwrap();
|
|
||||||
if mode != GpuMode::Discrete {
|
|
||||||
gfx_dbus.set_gpu_mux_mode(GpuMode::Discrete).unwrap();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if supported.rog_bios_ctrl.egpu_enable {
|
|
||||||
let gfx_dbus = supergfxctl::zbus_proxy::DaemonProxyBlocking::new(&conn).unwrap();
|
fn menu_add_gpu(&mut self, supported: &SupportedFunctions, current_mode: GfxMode) {
|
||||||
gpu_menu.add("eGPU", move |_| {
|
let gfx_dbus = self.gfx_proxy.clone();
|
||||||
|
let mut gpu_menu = RadioGroup::new("Integrated", move |_| {
|
||||||
let mode = gfx_dbus.mode().unwrap();
|
let mode = gfx_dbus.mode().unwrap();
|
||||||
if mode != GfxMode::Egpu {
|
if mode != GfxMode::Integrated {
|
||||||
gfx_dbus.set_mode(&GfxMode::Egpu).unwrap();
|
gfx_dbus.set_mode(&GfxMode::Integrated).unwrap();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let gfx_dbus = self.gfx_proxy.clone();
|
||||||
|
gpu_menu.add("Hybrid", move |_| {
|
||||||
|
let mode = gfx_dbus.mode().unwrap();
|
||||||
|
if mode != GfxMode::Hybrid {
|
||||||
|
gfx_dbus.set_mode(&GfxMode::Hybrid).unwrap();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
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().unwrap();
|
||||||
|
if mode != GpuMode::Discrete {
|
||||||
|
gfx_dbus.set_gpu_mux_mode(GpuMode::Discrete).unwrap();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if supported.rog_bios_ctrl.egpu_enable {
|
||||||
|
let gfx_dbus = self.gfx_proxy.clone();
|
||||||
|
gpu_menu.add("eGPU", move |_| {
|
||||||
|
let mode = gfx_dbus.mode().unwrap();
|
||||||
|
if mode != GfxMode::Egpu {
|
||||||
|
gfx_dbus.set_mode(&GfxMode::Egpu).unwrap();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
let active = match current_mode {
|
||||||
|
GfxMode::AsusMuxDiscreet => "Discreet".to_string(),
|
||||||
|
_ => current_mode.to_string(),
|
||||||
|
};
|
||||||
|
self.add_radio_sub_menu(
|
||||||
|
&format!("GPU Mode: {current_mode}"),
|
||||||
|
active.as_str(),
|
||||||
|
gpu_menu,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let active = match mode {
|
fn menu_clear(&mut self) {
|
||||||
GfxMode::AsusMuxDiscreet => "Discreet".to_string(),
|
self.menu = gtk::Menu::new();
|
||||||
_ => mode.to_string(),
|
}
|
||||||
};
|
|
||||||
tray.add_radio_sub_menu("GPU Mode", active.as_str(), gpu_menu);
|
/// Reset GTK menu to internal state, this can be called after clearing and rebuilding the menu too.
|
||||||
|
fn menu_update(&mut self) {
|
||||||
|
self.tray.set_menu(&mut self.menu);
|
||||||
|
self.set_icon(self.icon);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Do a flush, build, and update of the tray menu
|
||||||
|
fn rebuild_and_update(
|
||||||
|
&mut self,
|
||||||
|
supported: &SupportedFunctions,
|
||||||
|
current_gfx_mode: GfxMode,
|
||||||
|
charge_limit: u8,
|
||||||
|
panel_od: bool,
|
||||||
|
) {
|
||||||
|
self.menu_clear();
|
||||||
|
self.menu_add_base();
|
||||||
|
self.menu_add_charge_limit(charge_limit);
|
||||||
|
self.menu_add_panel_od(panel_od);
|
||||||
|
self.menu_add_gpu(supported, current_gfx_mode);
|
||||||
|
self.menu_update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn init_tray(
|
pub fn init_tray(
|
||||||
supported: SupportedFunctions,
|
supported: SupportedFunctions,
|
||||||
recv_command: Receiver<AppToTray>,
|
states: Arc<Mutex<PageDataStates>>,
|
||||||
) -> Receiver<TrayToApp> {
|
) -> Receiver<TrayToApp> {
|
||||||
let (send, recv) = channel();
|
let (send, recv) = channel();
|
||||||
let _send = Arc::new(Mutex::new(send));
|
let _send = Arc::new(Mutex::new(send));
|
||||||
@@ -224,43 +290,39 @@ pub fn init_tray(
|
|||||||
gtk::init().unwrap(); // Make this the main thread for gtk
|
gtk::init().unwrap(); // Make this the main thread for gtk
|
||||||
|
|
||||||
let mut tray = ROGTray::new().unwrap();
|
let mut tray = ROGTray::new().unwrap();
|
||||||
|
tray.rebuild_and_update(&supported, GfxMode::Hybrid, 100, false);
|
||||||
init_gpu_menu(&supported, &mut tray);
|
tray.set_icon(TRAY_APP_ICON);
|
||||||
// let s1 = send.clone();
|
|
||||||
// tray.add_menu_item("Quit", move || {
|
|
||||||
// let lock = s1.lock().unwrap();
|
|
||||||
// lock.send(TrayToApp::Quit).ok();
|
|
||||||
// })
|
|
||||||
// .ok();
|
|
||||||
|
|
||||||
//***********************************
|
|
||||||
// finally do
|
|
||||||
tray.tray.set_menu(&mut tray.menu);
|
|
||||||
//***********************************
|
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
if let Ok(command) = recv_command.try_recv() {
|
if let Ok(mut lock) = states.lock() {
|
||||||
match command {
|
if lock.tray_should_update {
|
||||||
AppToTray::DgpuStatus(s) => {
|
tray.rebuild_and_update(
|
||||||
match s {
|
&supported,
|
||||||
GfxPower::Active => tray.set_icon("asus_notif_red"),
|
lock.gfx_state.mode,
|
||||||
GfxPower::Suspended => tray.set_icon("asus_notif_blue"),
|
lock.power_state.charge_limit,
|
||||||
GfxPower::Off => tray.set_icon("asus_notif_green"),
|
lock.bios.panel_overdrive,
|
||||||
GfxPower::AsusDisabled => tray.set_icon("asus_notif_white"),
|
);
|
||||||
GfxPower::AsusMuxDiscreet => tray.set_icon("asus_notif_red"),
|
lock.tray_should_update = false;
|
||||||
GfxPower::Unknown => tray.set_icon("gpu-integrated"),
|
|
||||||
};
|
match lock.gfx_state.power_status {
|
||||||
}
|
GfxPower::Active => tray.set_icon("asus_notif_red"),
|
||||||
|
GfxPower::Suspended => tray.set_icon("asus_notif_blue"),
|
||||||
|
GfxPower::Off => tray.set_icon("asus_notif_green"),
|
||||||
|
GfxPower::AsusDisabled => tray.set_icon("asus_notif_white"),
|
||||||
|
GfxPower::AsusMuxDiscreet => tray.set_icon("asus_notif_red"),
|
||||||
|
GfxPower::Unknown => tray.set_icon("gpu-integrated"),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if gtk::events_pending() {
|
if gtk::events_pending() {
|
||||||
// This is blocking until any events are available
|
// This is blocking until any events are available
|
||||||
gtk::main_iteration();
|
gtk::main_iteration();
|
||||||
} else {
|
continue;
|
||||||
// Don't spool at max speed if no gtk events
|
|
||||||
std::thread::sleep(Duration::from_millis(300));
|
|
||||||
}
|
}
|
||||||
|
// Don't spool at max speed if no gtk events
|
||||||
|
std::thread::sleep(Duration::from_millis(300));
|
||||||
|
trace!("Tray loop ticked");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
use egui::{RichText, Ui};
|
use egui::{RichText, Ui};
|
||||||
use rog_platform::supported::SupportedFunctions;
|
use rog_platform::supported::SupportedFunctions;
|
||||||
|
|
||||||
use crate::{page_states::PageDataStates, RogDbusClientBlocking};
|
use crate::page_states::PageDataStates;
|
||||||
|
|
||||||
pub fn anime_power_group(
|
pub fn anime_power_group(
|
||||||
_supported: &SupportedFunctions,
|
_supported: &SupportedFunctions,
|
||||||
states: &mut PageDataStates,
|
states: &mut PageDataStates,
|
||||||
dbus: &mut RogDbusClientBlocking,
|
|
||||||
ui: &mut Ui,
|
ui: &mut Ui,
|
||||||
) {
|
) {
|
||||||
ui.heading("AniMe Matrix Settings");
|
ui.heading("AniMe Matrix Settings");
|
||||||
@@ -43,7 +42,9 @@ pub fn anime_power_group(
|
|||||||
});
|
});
|
||||||
ui.horizontal_wrapped(|ui| {
|
ui.horizontal_wrapped(|ui| {
|
||||||
if ui.checkbox(&mut states.anime.boot, "Enable").changed() {
|
if ui.checkbox(&mut states.anime.boot, "Enable").changed() {
|
||||||
dbus.proxies()
|
states
|
||||||
|
.asus_dbus
|
||||||
|
.proxies()
|
||||||
.anime()
|
.anime()
|
||||||
.set_boot_on_off(states.anime.boot)
|
.set_boot_on_off(states.anime.boot)
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
@@ -54,7 +55,9 @@ pub fn anime_power_group(
|
|||||||
});
|
});
|
||||||
ui.horizontal_wrapped(|ui| {
|
ui.horizontal_wrapped(|ui| {
|
||||||
if ui.checkbox(&mut states.anime.awake, "Enable").changed() {
|
if ui.checkbox(&mut states.anime.awake, "Enable").changed() {
|
||||||
dbus.proxies()
|
states
|
||||||
|
.asus_dbus
|
||||||
|
.proxies()
|
||||||
.anime()
|
.anime()
|
||||||
.set_on_off(states.anime.awake)
|
.set_on_off(states.anime.awake)
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
|
|||||||
@@ -7,16 +7,12 @@ use egui::{RichText, Ui};
|
|||||||
use rog_aura::{AuraEffect, AuraModeNum, AuraZone, Colour, Speed};
|
use rog_aura::{AuraEffect, AuraModeNum, AuraZone, Colour, Speed};
|
||||||
use rog_platform::supported::SupportedFunctions;
|
use rog_platform::supported::SupportedFunctions;
|
||||||
|
|
||||||
use crate::{
|
use crate::page_states::{AuraState, PageDataStates};
|
||||||
page_states::{AuraState, PageDataStates},
|
|
||||||
RogDbusClientBlocking,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub fn aura_modes_group(
|
pub fn aura_modes_group(
|
||||||
supported: &SupportedFunctions,
|
supported: &SupportedFunctions,
|
||||||
states: &mut PageDataStates,
|
states: &mut PageDataStates,
|
||||||
freq: &mut Arc<AtomicU8>,
|
freq: &mut Arc<AtomicU8>,
|
||||||
dbus: &mut RogDbusClientBlocking,
|
|
||||||
ui: &mut Ui,
|
ui: &mut Ui,
|
||||||
) {
|
) {
|
||||||
let mut changed = false;
|
let mut changed = false;
|
||||||
@@ -172,8 +168,7 @@ pub fn aura_modes_group(
|
|||||||
ui.separator();
|
ui.separator();
|
||||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::TOP), |ui| {
|
ui.with_layout(egui::Layout::right_to_left(egui::Align::TOP), |ui| {
|
||||||
if ui.add(egui::Button::new("Cancel")).clicked() {
|
if ui.add(egui::Button::new("Cancel")).clicked() {
|
||||||
let notif = states.aura.was_notified.clone();
|
match AuraState::new(supported, &states.asus_dbus) {
|
||||||
match AuraState::new(notif, supported, dbus) {
|
|
||||||
Ok(a) => states.aura.modes = a.modes,
|
Ok(a) => states.aura.modes = a.modes,
|
||||||
Err(e) => states.error = Some(e.to_string()),
|
Err(e) => states.error = Some(e.to_string()),
|
||||||
}
|
}
|
||||||
@@ -202,7 +197,9 @@ pub fn aura_modes_group(
|
|||||||
if changed {
|
if changed {
|
||||||
states.aura.current_mode = selected;
|
states.aura.current_mode = selected;
|
||||||
|
|
||||||
dbus.proxies()
|
states
|
||||||
|
.asus_dbus
|
||||||
|
.proxies()
|
||||||
.led()
|
.led()
|
||||||
.set_led_mode(states.aura.modes.get(&selected).unwrap())
|
.set_led_mode(states.aura.modes.get(&selected).unwrap())
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
|
|||||||
@@ -5,32 +5,22 @@ use rog_aura::{
|
|||||||
};
|
};
|
||||||
use rog_platform::supported::SupportedFunctions;
|
use rog_platform::supported::SupportedFunctions;
|
||||||
|
|
||||||
use crate::{page_states::PageDataStates, RogDbusClientBlocking};
|
use crate::page_states::PageDataStates;
|
||||||
|
|
||||||
pub fn aura_power_group(
|
pub fn aura_power_group(supported: &SupportedFunctions, states: &mut PageDataStates, ui: &mut Ui) {
|
||||||
supported: &SupportedFunctions,
|
|
||||||
states: &mut PageDataStates,
|
|
||||||
dbus: &mut RogDbusClientBlocking,
|
|
||||||
ui: &mut Ui,
|
|
||||||
) {
|
|
||||||
ui.heading("LED settings");
|
ui.heading("LED settings");
|
||||||
|
|
||||||
match supported.keyboard_led.prod_id {
|
match supported.keyboard_led.prod_id {
|
||||||
AuraDevice::X1854 | AuraDevice::X1869 | AuraDevice::X1866 => {
|
AuraDevice::X1854 | AuraDevice::X1869 | AuraDevice::X1866 => {
|
||||||
aura_power1(supported, states, dbus, ui)
|
aura_power1(supported, states, ui)
|
||||||
}
|
}
|
||||||
AuraDevice::X19B6 => aura_power2(supported, states, dbus, ui),
|
AuraDevice::X19B6 => aura_power2(supported, states, ui),
|
||||||
AuraDevice::Tuf => aura_power1(supported, states, dbus, ui),
|
AuraDevice::Tuf => aura_power1(supported, states, ui),
|
||||||
AuraDevice::Unknown => {}
|
AuraDevice::Unknown => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn aura_power1(
|
fn aura_power1(supported: &SupportedFunctions, states: &mut PageDataStates, ui: &mut Ui) {
|
||||||
supported: &SupportedFunctions,
|
|
||||||
states: &mut PageDataStates,
|
|
||||||
dbus: &mut RogDbusClientBlocking,
|
|
||||||
ui: &mut Ui,
|
|
||||||
) {
|
|
||||||
let enabled_states = &mut states.aura.enabled;
|
let enabled_states = &mut states.aura.enabled;
|
||||||
let mut boot = enabled_states.x1866.contains(&AuraDev1866::Boot);
|
let mut boot = enabled_states.x1866.contains(&AuraDev1866::Boot);
|
||||||
let mut sleep = enabled_states.x1866.contains(&AuraDev1866::Sleep);
|
let mut sleep = enabled_states.x1866.contains(&AuraDev1866::Sleep);
|
||||||
@@ -144,7 +134,9 @@ fn aura_power1(
|
|||||||
x19b6: vec![],
|
x19b6: vec![],
|
||||||
};
|
};
|
||||||
// build data to send
|
// build data to send
|
||||||
dbus.proxies()
|
states
|
||||||
|
.asus_dbus
|
||||||
|
.proxies()
|
||||||
.led()
|
.led()
|
||||||
.set_leds_power(options, enable)
|
.set_leds_power(options, enable)
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
@@ -193,7 +185,9 @@ fn aura_power1(
|
|||||||
x19b6: vec![],
|
x19b6: vec![],
|
||||||
};
|
};
|
||||||
// build data to send
|
// build data to send
|
||||||
dbus.proxies()
|
states
|
||||||
|
.asus_dbus
|
||||||
|
.proxies()
|
||||||
.led()
|
.led()
|
||||||
.set_leds_power(options, enable)
|
.set_leds_power(options, enable)
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
@@ -207,12 +201,7 @@ fn aura_power1(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn aura_power2(
|
fn aura_power2(supported: &SupportedFunctions, states: &mut PageDataStates, ui: &mut Ui) {
|
||||||
supported: &SupportedFunctions,
|
|
||||||
states: &mut PageDataStates,
|
|
||||||
dbus: &mut RogDbusClientBlocking,
|
|
||||||
ui: &mut Ui,
|
|
||||||
) {
|
|
||||||
let enabled_states = &mut states.aura.enabled;
|
let enabled_states = &mut states.aura.enabled;
|
||||||
let has_logo = supported
|
let has_logo = supported
|
||||||
.keyboard_led
|
.keyboard_led
|
||||||
@@ -331,7 +320,9 @@ fn aura_power2(
|
|||||||
x19b6: data,
|
x19b6: data,
|
||||||
};
|
};
|
||||||
// build data to send
|
// build data to send
|
||||||
dbus.proxies()
|
states
|
||||||
|
.asus_dbus
|
||||||
|
.proxies()
|
||||||
.led()
|
.led()
|
||||||
.set_leds_power(options, enable)
|
.set_leds_power(options, enable)
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
|
|||||||
@@ -136,8 +136,7 @@ pub fn fan_graphs(
|
|||||||
})
|
})
|
||||||
.ok();
|
.ok();
|
||||||
|
|
||||||
let notif = curves.was_notified.clone();
|
match FanCurvesState::new(supported, dbus) {
|
||||||
match FanCurvesState::new(notif, supported, dbus) {
|
|
||||||
Ok(f) => *curves = f,
|
Ok(f) => *curves = f,
|
||||||
Err(e) => *do_error = Some(e.to_string()),
|
Err(e) => *do_error = Some(e.to_string()),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
use crate::{page_states::PageDataStates, RogDbusClientBlocking};
|
use crate::page_states::PageDataStates;
|
||||||
use egui::Ui;
|
use egui::Ui;
|
||||||
use rog_platform::{platform::GpuMode, supported::SupportedFunctions};
|
use rog_platform::{platform::GpuMode, supported::SupportedFunctions};
|
||||||
use rog_profiles::Profile;
|
use rog_profiles::Profile;
|
||||||
|
|
||||||
pub fn platform_profile(states: &mut PageDataStates, dbus: &RogDbusClientBlocking, ui: &mut Ui) {
|
pub fn platform_profile(states: &mut PageDataStates, ui: &mut Ui) {
|
||||||
ui.heading("Platform profile");
|
ui.heading("Platform profile");
|
||||||
|
|
||||||
let mut changed = false;
|
let mut changed = false;
|
||||||
@@ -23,7 +23,9 @@ pub fn platform_profile(states: &mut PageDataStates, dbus: &RogDbusClientBlockin
|
|||||||
});
|
});
|
||||||
|
|
||||||
if changed {
|
if changed {
|
||||||
dbus.proxies()
|
states
|
||||||
|
.asus_dbus
|
||||||
|
.proxies()
|
||||||
.profile()
|
.profile()
|
||||||
.set_active_profile(states.profiles.current)
|
.set_active_profile(states.profiles.current)
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
@@ -33,21 +35,18 @@ pub fn platform_profile(states: &mut PageDataStates, dbus: &RogDbusClientBlockin
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn rog_bios_group(
|
pub fn rog_bios_group(supported: &SupportedFunctions, states: &mut PageDataStates, ui: &mut Ui) {
|
||||||
supported: &SupportedFunctions,
|
|
||||||
states: &mut PageDataStates,
|
|
||||||
dbus: &mut RogDbusClientBlocking,
|
|
||||||
ui: &mut Ui,
|
|
||||||
) {
|
|
||||||
ui.heading("Bios options");
|
ui.heading("Bios options");
|
||||||
|
|
||||||
let slider = egui::Slider::new(&mut states.charge_limit, 20..=100)
|
let slider = egui::Slider::new(&mut states.power_state.charge_limit, 20..=100)
|
||||||
.text("Charging limit")
|
.text("Charging limit")
|
||||||
.step_by(1.0);
|
.step_by(1.0);
|
||||||
if ui.add(slider).drag_released() {
|
if ui.add(slider).drag_released() {
|
||||||
dbus.proxies()
|
states
|
||||||
|
.asus_dbus
|
||||||
|
.proxies()
|
||||||
.charge()
|
.charge()
|
||||||
.set_charge_control_end_threshold(states.charge_limit as u8)
|
.set_charge_control_end_threshold(states.power_state.charge_limit as u8)
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
states.error = Some(err.to_string());
|
states.error = Some(err.to_string());
|
||||||
})
|
})
|
||||||
@@ -62,7 +61,9 @@ pub fn rog_bios_group(
|
|||||||
))
|
))
|
||||||
.changed()
|
.changed()
|
||||||
{
|
{
|
||||||
dbus.proxies()
|
states
|
||||||
|
.asus_dbus
|
||||||
|
.proxies()
|
||||||
.rog_bios()
|
.rog_bios()
|
||||||
.set_post_boot_sound(states.bios.post_sound)
|
.set_post_boot_sound(states.bios.post_sound)
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
@@ -79,7 +80,9 @@ pub fn rog_bios_group(
|
|||||||
))
|
))
|
||||||
.changed()
|
.changed()
|
||||||
{
|
{
|
||||||
dbus.proxies()
|
states
|
||||||
|
.asus_dbus
|
||||||
|
.proxies()
|
||||||
.rog_bios()
|
.rog_bios()
|
||||||
.set_panel_od(states.bios.panel_overdrive)
|
.set_panel_od(states.bios.panel_overdrive)
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
@@ -114,7 +117,9 @@ pub fn rog_bios_group(
|
|||||||
});
|
});
|
||||||
|
|
||||||
if changed {
|
if changed {
|
||||||
dbus.proxies()
|
states
|
||||||
|
.asus_dbus
|
||||||
|
.proxies()
|
||||||
.rog_bios()
|
.rog_bios()
|
||||||
.set_gpu_mux_mode(states.bios.dedicated_gfx)
|
.set_gpu_mux_mode(states.bios.dedicated_gfx)
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use crate::{Page, RogApp};
|
use crate::{Page, RogApp};
|
||||||
|
|
||||||
impl<'a> RogApp<'a> {
|
impl RogApp {
|
||||||
pub fn side_panel(&mut self, ctx: &egui::Context) {
|
pub fn side_panel(&mut self, ctx: &egui::Context) {
|
||||||
egui::SidePanel::left("side_panel")
|
egui::SidePanel::left("side_panel")
|
||||||
.resizable(false)
|
.resizable(false)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use egui::{vec2, Align2, FontId, Id, Sense};
|
|||||||
|
|
||||||
use crate::{RogApp, VERSION};
|
use crate::{RogApp, VERSION};
|
||||||
|
|
||||||
impl<'a> RogApp<'a> {
|
impl RogApp {
|
||||||
pub fn top_bar(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) {
|
pub fn top_bar(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) {
|
||||||
egui::TopBottomPanel::top("top_panel").show(ctx, |ui| {
|
egui::TopBottomPanel::top("top_panel").show(ctx, |ui| {
|
||||||
// The top panel is often a good place for a menu bar:
|
// The top panel is often a good place for a menu bar:
|
||||||
|
|||||||
Reference in New Issue
Block a user