Add support for mini_led_mode get/set

- asusd get/set, zbus methods
- Rog control center notification, tray menu, UI entry
This commit is contained in:
Luke D. Jones
2023-06-26 10:44:58 +12:00
parent 03c9f06569
commit acf41c1783
11 changed files with 144 additions and 31 deletions

View File

@@ -32,6 +32,7 @@ pub struct BiosState {
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,
}
@@ -54,6 +55,11 @@ impl BiosState {
} else {
false
},
mini_led_mode: if supported.rog_bios_ctrl.mini_led_mode {
dbus.proxies().rog_bios().mini_led_mode()?
} else {
false
},
// TODO: needs supergfx
dgpu_disable: supported.rog_bios_ctrl.dgpu_disable,
egpu_enable: supported.rog_bios_ctrl.egpu_enable,
@@ -410,9 +416,7 @@ impl Default for SystemState {
bios: BiosState {
post_sound: Default::default(),
dedicated_gfx: GpuMode::NotSupported,
panel_overdrive: Default::default(),
dgpu_disable: Default::default(),
egpu_enable: Default::default(),
..Default::default()
},
aura: AuraState {
current_mode: AuraModeNum::Static,
@@ -422,22 +426,14 @@ impl Default for SystemState {
x1866: vec![],
x19b6: vec![],
},
bright: Default::default(),
wave_red: Default::default(),
wave_green: Default::default(),
wave_blue: Default::default(),
..Default::default()
},
anime: AnimeState::default(),
profiles: ProfilesState {
list: Default::default(),
current: Default::default(),
..Default::default()
},
fan_curves: FanCurvesState {
show_curve: Default::default(),
show_graph: Default::default(),
enabled: Default::default(),
curves: Default::default(),
drag_delta: Default::default(),
..Default::default()
},
gfx_state: GfxState {
has_supergfx: false,

View File

@@ -247,6 +247,21 @@ impl ROGTray {
}
}
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_supergfx(&mut self, supported_gfx: &[GfxMode], current_mode: GfxMode) {
if !self.gfx_proxy_is_active {
trace!("menu_add_supergfx: gfx_proxy_is_active is false");
@@ -386,11 +401,13 @@ impl ROGTray {
current_gfx_mode: GfxMode,
charge_limit: u8,
panel_od: bool,
mini_led: 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 self.gfx_proxy_is_active {
// Add a supergfxctl specific menu
self.menu_add_supergfx(supported_gfx, current_gfx_mode);
@@ -453,7 +470,14 @@ pub fn init_tray(
Default::default()
};
tray.rebuild_and_update(&supported, &supported_gfx, GfxMode::Hybrid, 100, false);
tray.rebuild_and_update(
&supported,
&supported_gfx,
GfxMode::Hybrid,
100,
false,
false,
);
tray.set_icon(TRAY_APP_ICON);
info!("Started ROGTray");
@@ -475,6 +499,7 @@ pub fn init_tray(
current_gpu_mode,
lock.power_state.charge_limit,
lock.bios.panel_overdrive,
lock.bios.mini_led_mode,
);
lock.tray_should_update = false;
debug!("ROGTray: rebuilt menus due to state change");

View File

@@ -1,6 +1,8 @@
//! `update_and_notify` is responsible for both notifications *and* updating
//! stored statuses about the system state. This is done through either direct,
//! intoify, zbus notifications or similar methods.
//!
//! This module very much functions like a stand-alone app on its own thread.
use std::fmt::Display;
use std::process::Command;
@@ -37,6 +39,7 @@ static mut POWER_BAT_CMD: Option<Command> = None;
pub struct EnabledNotifications {
pub receive_notify_post_boot_sound: bool,
pub receive_notify_panel_od: bool,
pub receive_notify_mini_led_mode: bool,
pub receive_notify_dgpu_disable: bool,
pub receive_notify_egpu_enable: bool,
pub receive_notify_gpu_mux_mode: bool,
@@ -56,6 +59,7 @@ impl Default for EnabledNotifications {
Self {
receive_notify_post_boot_sound: false,
receive_notify_panel_od: true,
receive_notify_mini_led_mode: true,
receive_notify_dgpu_disable: true,
receive_notify_egpu_enable: true,
receive_notify_gpu_mux_mode: true,
@@ -177,6 +181,18 @@ pub fn start_notifications(
do_notification
);
recv_notif!(
RogBiosProxy,
receive_notify_mini_led_mode,
last_notification,
enabled_notifications,
page_states,
(bios.mini_led_mode),
(on),
"MiniLED mode enabled:",
do_notification
);
recv_notif!(
RogBiosProxy,
receive_notify_dgpu_disable,

View File

@@ -76,6 +76,12 @@ pub fn app_settings(config: &mut Config, states: &mut SystemState, ui: &mut Ui)
"Enable panel overdrive notification",
)
.clicked()
|| ui
.checkbox(
&mut enabled_notifications.receive_notify_mini_led_mode,
"Enable MiniLED mode notification",
)
.clicked()
|| ui
.checkbox(
&mut enabled_notifications.receive_notify_post_boot_sound,

View File

@@ -74,7 +74,7 @@ pub fn rog_bios_group(supported: &SupportedFunctions, states: &mut SystemState,
.ok();
}
if supported.rog_bios_ctrl.post_sound
if supported.rog_bios_ctrl.panel_overdrive
&& ui
.add(egui::Checkbox::new(
&mut states.bios.panel_overdrive,
@@ -93,6 +93,25 @@ pub fn rog_bios_group(supported: &SupportedFunctions, states: &mut SystemState,
.ok();
}
if supported.rog_bios_ctrl.mini_led_mode
&& ui
.add(egui::Checkbox::new(
&mut states.bios.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();
}
if supported.rog_bios_ctrl.gpu_mux {
let mut changed = false;
let mut dedicated_gfx = states.bios.dedicated_gfx;