mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Fluke/dbus refactor
This commit is contained in:
@@ -5,7 +5,7 @@ use std::time::{Duration, Instant};
|
||||
|
||||
use egui::{Button, RichText};
|
||||
use rog_aura::layouts::KeyLayout;
|
||||
use rog_platform::supported::SupportedFunctions;
|
||||
use rog_platform::platform::Properties;
|
||||
|
||||
use crate::config::Config;
|
||||
use crate::error::Result;
|
||||
@@ -15,7 +15,6 @@ use crate::{Page, RogDbusClientBlocking};
|
||||
pub struct RogApp {
|
||||
pub page: Page,
|
||||
pub states: Arc<Mutex<SystemState>>,
|
||||
pub supported: SupportedFunctions,
|
||||
// TODO: can probably just open and read whenever
|
||||
pub config: Config,
|
||||
/// Oscillator in percentage
|
||||
@@ -26,6 +25,8 @@ pub struct RogApp {
|
||||
pub oscillator_freq: Arc<AtomicU8>,
|
||||
/// A toggle that toggles true/false when the oscillator reaches 0
|
||||
pub oscillator_toggle: Arc<AtomicBool>,
|
||||
pub supported_interfaces: Vec<String>,
|
||||
pub supported_properties: Vec<Properties>,
|
||||
}
|
||||
|
||||
impl RogApp {
|
||||
@@ -36,7 +37,8 @@ impl RogApp {
|
||||
_cc: &eframe::CreationContext<'_>,
|
||||
) -> Result<Self> {
|
||||
let (dbus, _) = RogDbusClientBlocking::new()?;
|
||||
let supported = dbus.proxies().supported().supported_functions()?;
|
||||
let supported_interfaces = dbus.proxies().platform().supported_interfaces()?;
|
||||
let supported_properties = dbus.proxies().platform().supported_properties()?;
|
||||
|
||||
// Set up an oscillator to run on a thread.
|
||||
// Helpful for visual effects like colour pulse.
|
||||
@@ -87,7 +89,8 @@ impl RogApp {
|
||||
});
|
||||
|
||||
Ok(Self {
|
||||
supported,
|
||||
supported_interfaces,
|
||||
supported_properties,
|
||||
states,
|
||||
page: Page::System,
|
||||
config,
|
||||
@@ -166,7 +169,7 @@ impl eframe::App for RogApp {
|
||||
Page::AppSettings => self.app_settings_page(&mut states, ctx),
|
||||
Page::System => self.system_page(&mut states, ctx),
|
||||
Page::AuraEffects => self.aura_page(&mut states, ctx),
|
||||
Page::AnimeMatrix => todo!(),
|
||||
Page::AnimeMatrix => self.anime_page(ctx),
|
||||
Page::FanCurves => self.fan_curve_page(&mut states, ctx),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ use rog_control_center::{
|
||||
get_ipc_file, on_tmp_dir_exists, print_versions, RogApp, RogDbusClientBlocking, SHOWING_GUI,
|
||||
SHOW_GUI,
|
||||
};
|
||||
use rog_platform::supported::SupportedFunctions;
|
||||
use tokio::runtime::Runtime;
|
||||
|
||||
#[cfg(not(feature = "mocking"))]
|
||||
@@ -82,7 +81,7 @@ fn main() -> Result<()> {
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
let supported = match dbus.proxies().supported().supported_functions() {
|
||||
let supported_properties = match dbus.proxies().platform().supported_properties() {
|
||||
Ok(s) => s,
|
||||
Err(e) => {
|
||||
eframe::run_native(
|
||||
@@ -92,7 +91,7 @@ fn main() -> Result<()> {
|
||||
)
|
||||
.map_err(|e| error!("{e}"))
|
||||
.ok();
|
||||
SupportedFunctions::default()
|
||||
vec![]
|
||||
}
|
||||
};
|
||||
|
||||
@@ -186,11 +185,10 @@ fn main() -> Result<()> {
|
||||
layouts,
|
||||
&enabled_notifications,
|
||||
&config,
|
||||
&supported,
|
||||
)?;
|
||||
|
||||
if config.enable_tray_icon {
|
||||
init_tray(supported, states.clone());
|
||||
init_tray(supported_properties, states.clone());
|
||||
}
|
||||
|
||||
let mut bg_check_spawned = false;
|
||||
@@ -247,7 +245,6 @@ fn setup_page_state_and_notifs(
|
||||
keyboard_layouts: Vec<PathBuf>,
|
||||
enabled_notifications: &Arc<Mutex<EnabledNotifications>>,
|
||||
config: &Config,
|
||||
supported: &SupportedFunctions,
|
||||
) -> Result<Arc<Mutex<SystemState>>> {
|
||||
let page_states = Arc::new(Mutex::new(SystemState::new(
|
||||
layout_testing,
|
||||
@@ -256,7 +253,6 @@ fn setup_page_state_and_notifs(
|
||||
enabled_notifications.clone(),
|
||||
config.enable_tray_icon,
|
||||
config.run_in_background,
|
||||
supported,
|
||||
)?));
|
||||
|
||||
start_notifications(config, &page_states, enabled_notifications)?;
|
||||
|
||||
@@ -1,38 +1,35 @@
|
||||
use egui::{RichText, Ui};
|
||||
use rog_platform::supported::SupportedFunctions;
|
||||
use rog_platform::platform::PlatformPolicy;
|
||||
|
||||
use crate::system_state::{FanCurvesState, ProfilesState, SystemState};
|
||||
use crate::system_state::{FanCurvesState, SystemState};
|
||||
use crate::widgets::fan_graphs;
|
||||
use crate::{RogApp, RogDbusClientBlocking};
|
||||
|
||||
impl RogApp {
|
||||
pub fn fan_curve_page(&mut self, states: &mut SystemState, ctx: &egui::Context) {
|
||||
let Self { supported, .. } = self;
|
||||
if let Some(mut throttle) = states.bios.throttle {
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
ui.heading("Custom fan curves");
|
||||
Self::fan_curve(
|
||||
&mut throttle,
|
||||
&mut states.fan_curves,
|
||||
&states.asus_dbus,
|
||||
&mut states.error,
|
||||
ui,
|
||||
);
|
||||
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
ui.heading("Custom fan curves");
|
||||
Self::fan_curve(
|
||||
supported,
|
||||
&mut states.profiles,
|
||||
&mut states.fan_curves,
|
||||
&states.asus_dbus,
|
||||
&mut states.error,
|
||||
ui,
|
||||
);
|
||||
|
||||
fan_graphs(
|
||||
supported,
|
||||
&mut states.fan_curves,
|
||||
&states.asus_dbus,
|
||||
&mut states.error,
|
||||
ui,
|
||||
);
|
||||
});
|
||||
fan_graphs(
|
||||
&mut states.fan_curves,
|
||||
&states.asus_dbus,
|
||||
&mut states.error,
|
||||
ui,
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
fn fan_curve(
|
||||
supported: &SupportedFunctions,
|
||||
profiles: &mut ProfilesState,
|
||||
current: &mut PlatformPolicy,
|
||||
curves: &mut FanCurvesState,
|
||||
dbus: &RogDbusClientBlocking<'_>,
|
||||
do_error: &mut Option<String>,
|
||||
@@ -43,7 +40,7 @@ impl RogApp {
|
||||
let mut changed = false;
|
||||
ui.horizontal(|ui| {
|
||||
ui.label("Current profile: ");
|
||||
ui.label(RichText::new(format!("{}", profiles.current)).strong());
|
||||
ui.label(RichText::new(format!("{}", current)).strong());
|
||||
});
|
||||
|
||||
// ui.horizontal(|ui| {
|
||||
@@ -64,9 +61,9 @@ impl RogApp {
|
||||
// }
|
||||
// };
|
||||
|
||||
// if let Some(curves) = curves.curves.get_mut(&profiles.current) {
|
||||
// if let Some(curves) = curves.curves.get_mut(¤t) {
|
||||
// for curve in curves.iter_mut() {
|
||||
// fan_curve_enable(profiles.current, curve.fan, curve.enabled);
|
||||
// fan_curve_enable(current, curve.fan, curve.enabled);
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
@@ -75,7 +72,7 @@ impl RogApp {
|
||||
ui.label("Enabled fan-curves: ");
|
||||
let mut checked = false;
|
||||
let mut label = String::default();
|
||||
if let Some(curves) = curves.curves.get_mut(&profiles.current) {
|
||||
if let Some(curves) = curves.curves.get_mut(current) {
|
||||
for curve in curves.iter() {
|
||||
label.push_str(&<&str>::from(curve.fan).to_ascii_uppercase());
|
||||
label.push(' ');
|
||||
@@ -94,8 +91,8 @@ impl RogApp {
|
||||
.changed()
|
||||
{
|
||||
dbus.proxies()
|
||||
.profile()
|
||||
.set_fan_curves_enabled(profiles.current, checked)
|
||||
.fan_curves()
|
||||
.set_fan_curves_enabled(*current, checked)
|
||||
.map_err(|err| {
|
||||
*do_error = Some(err.to_string());
|
||||
})
|
||||
@@ -108,7 +105,7 @@ impl RogApp {
|
||||
let selected_profile = curves.show_curve;
|
||||
let selected_pu = curves.show_graph;
|
||||
|
||||
match FanCurvesState::new(supported, dbus) {
|
||||
match FanCurvesState::new(dbus) {
|
||||
Ok(f) => *curves = f,
|
||||
Err(e) => *do_error = Some(e.to_string()),
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
use crate::system_state::SystemState;
|
||||
use crate::widgets::{anime_power_group, aura_power_group, platform_profile, rog_bios_group};
|
||||
use crate::widgets::{anime_power_group, platform_profile, rog_bios_group};
|
||||
use crate::RogApp;
|
||||
|
||||
impl RogApp {
|
||||
pub fn system_page(&mut self, states: &mut SystemState, ctx: &egui::Context) {
|
||||
let Self { supported, .. } = self;
|
||||
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
ui.heading("Laptop settings");
|
||||
|
||||
@@ -17,26 +15,28 @@ impl RogApp {
|
||||
.show(ui, |ui| {
|
||||
ui.vertical(|ui| {
|
||||
ui.separator();
|
||||
if supported.platform_profile.platform_profile {
|
||||
platform_profile(states, ui);
|
||||
// if self.supported_interfaces {
|
||||
platform_profile(states, ui);
|
||||
// }
|
||||
});
|
||||
ui.vertical(|ui| {
|
||||
ui.separator();
|
||||
if self.supported_interfaces.contains(&"Aura".to_string()) {
|
||||
// aura_power_group(states, ui);
|
||||
}
|
||||
});
|
||||
ui.end_row();
|
||||
|
||||
ui.vertical(|ui| {
|
||||
ui.separator();
|
||||
aura_power_group(supported, states, ui);
|
||||
rog_bios_group(states, ui);
|
||||
});
|
||||
ui.end_row();
|
||||
|
||||
ui.vertical(|ui| {
|
||||
ui.separator();
|
||||
rog_bios_group(supported, states, ui);
|
||||
});
|
||||
ui.end_row();
|
||||
|
||||
ui.vertical(|ui| {
|
||||
ui.separator();
|
||||
if supported.anime_ctrl.0 {
|
||||
anime_power_group(supported, states, ui);
|
||||
if self.supported_interfaces.contains(&"Anime".to_string()) {
|
||||
anime_power_group(states, ui);
|
||||
}
|
||||
});
|
||||
ui.vertical(|ui| {
|
||||
|
||||
@@ -8,11 +8,10 @@ use log::error;
|
||||
use rog_anime::{Animations, DeviceState};
|
||||
use rog_aura::layouts::KeyLayout;
|
||||
use rog_aura::usb::AuraPowerDev;
|
||||
use rog_aura::{AuraEffect, AuraModeNum};
|
||||
use rog_platform::platform::GpuMode;
|
||||
use rog_platform::supported::SupportedFunctions;
|
||||
use rog_aura::{AuraEffect, AuraModeNum, LedBrightness};
|
||||
use rog_platform::platform::{GpuMode, PlatformPolicy};
|
||||
use rog_profiles::fan_curve_set::CurveData;
|
||||
use rog_profiles::{FanCurvePU, Profile};
|
||||
use rog_profiles::FanCurvePU;
|
||||
use supergfxctl::pci_device::{GfxMode, GfxPower};
|
||||
#[cfg(not(feature = "mocking"))]
|
||||
use supergfxctl::zbus_proxy::DaemonProxyBlocking as GfxProxyBlocking;
|
||||
@@ -24,111 +23,77 @@ use crate::update_and_notify::EnabledNotifications;
|
||||
use crate::RogDbusClientBlocking;
|
||||
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub struct BiosState {
|
||||
pub struct PlatformState {
|
||||
/// To be shared to a thread that checks notifications.
|
||||
/// It's a bit general in that it won't provide *what* was
|
||||
/// updated, so the full state needs refresh
|
||||
pub post_sound: bool,
|
||||
pub dedicated_gfx: GpuMode,
|
||||
pub panel_overdrive: bool,
|
||||
pub mini_led_mode: bool,
|
||||
pub dgpu_disable: bool,
|
||||
pub egpu_enable: bool,
|
||||
pub post_sound: Option<bool>,
|
||||
pub gpu_mux_mode: Option<GpuMode>,
|
||||
pub panel_overdrive: Option<bool>,
|
||||
pub mini_led_mode: Option<bool>,
|
||||
pub dgpu_disable: Option<bool>,
|
||||
pub egpu_enable: Option<bool>,
|
||||
pub throttle: Option<PlatformPolicy>,
|
||||
pub charge_limit: Option<u8>,
|
||||
}
|
||||
|
||||
impl BiosState {
|
||||
pub fn new(supported: &SupportedFunctions, dbus: &RogDbusClientBlocking<'_>) -> Result<Self> {
|
||||
impl PlatformState {
|
||||
pub fn new(dbus: &RogDbusClientBlocking<'_>) -> Result<Self> {
|
||||
Ok(Self {
|
||||
post_sound: if supported.rog_bios_ctrl.post_animation_sound {
|
||||
dbus.proxies().rog_bios().post_animation_sound()?
|
||||
} else {
|
||||
false
|
||||
},
|
||||
dedicated_gfx: if supported.rog_bios_ctrl.gpu_mux {
|
||||
GpuMode::from(dbus.proxies().rog_bios().gpu_mux_mode()?)
|
||||
} else {
|
||||
GpuMode::NotSupported
|
||||
},
|
||||
panel_overdrive: if supported.rog_bios_ctrl.panel_overdrive {
|
||||
dbus.proxies().rog_bios().panel_od()?
|
||||
} else {
|
||||
false
|
||||
},
|
||||
mini_led_mode: if supported.rog_bios_ctrl.mini_led_mode {
|
||||
dbus.proxies().rog_bios().mini_led_mode()?
|
||||
} else {
|
||||
false
|
||||
},
|
||||
post_sound: dbus.proxies().platform().post_animation_sound().ok(),
|
||||
gpu_mux_mode: dbus
|
||||
.proxies()
|
||||
.platform()
|
||||
.gpu_mux_mode()
|
||||
.map(GpuMode::from)
|
||||
.ok(),
|
||||
panel_overdrive: dbus.proxies().platform().panel_od().ok(),
|
||||
mini_led_mode: dbus.proxies().platform().mini_led_mode().ok(),
|
||||
// TODO: needs supergfx
|
||||
dgpu_disable: supported.rog_bios_ctrl.dgpu_disable,
|
||||
egpu_enable: supported.rog_bios_ctrl.egpu_enable,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub struct ProfilesState {
|
||||
pub list: Vec<Profile>,
|
||||
pub current: Profile,
|
||||
}
|
||||
|
||||
impl ProfilesState {
|
||||
pub fn new(supported: &SupportedFunctions, dbus: &RogDbusClientBlocking<'_>) -> Result<Self> {
|
||||
Ok(Self {
|
||||
list: if supported.platform_profile.platform_profile {
|
||||
let mut list = dbus.proxies().profile().profiles()?;
|
||||
list.sort();
|
||||
list
|
||||
} else {
|
||||
vec![]
|
||||
},
|
||||
current: if supported.platform_profile.platform_profile {
|
||||
dbus.proxies().profile().active_profile()?
|
||||
} else {
|
||||
Profile::Balanced
|
||||
},
|
||||
dgpu_disable: dbus.proxies().platform().dgpu_disable().ok(),
|
||||
egpu_enable: dbus.proxies().platform().egpu_enable().ok(),
|
||||
throttle: dbus.proxies().platform().throttle_thermal_policy().ok(),
|
||||
charge_limit: dbus
|
||||
.proxies()
|
||||
.platform()
|
||||
.charge_control_end_threshold()
|
||||
.ok(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub struct FanCurvesState {
|
||||
pub show_curve: Profile,
|
||||
pub show_curve: PlatformPolicy,
|
||||
pub show_graph: FanCurvePU,
|
||||
pub curves: BTreeMap<Profile, Vec<CurveData>>,
|
||||
pub curves: BTreeMap<PlatformPolicy, Vec<CurveData>>,
|
||||
pub available_fans: HashSet<FanCurvePU>,
|
||||
pub drag_delta: Vec2,
|
||||
}
|
||||
|
||||
impl FanCurvesState {
|
||||
pub fn new(supported: &SupportedFunctions, dbus: &RogDbusClientBlocking<'_>) -> Result<Self> {
|
||||
let profiles = if supported.platform_profile.platform_profile {
|
||||
dbus.proxies().profile().profiles()?
|
||||
} else {
|
||||
vec![Profile::Balanced, Profile::Quiet, Profile::Performance]
|
||||
};
|
||||
pub fn new(dbus: &RogDbusClientBlocking<'_>) -> Result<Self> {
|
||||
let profiles = vec![
|
||||
PlatformPolicy::Balanced,
|
||||
PlatformPolicy::Quiet,
|
||||
PlatformPolicy::Performance,
|
||||
];
|
||||
|
||||
let mut curves: BTreeMap<Profile, Vec<CurveData>> = BTreeMap::new();
|
||||
let mut curves: BTreeMap<PlatformPolicy, Vec<CurveData>> = BTreeMap::new();
|
||||
for p in &profiles {
|
||||
if !supported.platform_profile.fans.is_empty() {
|
||||
if let Ok(curve) = dbus.proxies().profile().fan_curve_data(*p) {
|
||||
curves.insert(*p, curve);
|
||||
}
|
||||
if let Ok(curve) = dbus.proxies().fan_curves().fan_curve_data(*p) {
|
||||
curves.insert(*p, curve);
|
||||
} else {
|
||||
curves.insert(*p, Vec::default());
|
||||
curves.insert(*p, Default::default());
|
||||
}
|
||||
}
|
||||
|
||||
let mut available_fans = HashSet::new();
|
||||
for fan in supported.platform_profile.fans.iter() {
|
||||
available_fans.insert(*fan);
|
||||
}
|
||||
let available_fans = HashSet::new();
|
||||
// for fan in supported.platform_profile.fans.iter() {
|
||||
// available_fans.insert(*fan);
|
||||
// }
|
||||
|
||||
let show_curve = if !supported.platform_profile.fans.is_empty() {
|
||||
dbus.proxies().profile().active_profile()?
|
||||
} else {
|
||||
Profile::Balanced
|
||||
};
|
||||
let show_curve = dbus.proxies().platform().throttle_thermal_policy()?;
|
||||
|
||||
Ok(Self {
|
||||
show_curve,
|
||||
@@ -146,7 +111,7 @@ pub struct AuraState {
|
||||
pub modes: BTreeMap<AuraModeNum, AuraEffect>,
|
||||
pub enabled: AuraPowerDev,
|
||||
/// Brightness from 0-3
|
||||
pub bright: i16,
|
||||
pub bright: LedBrightness,
|
||||
pub wave_red: [u8; 22],
|
||||
pub wave_green: [u8; 22],
|
||||
pub wave_blue: [u8; 22],
|
||||
@@ -156,18 +121,18 @@ impl AuraState {
|
||||
pub fn new(layout: &KeyLayout, dbus: &RogDbusClientBlocking<'_>) -> Result<Self> {
|
||||
Ok(Self {
|
||||
current_mode: if !layout.basic_modes().is_empty() {
|
||||
dbus.proxies().led().led_mode().unwrap_or_default()
|
||||
dbus.proxies().aura().led_mode().unwrap_or_default()
|
||||
} else {
|
||||
AuraModeNum::Static
|
||||
},
|
||||
|
||||
modes: if !layout.basic_modes().is_empty() {
|
||||
dbus.proxies().led().led_modes().unwrap_or_default()
|
||||
dbus.proxies().aura().all_mode_data().unwrap_or_default()
|
||||
} else {
|
||||
BTreeMap::new()
|
||||
},
|
||||
enabled: dbus.proxies().led().led_power().unwrap_or_default(),
|
||||
bright: dbus.proxies().led().led_brightness().unwrap_or_default(),
|
||||
enabled: dbus.proxies().aura().led_power().unwrap_or_default(),
|
||||
bright: dbus.proxies().aura().brightness().unwrap_or_default(),
|
||||
wave_red: [0u8; 22],
|
||||
wave_green: [0u8; 22],
|
||||
wave_blue: [0u8; 22],
|
||||
@@ -198,18 +163,14 @@ pub struct AnimeState {
|
||||
}
|
||||
|
||||
impl AnimeState {
|
||||
pub fn new(supported: &SupportedFunctions, dbus: &RogDbusClientBlocking<'_>) -> Result<Self> {
|
||||
if supported.anime_ctrl.0 {
|
||||
let device_state = dbus.proxies().anime().device_state()?;
|
||||
Ok(Self {
|
||||
display_enabled: device_state.display_enabled,
|
||||
display_brightness: device_state.display_brightness as u8,
|
||||
builtin_anims_enabled: device_state.builtin_anims_enabled,
|
||||
builtin_anims: device_state.builtin_anims,
|
||||
})
|
||||
} else {
|
||||
Ok(Default::default())
|
||||
}
|
||||
pub fn new(dbus: &RogDbusClientBlocking<'_>) -> Result<Self> {
|
||||
let device_state = dbus.proxies().anime().device_state()?;
|
||||
Ok(Self {
|
||||
display_enabled: device_state.display_enabled,
|
||||
display_brightness: device_state.display_brightness as u8,
|
||||
builtin_anims_enabled: device_state.builtin_anims_enabled,
|
||||
builtin_anims: device_state.builtin_anims,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,7 +193,7 @@ pub struct GfxState {
|
||||
}
|
||||
|
||||
impl GfxState {
|
||||
pub fn new(_supported: &SupportedFunctions, dbus: &GfxProxyBlocking<'_>) -> Result<Self> {
|
||||
pub fn new(dbus: &GfxProxyBlocking<'_>) -> Result<Self> {
|
||||
Ok(Self {
|
||||
has_supergfx: dbus.mode().is_ok(),
|
||||
mode: dbus.mode().unwrap_or(GfxMode::None),
|
||||
@@ -251,21 +212,6 @@ impl Default for GfxState {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub struct PowerState {
|
||||
pub charge_limit: u8,
|
||||
pub ac_power: bool,
|
||||
}
|
||||
|
||||
impl PowerState {
|
||||
pub fn new(_supported: &SupportedFunctions, dbus: &RogDbusClientBlocking<'_>) -> Result<Self> {
|
||||
Ok(Self {
|
||||
charge_limit: dbus.proxies().charge().charge_control_end_threshold()?,
|
||||
ac_power: dbus.proxies().charge().mains_online()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct AuraCreation {
|
||||
/// Specifically for testing the development of keyboard layouts (combined
|
||||
@@ -302,13 +248,11 @@ pub struct SystemState {
|
||||
pub enabled_notifications: Arc<Mutex<EnabledNotifications>>,
|
||||
/// Because much of the app state here is the same as
|
||||
/// `RogBiosSupportedFunctions` we can re-use that structure.
|
||||
pub bios: BiosState,
|
||||
pub bios: PlatformState,
|
||||
pub aura: AuraState,
|
||||
pub anime: AnimeState,
|
||||
pub profiles: ProfilesState,
|
||||
pub fan_curves: FanCurvesState,
|
||||
pub gfx_state: GfxState,
|
||||
pub power_state: PowerState,
|
||||
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.
|
||||
@@ -330,66 +274,46 @@ impl SystemState {
|
||||
enabled_notifications: Arc<Mutex<EnabledNotifications>>,
|
||||
tray_enabled: bool,
|
||||
run_in_bg: bool,
|
||||
supported: &SupportedFunctions,
|
||||
) -> Result<Self> {
|
||||
let (asus_dbus, conn) = RogDbusClientBlocking::new()?;
|
||||
let mut error = None;
|
||||
let gfx_dbus = GfxProxyBlocking::new(&conn).expect("Couldn't connect to supergfxd");
|
||||
|
||||
let aura = AuraState::new(&keyboard_layout, &asus_dbus)
|
||||
.map_err(|e| {
|
||||
let e = format!("Could not get AuraState state: {e}");
|
||||
error!("{e}");
|
||||
error = Some(e);
|
||||
})
|
||||
.unwrap_or_default();
|
||||
|
||||
Ok(Self {
|
||||
aura_creation: AuraCreation::new(layout_testing, keyboard_layout, keyboard_layouts),
|
||||
enabled_notifications,
|
||||
power_state: PowerState::new(supported, &asus_dbus)
|
||||
.map_err(|e| {
|
||||
let e = format!("Could not get PowerState state: {e}");
|
||||
error!("{e}");
|
||||
error = Some(e);
|
||||
})
|
||||
.unwrap_or_default(),
|
||||
bios: BiosState::new(supported, &asus_dbus)
|
||||
bios: PlatformState::new(&asus_dbus)
|
||||
.map_err(|e| {
|
||||
let e = format!("Could not get BiosState state: {e}");
|
||||
error!("{e}");
|
||||
error = Some(e);
|
||||
})
|
||||
.unwrap_or_default(),
|
||||
aura,
|
||||
anime: AnimeState::new(supported, &asus_dbus)
|
||||
anime: AnimeState::new(&asus_dbus)
|
||||
.map_err(|e| {
|
||||
let e = format!("Could not get AanimeState state: {e}");
|
||||
error!("{e}");
|
||||
error = Some(e);
|
||||
})
|
||||
.unwrap_or_default(),
|
||||
profiles: ProfilesState::new(supported, &asus_dbus)
|
||||
.map_err(|e| {
|
||||
let e = format!("Could not get ProfilesState state: {e}");
|
||||
error!("{e}");
|
||||
error = Some(e);
|
||||
})
|
||||
.unwrap_or_default(),
|
||||
fan_curves: FanCurvesState::new(supported, &asus_dbus)
|
||||
fan_curves: FanCurvesState::new(&asus_dbus)
|
||||
.map_err(|e| {
|
||||
let e = format!("Could not get FanCurvesState state: {e}");
|
||||
error!("{e}");
|
||||
error = Some(e);
|
||||
})
|
||||
.unwrap_or_default(),
|
||||
gfx_state: GfxState::new(supported, &gfx_dbus)
|
||||
gfx_state: GfxState::new(&gfx_dbus)
|
||||
.map_err(|e| {
|
||||
let e = format!("Could not get supergfxd state: {e}");
|
||||
error!("{e}");
|
||||
error = Some(e);
|
||||
})
|
||||
.unwrap_or_default(),
|
||||
error,
|
||||
error: None,
|
||||
tray_should_update: true,
|
||||
app_should_update: true,
|
||||
asus_dbus,
|
||||
@@ -419,9 +343,10 @@ impl Default for SystemState {
|
||||
keyboard_layout_index: 0,
|
||||
},
|
||||
enabled_notifications: Default::default(),
|
||||
bios: BiosState {
|
||||
bios: PlatformState {
|
||||
post_sound: Default::default(),
|
||||
dedicated_gfx: GpuMode::NotSupported,
|
||||
gpu_mux_mode: None,
|
||||
charge_limit: Some(100),
|
||||
..Default::default()
|
||||
},
|
||||
aura: AuraState {
|
||||
@@ -431,9 +356,6 @@ impl Default for SystemState {
|
||||
..Default::default()
|
||||
},
|
||||
anime: AnimeState::default(),
|
||||
profiles: ProfilesState {
|
||||
..Default::default()
|
||||
},
|
||||
fan_curves: FanCurvesState {
|
||||
..Default::default()
|
||||
},
|
||||
@@ -442,10 +364,6 @@ impl Default for SystemState {
|
||||
mode: GfxMode::None,
|
||||
power_status: GfxPower::Unknown,
|
||||
},
|
||||
power_state: PowerState {
|
||||
charge_limit: 99,
|
||||
ac_power: false,
|
||||
},
|
||||
error: Default::default(),
|
||||
tray_should_update: true,
|
||||
app_should_update: true,
|
||||
|
||||
@@ -9,9 +9,8 @@ use gtk::gio::Icon;
|
||||
use gtk::prelude::*;
|
||||
use libappindicator::{AppIndicator, AppIndicatorStatus};
|
||||
use log::{debug, error, info, trace, warn};
|
||||
use rog_dbus::zbus_platform::RogBiosProxyBlocking;
|
||||
use rog_platform::platform::GpuMode;
|
||||
use rog_platform::supported::SupportedFunctions;
|
||||
use rog_dbus::zbus_platform::PlatformProxyBlocking;
|
||||
use rog_platform::platform::{GpuMode, Properties};
|
||||
use supergfxctl::actions::UserActionRequired as GfxUserActionRequired;
|
||||
use supergfxctl::pci_device::{GfxMode, GfxPower};
|
||||
use supergfxctl::zbus_proxy::DaemonProxyBlocking as GfxProxyBlocking;
|
||||
@@ -73,14 +72,15 @@ pub struct ROGTray {
|
||||
tray: AppIndicator,
|
||||
menu: gtk::Menu,
|
||||
icon: &'static str,
|
||||
bios_proxy: RogBiosProxyBlocking<'static>,
|
||||
bios_proxy: PlatformProxyBlocking<'static>,
|
||||
gfx_proxy_is_active: bool,
|
||||
gfx_action: Arc<Mutex<GfxUserActionRequired>>,
|
||||
gfx_proxy: GfxProxyBlocking<'static>,
|
||||
states: Arc<Mutex<SystemState>>,
|
||||
}
|
||||
|
||||
impl ROGTray {
|
||||
pub fn new() -> Result<Self> {
|
||||
pub fn new(states: Arc<Mutex<SystemState>>) -> Result<Self> {
|
||||
let conn = zbus::blocking::Connection::system().map_err(|e| {
|
||||
error!("ROGTray: {e}");
|
||||
e
|
||||
@@ -95,13 +95,14 @@ impl ROGTray {
|
||||
tray: AppIndicator::new(TRAY_LABEL, TRAY_APP_ICON),
|
||||
menu: gtk::Menu::new(),
|
||||
icon: TRAY_APP_ICON,
|
||||
bios_proxy: RogBiosProxyBlocking::new(&conn).map_err(|e| {
|
||||
bios_proxy: PlatformProxyBlocking::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,
|
||||
states,
|
||||
};
|
||||
Ok(rog_tray)
|
||||
}
|
||||
@@ -219,41 +220,43 @@ impl ROGTray {
|
||||
debug!("ROGTray: built base menu");
|
||||
}
|
||||
|
||||
fn menu_add_charge_limit(&mut self, supported: &SupportedFunctions, limit: u8) {
|
||||
if supported.charge_ctrl.charge_level_set {
|
||||
self.add_inactive_label(&format!("Charge limit: {limit}"));
|
||||
debug!("ROGTray: appended charge limit menu");
|
||||
}
|
||||
fn menu_add_charge_limit(&mut self, limit: u8) {
|
||||
self.add_inactive_label(&format!("Charge limit: {limit}"));
|
||||
debug!("ROGTray: appended charge limit menu");
|
||||
}
|
||||
|
||||
fn menu_add_panel_od(&mut self, supported: &SupportedFunctions, panel_od: bool) {
|
||||
if supported.rog_bios_ctrl.panel_overdrive {
|
||||
let bios = self.bios_proxy.clone();
|
||||
self.add_check_menu_item("Panel Overdrive", panel_od, move |this| {
|
||||
bios.set_panel_od(this.is_active())
|
||||
.map_err(|e| {
|
||||
error!("ROGTray: set_panel_od: {e}");
|
||||
e
|
||||
})
|
||||
.ok();
|
||||
});
|
||||
debug!("ROGTray: appended panel overdrive menu");
|
||||
}
|
||||
fn menu_add_panel_od(&mut self, panel_od: bool) {
|
||||
let bios = self.bios_proxy.clone();
|
||||
let states = self.states.clone();
|
||||
self.add_check_menu_item("Panel Overdrive", panel_od, move |this| {
|
||||
if let Ok(mut lock) = states.lock() {
|
||||
lock.tray_should_update = true;
|
||||
}
|
||||
bios.set_panel_od(this.is_active())
|
||||
.map_err(|e| {
|
||||
error!("ROGTray: set_panel_od: {e}");
|
||||
e
|
||||
})
|
||||
.ok();
|
||||
});
|
||||
debug!("ROGTray: appended panel overdrive menu");
|
||||
}
|
||||
|
||||
fn menu_add_mini_led_mode(&mut self, supported: &SupportedFunctions, on: bool) {
|
||||
if supported.rog_bios_ctrl.mini_led_mode {
|
||||
let bios = self.bios_proxy.clone();
|
||||
self.add_check_menu_item("MiniLED mode", on, move |this| {
|
||||
bios.set_mini_led_mode(this.is_active())
|
||||
.map_err(|e| {
|
||||
error!("ROGTray: set_mini_led_mode: {e}");
|
||||
e
|
||||
})
|
||||
.ok();
|
||||
});
|
||||
debug!("ROGTray: appended miniLED mode menu");
|
||||
}
|
||||
fn menu_add_mini_led_mode(&mut self, on: bool) {
|
||||
let bios = self.bios_proxy.clone();
|
||||
let states = self.states.clone();
|
||||
self.add_check_menu_item("MiniLED mode", on, move |this| {
|
||||
if let Ok(mut lock) = states.lock() {
|
||||
lock.tray_should_update = true;
|
||||
}
|
||||
bios.set_mini_led_mode(this.is_active())
|
||||
.map_err(|e| {
|
||||
error!("ROGTray: set_mini_led_mode: {e}");
|
||||
e
|
||||
})
|
||||
.ok();
|
||||
});
|
||||
debug!("ROGTray: appended miniLED mode menu");
|
||||
}
|
||||
|
||||
fn menu_add_supergfx(&mut self, supported_gfx: &[GfxMode], current_mode: GfxMode) {
|
||||
@@ -264,8 +267,12 @@ impl ROGTray {
|
||||
|
||||
let gfx_dbus = self.gfx_proxy.clone();
|
||||
let gfx_action = self.gfx_action.clone();
|
||||
let states = self.states.clone();
|
||||
let mut gpu_menu = RadioGroup::new("Integrated", move |_| {
|
||||
if current_mode != GfxMode::Integrated {
|
||||
if let Ok(mut lock) = states.lock() {
|
||||
lock.tray_should_update = true;
|
||||
}
|
||||
if let Ok(res) = gfx_dbus.set_mode(&GfxMode::Integrated).map_err(|e| {
|
||||
error!("ROGTray: srt_mode: {e}");
|
||||
e
|
||||
@@ -280,8 +287,12 @@ impl ROGTray {
|
||||
let mut func = |menu_mode: GfxMode| {
|
||||
let gfx_dbus = self.gfx_proxy.clone();
|
||||
let gfx_action = self.gfx_action.clone();
|
||||
let states = self.states.clone();
|
||||
gpu_menu.add(&format!("{menu_mode}"), move |_| {
|
||||
if current_mode != menu_mode {
|
||||
if let Ok(mut lock) = states.lock() {
|
||||
lock.tray_should_update = true;
|
||||
}
|
||||
if let Ok(res) = gfx_dbus.set_mode(&menu_mode).map_err(|e| {
|
||||
error!("ROGTray: set_mode: {e}");
|
||||
e
|
||||
@@ -332,7 +343,11 @@ impl ROGTray {
|
||||
reboot_required = mode != current_mode;
|
||||
}
|
||||
|
||||
let states = self.states.clone();
|
||||
let mut gpu_menu = RadioGroup::new("Optimus", move |_| {
|
||||
if let Ok(mut lock) = states.lock() {
|
||||
lock.tray_should_update = true;
|
||||
}
|
||||
gfx_dbus
|
||||
.set_gpu_mux_mode(GpuMode::Optimus)
|
||||
.map_err(|e| {
|
||||
@@ -344,7 +359,11 @@ impl ROGTray {
|
||||
});
|
||||
|
||||
let gfx_dbus = self.bios_proxy.clone();
|
||||
let states = self.states.clone();
|
||||
gpu_menu.add("Ultimate", move |_| {
|
||||
if let Ok(mut lock) = states.lock() {
|
||||
lock.tray_should_update = true;
|
||||
}
|
||||
gfx_dbus
|
||||
.set_gpu_mux_mode(GpuMode::Discrete)
|
||||
.map_err(|e| {
|
||||
@@ -390,22 +409,28 @@ impl ROGTray {
|
||||
/// Do a flush, build, and update of the tray menu
|
||||
fn rebuild_and_update(
|
||||
&mut self,
|
||||
supported: &SupportedFunctions,
|
||||
supported_properties: &[Properties],
|
||||
supported_gfx: &[GfxMode],
|
||||
current_gfx_mode: GfxMode,
|
||||
charge_limit: u8,
|
||||
panel_od: bool,
|
||||
mini_led: bool,
|
||||
charge_limit: Option<u8>,
|
||||
panel_od: Option<bool>,
|
||||
mini_led: Option<bool>,
|
||||
) {
|
||||
self.menu_clear();
|
||||
self.menu_add_base();
|
||||
self.menu_add_charge_limit(supported, charge_limit);
|
||||
self.menu_add_panel_od(supported, panel_od);
|
||||
self.menu_add_mini_led_mode(supported, mini_led);
|
||||
if let Some(charge_limit) = charge_limit {
|
||||
self.menu_add_charge_limit(charge_limit);
|
||||
}
|
||||
if let Some(panel_od) = panel_od {
|
||||
self.menu_add_panel_od(panel_od);
|
||||
}
|
||||
if let Some(mini_led) = mini_led {
|
||||
self.menu_add_mini_led_mode(mini_led);
|
||||
}
|
||||
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 {
|
||||
} else if supported_properties.contains(&Properties::GpuMuxMode) {
|
||||
self.menu_add_mux(current_gfx_mode);
|
||||
}
|
||||
self.menu_update();
|
||||
@@ -413,7 +438,7 @@ impl ROGTray {
|
||||
}
|
||||
|
||||
/// The tray is controlled somewhat by `Arc<Mutex<SystemState>>`
|
||||
pub fn init_tray(supported: SupportedFunctions, states: Arc<Mutex<SystemState>>) {
|
||||
pub fn init_tray(supported_properties: Vec<Properties>, states: Arc<Mutex<SystemState>>) {
|
||||
std::thread::spawn(move || {
|
||||
let gtk_init = gtk::init().map_err(|e| {
|
||||
error!("ROGTray: gtk init {e}");
|
||||
@@ -424,7 +449,7 @@ pub fn init_tray(supported: SupportedFunctions, states: Arc<Mutex<SystemState>>)
|
||||
} // Make this the main thread for gtk
|
||||
debug!("init_tray gtk");
|
||||
|
||||
let mut tray = match ROGTray::new() {
|
||||
let mut tray = match ROGTray::new(states.clone()) {
|
||||
Ok(t) => {
|
||||
info!("init_tray: built menus");
|
||||
t
|
||||
@@ -460,33 +485,36 @@ pub fn init_tray(supported: SupportedFunctions, states: Arc<Mutex<SystemState>>)
|
||||
};
|
||||
|
||||
tray.rebuild_and_update(
|
||||
&supported,
|
||||
&supported_properties,
|
||||
&supported_gfx,
|
||||
GfxMode::Hybrid,
|
||||
100,
|
||||
false,
|
||||
false,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
tray.set_icon(TRAY_APP_ICON);
|
||||
info!("Started ROGTray");
|
||||
|
||||
loop {
|
||||
let states = tray.states.clone();
|
||||
if let Ok(mut lock) = states.lock() {
|
||||
if lock.tray_should_update {
|
||||
// Supergfx ends up adding some complexity to handle if it isn't available
|
||||
let current_gpu_mode = if lock.gfx_state.has_supergfx {
|
||||
lock.gfx_state.mode
|
||||
} else {
|
||||
match lock.bios.dedicated_gfx {
|
||||
} else if let Some(mode) = lock.bios.gpu_mux_mode {
|
||||
match mode {
|
||||
GpuMode::Discrete => GfxMode::AsusMuxDgpu,
|
||||
_ => GfxMode::Hybrid,
|
||||
}
|
||||
} else {
|
||||
GfxMode::Hybrid
|
||||
};
|
||||
tray.rebuild_and_update(
|
||||
&supported,
|
||||
&supported_properties,
|
||||
&supported_gfx,
|
||||
current_gpu_mode,
|
||||
lock.power_state.charge_limit,
|
||||
lock.bios.charge_limit,
|
||||
lock.bios.panel_overdrive,
|
||||
lock.bios.mini_led_mode,
|
||||
);
|
||||
@@ -523,7 +551,7 @@ pub fn init_tray(supported: SupportedFunctions, states: Arc<Mutex<SystemState>>)
|
||||
continue;
|
||||
}
|
||||
// Don't spool at max speed if no gtk events
|
||||
std::thread::sleep(Duration::from_millis(300));
|
||||
std::thread::sleep(Duration::from_millis(50));
|
||||
trace!("Tray loop ticked");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -12,12 +12,9 @@ use std::time::Duration;
|
||||
use log::{error, info, trace, warn};
|
||||
use notify_rust::{Hint, Notification, NotificationHandle, Urgency};
|
||||
use rog_dbus::zbus_anime::AnimeProxy;
|
||||
use rog_dbus::zbus_led::LedProxy;
|
||||
use rog_dbus::zbus_platform::RogBiosProxy;
|
||||
use rog_dbus::zbus_power::PowerProxy;
|
||||
use rog_dbus::zbus_profile::ProfileProxy;
|
||||
use rog_platform::platform::GpuMode;
|
||||
use rog_profiles::Profile;
|
||||
use rog_dbus::zbus_aura::AuraProxy;
|
||||
use rog_dbus::zbus_platform::PlatformProxy;
|
||||
use rog_platform::platform::{GpuMode, PlatformPolicy};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use supergfxctl::actions::UserActionRequired as GfxUserAction;
|
||||
use supergfxctl::pci_device::{GfxMode, GfxPower};
|
||||
@@ -42,11 +39,11 @@ pub struct EnabledNotifications {
|
||||
pub receive_mini_led_mode_changed: bool,
|
||||
pub receive_dgpu_disable_changed: bool,
|
||||
pub receive_egpu_enable_changed: bool,
|
||||
pub receive_notify_gpu_mux_mode: bool,
|
||||
pub receive_notify_charge_control_end_threshold: bool,
|
||||
pub receive_gpu_mux_mode_changed: bool,
|
||||
pub receive_charge_control_end_threshold_changed: bool,
|
||||
pub receive_notify_mains_online: bool,
|
||||
pub receive_notify_profile: bool,
|
||||
pub receive_notify_led: bool,
|
||||
pub receive_throttle_thermal_policy_changed: bool,
|
||||
pub receive_led_mode_data_changed: bool,
|
||||
/// Anime
|
||||
pub receive_power_states: bool,
|
||||
pub receive_notify_gfx: bool,
|
||||
@@ -62,11 +59,11 @@ impl Default for EnabledNotifications {
|
||||
receive_mini_led_mode_changed: true,
|
||||
receive_dgpu_disable_changed: true,
|
||||
receive_egpu_enable_changed: true,
|
||||
receive_notify_gpu_mux_mode: true,
|
||||
receive_notify_charge_control_end_threshold: true,
|
||||
receive_gpu_mux_mode_changed: true,
|
||||
receive_charge_control_end_threshold_changed: true,
|
||||
receive_notify_mains_online: false,
|
||||
receive_notify_profile: true,
|
||||
receive_notify_led: true,
|
||||
receive_throttle_thermal_policy_changed: true,
|
||||
receive_led_mode_data_changed: true,
|
||||
receive_power_states: false,
|
||||
receive_notify_gfx: false,
|
||||
receive_notify_gfx_status: false,
|
||||
@@ -160,7 +157,7 @@ macro_rules! recv_changed {
|
||||
}
|
||||
}
|
||||
if let Ok(mut lock) = page_states1.lock() {
|
||||
lock.$($args)+ = out;
|
||||
lock.$($args)+ = out.into();
|
||||
lock.set_notified();
|
||||
}
|
||||
}
|
||||
@@ -201,7 +198,7 @@ pub fn start_notifications(
|
||||
|
||||
// BIOS notif
|
||||
recv_changed!(
|
||||
RogBiosProxy,
|
||||
PlatformProxy,
|
||||
receive_post_animation_sound_changed,
|
||||
last_notification,
|
||||
enabled_notifications,
|
||||
@@ -212,7 +209,7 @@ pub fn start_notifications(
|
||||
);
|
||||
|
||||
recv_changed!(
|
||||
RogBiosProxy,
|
||||
PlatformProxy,
|
||||
receive_panel_od_changed,
|
||||
last_notification,
|
||||
enabled_notifications,
|
||||
@@ -223,7 +220,7 @@ pub fn start_notifications(
|
||||
);
|
||||
|
||||
recv_changed!(
|
||||
RogBiosProxy,
|
||||
PlatformProxy,
|
||||
receive_mini_led_mode_changed,
|
||||
last_notification,
|
||||
enabled_notifications,
|
||||
@@ -234,7 +231,7 @@ pub fn start_notifications(
|
||||
);
|
||||
|
||||
recv_changed!(
|
||||
RogBiosProxy,
|
||||
PlatformProxy,
|
||||
receive_dgpu_disable_changed,
|
||||
last_notification,
|
||||
enabled_notifications,
|
||||
@@ -245,7 +242,7 @@ pub fn start_notifications(
|
||||
);
|
||||
|
||||
recv_changed!(
|
||||
RogBiosProxy,
|
||||
PlatformProxy,
|
||||
receive_egpu_enable_changed,
|
||||
last_notification,
|
||||
enabled_notifications,
|
||||
@@ -256,85 +253,69 @@ pub fn start_notifications(
|
||||
);
|
||||
|
||||
// Charge notif
|
||||
recv_notif!(
|
||||
PowerProxy,
|
||||
receive_notify_charge_control_end_threshold,
|
||||
recv_changed!(
|
||||
PlatformProxy,
|
||||
receive_charge_control_end_threshold_changed,
|
||||
last_notification,
|
||||
enabled_notifications,
|
||||
page_states,
|
||||
(power_state.charge_limit),
|
||||
(limit),
|
||||
(bios.charge_limit),
|
||||
"Battery charge limit changed to",
|
||||
do_notification
|
||||
);
|
||||
|
||||
recv_notif!(
|
||||
PowerProxy,
|
||||
receive_notify_mains_online,
|
||||
last_notification,
|
||||
enabled_notifications,
|
||||
page_states,
|
||||
(power_state.ac_power),
|
||||
(on),
|
||||
"AC Power power is",
|
||||
ac_power_notification
|
||||
);
|
||||
|
||||
// Profile notif
|
||||
recv_notif!(
|
||||
ProfileProxy,
|
||||
receive_notify_profile,
|
||||
recv_changed!(
|
||||
PlatformProxy,
|
||||
receive_throttle_thermal_policy_changed,
|
||||
last_notification,
|
||||
enabled_notifications,
|
||||
page_states,
|
||||
(profiles.current),
|
||||
(profile),
|
||||
(bios.throttle),
|
||||
"Profile changed to",
|
||||
do_thermal_notif
|
||||
);
|
||||
// notify!(do_thermal_notif(&out.profile), lock);
|
||||
|
||||
// LED notif
|
||||
recv_notif!(
|
||||
LedProxy,
|
||||
receive_notify_led,
|
||||
recv_changed!(
|
||||
AuraProxy,
|
||||
receive_led_mode_data_changed,
|
||||
last_notification,
|
||||
enabled_notifications,
|
||||
page_states,
|
||||
(aura.current_mode),
|
||||
(data.mode),
|
||||
"Keyboard LED mode changed to",
|
||||
do_notification
|
||||
);
|
||||
|
||||
let page_states1 = page_states.clone();
|
||||
tokio::spawn(async move {
|
||||
let conn = zbus::Connection::system()
|
||||
.await
|
||||
.map_err(|e| {
|
||||
error!("zbus signal: receive_device_state: {e}");
|
||||
e
|
||||
})
|
||||
.unwrap();
|
||||
let proxy = LedProxy::new(&conn)
|
||||
.await
|
||||
.map_err(|e| {
|
||||
error!("zbus signal: receive_device_state: {e}");
|
||||
e
|
||||
})
|
||||
.unwrap();
|
||||
if let Ok(mut p) = proxy.receive_notify_power_states().await {
|
||||
info!("Started zbus signal thread: receive_notify_power_states");
|
||||
while let Some(e) = p.next().await {
|
||||
if let Ok(out) = e.args() {
|
||||
if let Ok(mut lock) = page_states1.lock() {
|
||||
lock.aura.enabled = out.data;
|
||||
lock.set_notified();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
// let page_states1 = page_states.clone();
|
||||
// tokio::spawn(async move {
|
||||
// let conn = zbus::Connection::system()
|
||||
// .await
|
||||
// .map_err(|e| {
|
||||
// error!("zbus signal: receive_device_state: {e}");
|
||||
// e
|
||||
// })
|
||||
// .unwrap();
|
||||
// let proxy = AuraProxy::new(&conn)
|
||||
// .await
|
||||
// .map_err(|e| {
|
||||
// error!("zbus signal: receive_device_state: {e}");
|
||||
// e
|
||||
// })
|
||||
// .unwrap();
|
||||
// let p = proxy.receive_led_power_changed().await;
|
||||
// info!("Started zbus signal thread: receive_notify_power_states");
|
||||
// while let Some(e) = p.next().await {
|
||||
// if let Ok(out) = e.get().await {
|
||||
// if let Ok(mut lock) = page_states1.lock() {
|
||||
// lock.aura.enabled = out;
|
||||
// lock.set_notified();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
|
||||
let page_states1 = page_states.clone();
|
||||
tokio::spawn(async move {
|
||||
@@ -373,7 +354,7 @@ pub fn start_notifications(
|
||||
e
|
||||
})
|
||||
.unwrap();
|
||||
let proxy = RogBiosProxy::new(&conn)
|
||||
let proxy = PlatformProxy::new(&conn)
|
||||
.await
|
||||
.map_err(|e| {
|
||||
error!("zbus signal: receive_notify_gpu_mux_mode: {e}");
|
||||
@@ -394,7 +375,7 @@ pub fn start_notifications(
|
||||
continue;
|
||||
}
|
||||
if let Ok(mut lock) = page_states1.lock() {
|
||||
lock.bios.dedicated_gfx = mode;
|
||||
lock.bios.gpu_mux_mode = Some(mode);
|
||||
lock.set_notified();
|
||||
}
|
||||
do_mux_notification("Reboot required. BIOS GPU MUX mode set to", &mode).ok();
|
||||
@@ -541,7 +522,8 @@ where
|
||||
Ok(base_notification(message, data).show()?)
|
||||
}
|
||||
|
||||
fn ac_power_notification(message: &str, on: &bool) -> Result<NotificationHandle> {
|
||||
// TODO:
|
||||
fn _ac_power_notification(message: &str, on: &bool) -> Result<NotificationHandle> {
|
||||
let data = if *on {
|
||||
unsafe {
|
||||
if let Some(cmd) = POWER_AC_CMD.as_mut() {
|
||||
@@ -564,11 +546,11 @@ fn ac_power_notification(message: &str, on: &bool) -> Result<NotificationHandle>
|
||||
Ok(base_notification(message, &data).show()?)
|
||||
}
|
||||
|
||||
fn do_thermal_notif(message: &str, profile: &Profile) -> Result<NotificationHandle> {
|
||||
fn do_thermal_notif(message: &str, profile: &PlatformPolicy) -> Result<NotificationHandle> {
|
||||
let icon = match profile {
|
||||
Profile::Balanced => "asus_notif_yellow",
|
||||
Profile::Performance => "asus_notif_red",
|
||||
Profile::Quiet => "asus_notif_green",
|
||||
PlatformPolicy::Balanced => "asus_notif_yellow",
|
||||
PlatformPolicy::Performance => "asus_notif_red",
|
||||
PlatformPolicy::Quiet => "asus_notif_green",
|
||||
};
|
||||
let profile: &str = (*profile).into();
|
||||
let mut notif = base_notification(message, &profile.to_uppercase());
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
use egui::{RichText, Ui};
|
||||
use rog_anime::usb::Brightness;
|
||||
use rog_platform::supported::SupportedFunctions;
|
||||
|
||||
use crate::system_state::SystemState;
|
||||
|
||||
pub fn anime_power_group(_supported: &SupportedFunctions, states: &mut SystemState, ui: &mut Ui) {
|
||||
pub fn anime_power_group(states: &mut SystemState, ui: &mut Ui) {
|
||||
ui.heading("AniMe Matrix Settings");
|
||||
ui.label("Options are incomplete. Awake + Boot should work");
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ pub fn app_settings(config: &mut Config, states: &mut SystemState, ui: &mut Ui)
|
||||
.clicked()
|
||||
|| ui
|
||||
.checkbox(
|
||||
&mut enabled_notifications.receive_notify_led,
|
||||
&mut enabled_notifications.receive_led_mode_data_changed,
|
||||
"Enable LED mode change notification",
|
||||
)
|
||||
.clicked()
|
||||
@@ -69,13 +69,13 @@ pub fn app_settings(config: &mut Config, states: &mut SystemState, ui: &mut Ui)
|
||||
.clicked()
|
||||
|| ui
|
||||
.checkbox(
|
||||
&mut enabled_notifications.receive_notify_charge_control_end_threshold,
|
||||
&mut enabled_notifications.receive_charge_control_end_threshold_changed,
|
||||
"Enable charge threshold notification",
|
||||
)
|
||||
.clicked()
|
||||
|| ui
|
||||
.checkbox(
|
||||
&mut enabled_notifications.receive_notify_profile,
|
||||
&mut enabled_notifications.receive_throttle_thermal_policy_changed,
|
||||
"Enable profile change notification",
|
||||
)
|
||||
.clicked()
|
||||
|
||||
@@ -228,8 +228,8 @@ pub fn aura_modes_group(states: &mut SystemState, freq: &mut Arc<AtomicU8>, ui:
|
||||
states
|
||||
.asus_dbus
|
||||
.proxies()
|
||||
.led()
|
||||
.set_led_mode(states.aura.modes.get(&selected).unwrap())
|
||||
.aura()
|
||||
.set_led_mode(states.aura.modes.get(&selected).unwrap().mode)
|
||||
.map_err(|err| {
|
||||
states.error = Some(err.to_string());
|
||||
})
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
use egui::{RichText, Ui};
|
||||
use rog_aura::power::{AuraPower, KbAuraPowerState};
|
||||
use rog_aura::usb::{AuraDevRog1, AuraDevTuf, AuraDevice, AuraPowerDev};
|
||||
use rog_platform::supported::SupportedFunctions;
|
||||
|
||||
use crate::system_state::SystemState;
|
||||
|
||||
@@ -132,7 +131,7 @@ fn aura_power1(supported: &SupportedFunctions, states: &mut SystemState, ui: &mu
|
||||
states
|
||||
.asus_dbus
|
||||
.proxies()
|
||||
.led()
|
||||
.aura()
|
||||
.set_led_power(options, enable)
|
||||
.map_err(|err| {
|
||||
states.error = Some(err.to_string());
|
||||
@@ -182,7 +181,7 @@ fn aura_power1(supported: &SupportedFunctions, states: &mut SystemState, ui: &mu
|
||||
states
|
||||
.asus_dbus
|
||||
.proxies()
|
||||
.led()
|
||||
.aura()
|
||||
.set_led_power(options, enable)
|
||||
.map_err(|err| {
|
||||
states.error = Some(err.to_string());
|
||||
@@ -247,7 +246,7 @@ fn aura_power2(supported: &SupportedFunctions, states: &mut SystemState, ui: &mu
|
||||
states
|
||||
.asus_dbus
|
||||
.proxies()
|
||||
.led()
|
||||
.aura()
|
||||
.set_led_power(options, enable)
|
||||
.map_err(|err| {
|
||||
states.error = Some(err.to_string());
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
use egui::plot::Points;
|
||||
use egui::Ui;
|
||||
use rog_platform::supported::SupportedFunctions;
|
||||
use rog_platform::platform::PlatformPolicy;
|
||||
use rog_profiles::fan_curve_set::CurveData;
|
||||
use rog_profiles::{FanCurvePU, Profile};
|
||||
use rog_profiles::FanCurvePU;
|
||||
|
||||
use crate::system_state::FanCurvesState;
|
||||
use crate::RogDbusClientBlocking;
|
||||
|
||||
pub fn fan_graphs(
|
||||
supported: &SupportedFunctions,
|
||||
curves: &mut FanCurvesState,
|
||||
dbus: &RogDbusClientBlocking<'_>,
|
||||
do_error: &mut Option<String>,
|
||||
@@ -16,13 +15,16 @@ pub fn fan_graphs(
|
||||
) {
|
||||
ui.separator();
|
||||
|
||||
let mut item = |profile: Profile, ui: &mut Ui| {
|
||||
let mut item = |profile: PlatformPolicy, ui: &mut Ui| {
|
||||
ui.group(|ui| {
|
||||
if ui
|
||||
.selectable_value(&mut curves.show_curve, profile, format!("{profile:?}"))
|
||||
.clicked()
|
||||
{
|
||||
dbus.proxies().profile().set_active_profile(profile).ok();
|
||||
dbus.proxies()
|
||||
.platform()
|
||||
.set_throttle_thermal_policy(profile)
|
||||
.ok();
|
||||
}
|
||||
ui.add_enabled_ui(curves.show_curve == profile, |ui| {
|
||||
if curves.available_fans.contains(&FanCurvePU::CPU) {
|
||||
@@ -164,7 +166,7 @@ pub fn fan_graphs(
|
||||
|
||||
if set {
|
||||
dbus.proxies()
|
||||
.profile()
|
||||
.fan_curves()
|
||||
.set_fan_curve(curves.show_curve, data.clone())
|
||||
.map_err(|err| {
|
||||
*do_error = Some(err.to_string());
|
||||
@@ -175,7 +177,7 @@ pub fn fan_graphs(
|
||||
if clear {
|
||||
if let Ok(curve) = dbus
|
||||
.proxies()
|
||||
.profile()
|
||||
.fan_curves()
|
||||
.fan_curve_data(curves.show_curve)
|
||||
.map_err(|err| {
|
||||
*do_error = Some(err.to_string());
|
||||
@@ -189,14 +191,14 @@ pub fn fan_graphs(
|
||||
|
||||
if reset {
|
||||
dbus.proxies()
|
||||
.profile()
|
||||
.fan_curves()
|
||||
.reset_profile_curves(curves.show_curve)
|
||||
.map_err(|err| {
|
||||
*do_error = Some(err.to_string());
|
||||
})
|
||||
.ok();
|
||||
|
||||
match FanCurvesState::new(supported, dbus) {
|
||||
match FanCurvesState::new(dbus) {
|
||||
Ok(f) => *curves = f,
|
||||
Err(e) => *do_error = Some(e.to_string()),
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
mod anime_power;
|
||||
mod app_settings;
|
||||
mod aura_modes;
|
||||
mod aura_power;
|
||||
// mod aura_power;
|
||||
mod fan_graph;
|
||||
mod keyboard_layout;
|
||||
mod rog_bios;
|
||||
@@ -11,7 +11,7 @@ mod top_bar;
|
||||
pub use anime_power::*;
|
||||
pub use app_settings::*;
|
||||
pub use aura_modes::*;
|
||||
pub use aura_power::*;
|
||||
// pub use aura_power::*;
|
||||
pub use fan_graph::*;
|
||||
pub use keyboard_layout::*;
|
||||
pub use rog_bios::*;
|
||||
|
||||
@@ -1,124 +1,114 @@
|
||||
use egui::Ui;
|
||||
use rog_platform::platform::GpuMode;
|
||||
use rog_platform::supported::SupportedFunctions;
|
||||
use rog_profiles::Profile;
|
||||
use rog_platform::platform::{GpuMode, PlatformPolicy};
|
||||
|
||||
use crate::system_state::SystemState;
|
||||
|
||||
pub fn platform_profile(states: &mut SystemState, ui: &mut Ui) {
|
||||
ui.heading("Platform profile");
|
||||
if let Some(mut throttle) = states.bios.throttle {
|
||||
ui.heading("Platform profile");
|
||||
|
||||
let mut changed = false;
|
||||
let mut item = |p: Profile, ui: &mut Ui| {
|
||||
if ui
|
||||
.selectable_value(&mut states.profiles.current, p, format!("{p:?}"))
|
||||
.clicked()
|
||||
{
|
||||
changed = true;
|
||||
}
|
||||
};
|
||||
let mut item = |p: PlatformPolicy, ui: &mut Ui| {
|
||||
if ui
|
||||
.selectable_value(&mut throttle, p, format!("{p:?}"))
|
||||
.clicked()
|
||||
{
|
||||
states
|
||||
.asus_dbus
|
||||
.proxies()
|
||||
.platform()
|
||||
.set_throttle_thermal_policy(throttle)
|
||||
.map_err(|err| {
|
||||
states.error = Some(err.to_string());
|
||||
})
|
||||
.ok();
|
||||
}
|
||||
};
|
||||
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
for a in &states.profiles.list {
|
||||
item(*a, ui);
|
||||
}
|
||||
});
|
||||
|
||||
if changed {
|
||||
states
|
||||
.asus_dbus
|
||||
.proxies()
|
||||
.profile()
|
||||
.set_active_profile(states.profiles.current)
|
||||
.map_err(|err| {
|
||||
states.error = Some(err.to_string());
|
||||
})
|
||||
.ok();
|
||||
};
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
for a in PlatformPolicy::list() {
|
||||
item(a, ui);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
pub fn rog_bios_group(supported: &SupportedFunctions, states: &mut SystemState, ui: &mut Ui) {
|
||||
pub fn rog_bios_group(states: &mut SystemState, ui: &mut Ui) {
|
||||
ui.heading("Bios options");
|
||||
|
||||
let slider = egui::Slider::new(&mut states.power_state.charge_limit, 20..=100)
|
||||
.text("Charging limit")
|
||||
.step_by(1.0);
|
||||
if ui.add(slider).drag_released() {
|
||||
states
|
||||
.asus_dbus
|
||||
.proxies()
|
||||
.charge()
|
||||
.set_charge_control_end_threshold(states.power_state.charge_limit)
|
||||
.map_err(|err| {
|
||||
states.error = Some(err.to_string());
|
||||
})
|
||||
.ok();
|
||||
if let Some(mut limit) = states.bios.charge_limit {
|
||||
let slider = egui::Slider::new(&mut limit, 20..=100)
|
||||
.text("Charging limit")
|
||||
.step_by(1.0);
|
||||
if ui.add(slider).drag_released() {
|
||||
states
|
||||
.asus_dbus
|
||||
.proxies()
|
||||
.platform()
|
||||
.set_charge_control_end_threshold(limit)
|
||||
.map_err(|err| {
|
||||
states.error = Some(err.to_string());
|
||||
})
|
||||
.ok();
|
||||
}
|
||||
}
|
||||
|
||||
if supported.rog_bios_ctrl.post_animation_sound
|
||||
&& ui
|
||||
.add(egui::Checkbox::new(
|
||||
&mut states.bios.post_sound,
|
||||
"POST sound",
|
||||
))
|
||||
if let Some(mut sound) = states.bios.post_sound {
|
||||
if ui
|
||||
.add(egui::Checkbox::new(&mut sound, "POST sound"))
|
||||
.changed()
|
||||
{
|
||||
states
|
||||
.asus_dbus
|
||||
.proxies()
|
||||
.rog_bios()
|
||||
.set_post_animation_sound(states.bios.post_sound)
|
||||
.map_err(|err| {
|
||||
states.error = Some(err.to_string());
|
||||
})
|
||||
.ok();
|
||||
{
|
||||
states
|
||||
.asus_dbus
|
||||
.proxies()
|
||||
.platform()
|
||||
.set_post_animation_sound(sound)
|
||||
.map_err(|err| {
|
||||
states.error = Some(err.to_string());
|
||||
})
|
||||
.ok();
|
||||
}
|
||||
}
|
||||
|
||||
if supported.rog_bios_ctrl.panel_overdrive
|
||||
&& ui
|
||||
.add(egui::Checkbox::new(
|
||||
&mut states.bios.panel_overdrive,
|
||||
"Panel overdrive",
|
||||
))
|
||||
if let Some(mut overdrive) = states.bios.panel_overdrive {
|
||||
if ui
|
||||
.add(egui::Checkbox::new(&mut overdrive, "Panel overdrive"))
|
||||
.changed()
|
||||
{
|
||||
states
|
||||
.asus_dbus
|
||||
.proxies()
|
||||
.rog_bios()
|
||||
.set_panel_od(states.bios.panel_overdrive)
|
||||
.map_err(|err| {
|
||||
states.error = Some(err.to_string());
|
||||
})
|
||||
.ok();
|
||||
{
|
||||
states
|
||||
.asus_dbus
|
||||
.proxies()
|
||||
.platform()
|
||||
.set_panel_od(overdrive)
|
||||
.map_err(|err| {
|
||||
states.error = Some(err.to_string());
|
||||
})
|
||||
.ok();
|
||||
}
|
||||
}
|
||||
|
||||
if supported.rog_bios_ctrl.mini_led_mode
|
||||
&& ui
|
||||
.add(egui::Checkbox::new(
|
||||
&mut states.bios.mini_led_mode,
|
||||
"MiniLED backlight",
|
||||
))
|
||||
if let Some(mut mini_led_mode) = states.bios.mini_led_mode {
|
||||
if ui
|
||||
.add(egui::Checkbox::new(&mut mini_led_mode, "MiniLED backlight"))
|
||||
.changed()
|
||||
{
|
||||
states
|
||||
.asus_dbus
|
||||
.proxies()
|
||||
.rog_bios()
|
||||
.set_mini_led_mode(states.bios.mini_led_mode)
|
||||
.map_err(|err| {
|
||||
states.error = Some(err.to_string());
|
||||
})
|
||||
.ok();
|
||||
{
|
||||
states
|
||||
.asus_dbus
|
||||
.proxies()
|
||||
.platform()
|
||||
.set_mini_led_mode(mini_led_mode)
|
||||
.map_err(|err| {
|
||||
states.error = Some(err.to_string());
|
||||
})
|
||||
.ok();
|
||||
}
|
||||
}
|
||||
|
||||
if supported.rog_bios_ctrl.gpu_mux {
|
||||
if let Some(mut gpu_mux_mode) = states.bios.gpu_mux_mode {
|
||||
let mut changed = false;
|
||||
let mut dedicated_gfx = states.bios.dedicated_gfx;
|
||||
|
||||
let mut reboot_required = false;
|
||||
if let Ok(mode) = states.asus_dbus.proxies().rog_bios().gpu_mux_mode() {
|
||||
reboot_required = GpuMode::from(mode) != states.bios.dedicated_gfx;
|
||||
if let Ok(mode) = states.asus_dbus.proxies().platform().gpu_mux_mode() {
|
||||
reboot_required = GpuMode::from(mode) != gpu_mux_mode;
|
||||
}
|
||||
|
||||
ui.group(|ui| {
|
||||
@@ -128,14 +118,14 @@ pub fn rog_bios_group(supported: &SupportedFunctions, states: &mut SystemState,
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
changed = ui
|
||||
.selectable_value(
|
||||
&mut dedicated_gfx,
|
||||
&mut gpu_mux_mode,
|
||||
GpuMode::Discrete,
|
||||
"Dedicated (Ultimate)",
|
||||
)
|
||||
.clicked()
|
||||
|| ui
|
||||
.selectable_value(
|
||||
&mut dedicated_gfx,
|
||||
&mut gpu_mux_mode,
|
||||
GpuMode::Optimus,
|
||||
"Optimus (Hybrid)",
|
||||
)
|
||||
@@ -152,8 +142,8 @@ pub fn rog_bios_group(supported: &SupportedFunctions, states: &mut SystemState,
|
||||
states
|
||||
.asus_dbus
|
||||
.proxies()
|
||||
.rog_bios()
|
||||
.set_gpu_mux_mode(dedicated_gfx)
|
||||
.platform()
|
||||
.set_gpu_mux_mode(gpu_mux_mode)
|
||||
.map_err(|err| {
|
||||
states.error = Some(err.to_string());
|
||||
})
|
||||
|
||||
@@ -18,7 +18,7 @@ impl RogApp {
|
||||
*page = Page::System;
|
||||
}
|
||||
|
||||
if !self.supported.platform_profile.fans.is_empty() {
|
||||
if self.supported_interfaces.contains(&"FanCurves".to_owned()) {
|
||||
ui.separator();
|
||||
if ui
|
||||
.selectable_value(page, Page::FanCurves, "Fan Curves")
|
||||
@@ -28,7 +28,7 @@ impl RogApp {
|
||||
}
|
||||
}
|
||||
|
||||
if !self.supported.keyboard_led.basic_modes.is_empty() {
|
||||
if self.supported_interfaces.contains(&"Aura".to_owned()) {
|
||||
ui.separator();
|
||||
if ui
|
||||
.selectable_value(page, Page::AuraEffects, "Keyboard Aura")
|
||||
@@ -39,7 +39,7 @@ impl RogApp {
|
||||
}
|
||||
|
||||
// TODO: Anime page is not complete
|
||||
if self.supported.anime_ctrl.0 {
|
||||
if self.supported_interfaces.contains(&"Anime".to_owned()) {
|
||||
ui.separator();
|
||||
if ui
|
||||
.selectable_value(page, Page::AnimeMatrix, "AniMe Matrix")
|
||||
|
||||
Reference in New Issue
Block a user