Merge branch 'main' into main

This commit is contained in:
Luke Jones
2024-04-10 08:54:54 +12:00
committed by GitHub
61 changed files with 1573 additions and 3009 deletions

View File

@@ -23,22 +23,12 @@ pub mod types;
pub mod ui;
pub mod update_and_notify;
#[cfg(feature = "mocking")]
pub use mocking::RogDbusClientBlocking;
use nix::sys::stat;
use nix::unistd;
#[cfg(not(feature = "mocking"))]
pub use rog_dbus::RogDbusClientBlocking;
use tempfile::TempDir;
// use log::{error, info, warn};
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
#[cfg(not(feature = "mocking"))]
const DATA_DIR: &str = "/usr/share/rog-gui/";
#[cfg(feature = "mocking")]
const DATA_DIR: &str = env!("CARGO_MANIFEST_DIR");
const BOARD_NAME: &str = "/sys/class/dmi/id/board_name";
pub const APP_ICON_PATH: &str = "/usr/share/icons/hicolor/512x512/apps/rog-control-center.png";
pub fn print_versions() {
@@ -89,7 +79,7 @@ pub fn on_tmp_dir_exists() -> Result<TempDir, std::io::Error> {
ipc_file.write_all(&[SHOW_GUI, 0])?;
// tiny sleep to give the app a chance to respond
sleep(Duration::from_millis(10));
ipc_file.read(&mut buf).ok();
ipc_file.read_exact(&mut buf).ok();
// First entry is the actual state
if buf[0] == SHOWING_GUI {

View File

@@ -15,19 +15,28 @@ use rog_control_center::cli_options::CliStart;
use rog_control_center::config::Config;
use rog_control_center::error::Result;
use rog_control_center::slint::ComponentHandle;
use rog_control_center::system_state::{AuraCreation, SystemState};
use rog_control_center::system_state::SystemState;
use rog_control_center::tray::init_tray;
use rog_control_center::ui::setup_window;
use rog_control_center::update_and_notify::{start_notifications, EnabledNotifications};
use rog_control_center::{
get_ipc_file, on_tmp_dir_exists, print_versions, MainWindow, RogDbusClientBlocking, QUIT_APP,
SHOWING_GUI, SHOW_GUI,
get_ipc_file, on_tmp_dir_exists, print_versions, MainWindow, QUIT_APP, SHOWING_GUI, SHOW_GUI,
};
use tokio::runtime::Runtime;
// use winit::monitor::VideoMode;
// use winit::window::{Fullscreen, WindowLevel};
fn main() -> Result<()> {
#[tokio::main]
async fn main() -> Result<()> {
let self_version = env!("CARGO_PKG_VERSION");
let conn = zbus::blocking::Connection::system()?;
let proxy = rog_dbus::zbus_platform::PlatformProxyBlocking::new(&conn)?;
let asusd_version = proxy.version().unwrap();
if asusd_version != self_version {
println!("Version mismatch: asusctl = {self_version}, asusd = {asusd_version}");
return Ok(());
}
let dmi = DMIID::new().unwrap_or_default();
let board_name = dmi.board_name;
let prod_family = dmi.product_family;
@@ -66,17 +75,9 @@ fn main() -> Result<()> {
// Enter the runtime so that `tokio::spawn` is available immediately.
let _enter = rt.enter();
let (dbus, _) = RogDbusClientBlocking::new()
.map_err(|_| {
// TODO: show an error window
})
.unwrap();
let supported_properties = dbus
.proxies()
.platform()
.supported_properties()
.unwrap_or_else(|_e| {
let supported_properties = match proxy.supported_properties() {
Ok(s) => s,
Err(_e) => {
// TODO: show an error window
Vec::default()
});
@@ -91,24 +92,28 @@ fn main() -> Result<()> {
if cli_parsed.height_fullscreen != 0 {
config.fullscreen_height = cli_parsed.height_fullscreen;
}
config.write();
} else if cli_parsed.windowed {
config.start_fullscreen = false;
config.write();
}
if is_rog_ally {
config.enable_notifications = false;
config.enable_tray_icon = false;
config.run_in_background = false;
config.startup_in_background = false;
}
if config.startup_in_background {
config.run_in_background = true;
config.write();
} else {
get_ipc_file().unwrap().write_all(&[SHOW_GUI, 0]).unwrap();
}
config.write();
let enabled_notifications = EnabledNotifications::tokio_mutex(&config);
let aura_creation = AuraCreation::new(cli_parsed.board_name, cli_parsed.layout_viewing)?;
// TODO: config mutex to share config in various places
let states = setup_page_state_and_notifs(aura_creation, &enabled_notifications, &config)?;
let states = setup_page_state_and_notifs(&enabled_notifications, &config).await?;
let enable_tray_icon = config.enable_tray_icon;
let startup_in_background = config.startup_in_background;
@@ -207,17 +212,18 @@ fn main() -> Result<()> {
Ok(())
}
fn setup_page_state_and_notifs(
aura_creation: AuraCreation,
async fn setup_page_state_and_notifs(
enabled_notifications: &Arc<Mutex<EnabledNotifications>>,
config: &Config,
) -> Result<Arc<Mutex<SystemState>>> {
let page_states = Arc::new(Mutex::new(SystemState::new(
aura_creation,
enabled_notifications.clone(),
config.enable_tray_icon,
config.run_in_background,
)?));
let page_states = Arc::new(Mutex::new(
SystemState::new(
enabled_notifications.clone(),
config.enable_tray_icon,
config.run_in_background,
)
.await?,
));
start_notifications(config, &page_states, enabled_notifications)?;
@@ -254,8 +260,10 @@ fn setup_page_state_and_notifs(
// IconData {
// height,
// width,
// rgba,
// }
// rgba
//
//
// / }
// }
fn do_cli_help(parsed: &CliStart) -> bool {

View File

@@ -1,190 +1,15 @@
use std::collections::{BTreeMap, HashSet};
use std::path::PathBuf;
use std::sync::{Arc, Mutex};
use std::time::SystemTime;
use log::{error, warn};
use rog_anime::{Animations, DeviceState};
use rog_aura::aura_detection::{LaptopLedData, LedSupportFile};
use rog_aura::layouts::KeyLayout;
use rog_aura::usb::AuraPowerDev;
use rog_aura::{AuraEffect, AuraModeNum, LedBrightness};
use rog_platform::platform::{GpuMode, ThrottlePolicy};
use rog_profiles::fan_curve_set::CurveData;
use rog_profiles::FanCurvePU;
use log::error;
use supergfxctl::pci_device::{GfxMode, GfxPower};
#[cfg(not(feature = "mocking"))]
use supergfxctl::zbus_proxy::DaemonProxyBlocking as GfxProxyBlocking;
use supergfxctl::zbus_proxy::DaemonProxy as GfxProxy;
use zbus::Connection;
use crate::error::Result;
#[cfg(feature = "mocking")]
use crate::mocking::DaemonProxyBlocking as GfxProxyBlocking;
use crate::update_and_notify::EnabledNotifications;
use crate::{RogDbusClientBlocking, BOARD_NAME, DATA_DIR};
#[derive(Clone, Debug, Default)]
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: 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<ThrottlePolicy>,
pub charge_limit: Option<u8>,
}
impl PlatformState {
pub fn new(dbus: &RogDbusClientBlocking<'_>) -> Result<Self> {
Ok(Self {
post_sound: dbus.proxies().platform().boot_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: 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: ThrottlePolicy,
pub show_graph: FanCurvePU,
pub curves: BTreeMap<ThrottlePolicy, Vec<CurveData>>,
pub available_fans: HashSet<FanCurvePU>,
// pub drag_delta: Vec2,
}
impl FanCurvesState {
pub fn new(dbus: &RogDbusClientBlocking<'_>) -> Result<Self> {
let profiles = vec![
ThrottlePolicy::Balanced,
ThrottlePolicy::Quiet,
ThrottlePolicy::Performance,
];
let mut available_fans = HashSet::new();
let mut curves: BTreeMap<ThrottlePolicy, Vec<CurveData>> = BTreeMap::new();
for p in &profiles {
if let Ok(curve) = dbus.proxies().fan_curves().fan_curve_data(*p) {
if available_fans.is_empty() {
for fan in &curve {
available_fans.insert(fan.fan);
}
}
curves.insert(*p, curve);
} else {
curves.insert(*p, Default::default());
}
}
let show_curve = dbus.proxies().platform().throttle_thermal_policy()?;
Ok(Self {
show_curve,
show_graph: FanCurvePU::CPU,
curves,
available_fans,
// drag_delta: Vec2::default(),
})
}
}
#[derive(Clone, Debug, Default)]
pub struct AuraState {
pub current_mode: AuraModeNum,
pub modes: BTreeMap<AuraModeNum, AuraEffect>,
pub enabled: AuraPowerDev,
/// Brightness from 0-3
pub bright: LedBrightness,
pub wave_red: [u8; 22],
pub wave_green: [u8; 22],
pub wave_blue: [u8; 22],
}
impl AuraState {
pub fn new(layout: &KeyLayout, dbus: &RogDbusClientBlocking<'_>) -> Result<Self> {
Ok(Self {
current_mode: if !layout.basic_modes().is_empty() {
dbus.proxies().aura().led_mode().unwrap_or_default()
} else {
AuraModeNum::Static
},
modes: if !layout.basic_modes().is_empty() {
dbus.proxies().aura().all_mode_data().unwrap_or_default()
} else {
BTreeMap::new()
},
enabled: dbus.proxies().aura().led_power().unwrap_or_default(),
bright: Default::default(),
wave_red: [0u8; 22],
wave_green: [0u8; 22],
wave_blue: [0u8; 22],
})
}
/// Bump value in to the wave and surf all along.
pub fn nudge_wave(&mut self, r: u8, g: u8, b: u8) {
for i in (0..self.wave_red.len()).rev() {
if i > 0 {
self.wave_red[i] = self.wave_red[i - 1];
self.wave_green[i] = self.wave_green[i - 1];
self.wave_blue[i] = self.wave_blue[i - 1];
}
}
self.wave_red[0] = r;
self.wave_green[0] = g;
self.wave_blue[0] = b;
}
}
#[derive(Clone, Debug, Default)]
pub struct AnimeState {
pub display_enabled: bool,
pub display_brightness: u8,
pub builtin_anims_enabled: bool,
pub builtin_anims: Animations,
}
impl AnimeState {
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,
})
}
}
impl From<DeviceState> for AnimeState {
fn from(dev: DeviceState) -> Self {
Self {
display_enabled: dev.display_enabled,
display_brightness: dev.display_brightness as u8,
builtin_anims_enabled: dev.builtin_anims_enabled,
builtin_anims: dev.builtin_anims,
}
}
}
#[derive(Clone, Debug)]
pub struct GfxState {
@@ -194,11 +19,11 @@ pub struct GfxState {
}
impl GfxState {
pub fn new(dbus: &GfxProxyBlocking<'_>) -> Result<Self> {
pub async fn new(dbus: &GfxProxy<'_>) -> Result<Self> {
Ok(Self {
has_supergfx: dbus.mode().is_ok(),
mode: dbus.mode().unwrap_or(GfxMode::None),
power_status: dbus.power().unwrap_or(GfxPower::Unknown),
has_supergfx: dbus.mode().await.is_ok(),
mode: dbus.mode().await.unwrap_or(GfxMode::None),
power_status: dbus.power().await.unwrap_or(GfxPower::Unknown),
})
}
}
@@ -213,115 +38,16 @@ impl Default for GfxState {
}
}
/// The keyboard layout, used for such things as per-key and zones
#[derive(Clone, Debug)]
pub struct AuraCreation {
/// Specifically for testing the development of keyboard layouts (combined
/// with `--layout-name` CLI option)
pub layout_testing: Option<PathBuf>,
pub layout_last_modified: SystemTime,
pub keyboard_layout: KeyLayout,
pub keyboard_layouts: Vec<PathBuf>,
/// current index in to `self.keyboard_layouts`
pub keyboard_layout_index: usize,
}
impl AuraCreation {
pub fn new(test_name: Option<String>, view_layout: bool) -> Result<Self> {
let mut led_support = LaptopLedData::get_data();
let mut path = PathBuf::from(DATA_DIR);
let mut layout_testing = None;
let mut keyboard_layouts = Vec::new();
// Find and load a matching layout for laptop
let mut board_name = std::fs::read_to_string(BOARD_NAME).map_err(|e| {
println!("DOH! {BOARD_NAME}, {e}");
e
})?;
if test_name.is_some() || view_layout {
if cfg!(feature = "mocking") {
path.pop();
path.push("rog-aura");
path.push("data");
}
keyboard_layouts = KeyLayout::layout_files(path.clone()).unwrap();
if let Some(name) = test_name {
if let Some(modes) = LedSupportFile::load_from_supoprt_db() {
if let Some(data) = modes.matcher(&name) {
led_support = data;
}
}
board_name = name;
for layout in &keyboard_layouts {
if layout
.file_name()
.unwrap()
.to_string_lossy()
.contains(&led_support.layout_name.to_lowercase())
{
layout_testing = Some(layout.clone());
}
}
} else {
board_name = "GQ401QM".to_owned();
};
if view_layout {
layout_testing = Some(keyboard_layouts[0].clone());
board_name = keyboard_layouts[0]
.file_name()
.unwrap()
.to_string_lossy()
.split_once('_')
.unwrap()
.0
.to_owned();
led_support.layout_name = board_name.clone();
}
}
let keyboard_layout = KeyLayout::find_layout(led_support, path)
.map_err(|e| {
println!("DERP! , {e}");
})
.unwrap_or_else(|_| {
warn!("Did not find a keyboard layout matching {board_name}");
KeyLayout::default_layout()
});
Ok(Self {
layout_testing,
layout_last_modified: SystemTime::now(),
keyboard_layout,
keyboard_layouts,
keyboard_layout_index: 0,
})
}
}
/// State stored from system daemons. This is shared with: tray, zbus
/// notifications thread and the GUI app thread.
pub struct SystemState {
pub aura_creation: AuraCreation,
//--
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: PlatformState,
pub aura: AuraState,
pub anime: AnimeState,
pub fan_curves: FanCurvesState,
pub gfx_state: GfxState,
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>,
pub tray_enabled: bool,
pub run_in_bg: bool,
}
@@ -329,47 +55,22 @@ pub struct SystemState {
impl SystemState {
/// Creates self, including the relevant dbus connections and proixies for
/// internal use
pub fn new(
aura_creation: AuraCreation,
pub async fn new(
enabled_notifications: Arc<Mutex<EnabledNotifications>>,
tray_enabled: bool,
run_in_bg: bool,
) -> Result<Self> {
let (asus_dbus, conn) = RogDbusClientBlocking::new()?;
let aura = AuraState::new(&aura_creation.keyboard_layout, &asus_dbus)
.map_err(|e| {
let e = format!("Could not get AuraState state: {e}");
error!("{e}");
})
.unwrap_or_default();
let conn = Connection::system().await?;
let gfx_dbus = GfxProxyBlocking::builder(&conn)
let gfx_dbus = GfxProxy::builder(&conn)
.destination(":org.supergfxctl.Daemon")?
.build()
.await
.expect("Couldn't connect to supergfxd");
Ok(Self {
aura_creation,
enabled_notifications,
bios: PlatformState::new(&asus_dbus)
.map_err(|e| {
let e = format!("Could not get BiosState state: {e}");
error!("{e}");
})
.unwrap_or_default(),
aura,
anime: AnimeState::new(&asus_dbus)
.map_err(|e| {
let e = format!("Could not get AnimeState state: {e}");
error!("{e}");
})
.unwrap_or_default(),
fan_curves: FanCurvesState::new(&asus_dbus)
.map_err(|e| {
let e = format!("Could not get FanCurvesState state: {e}");
error!("{e}");
})
.unwrap_or_default(),
gfx_state: GfxState::new(&gfx_dbus)
.await
.map_err(|e| {
let e = format!("Could not get supergfxd state: {e}");
error!("{e}");
@@ -378,8 +79,6 @@ impl SystemState {
error: None,
tray_should_update: true,
app_should_update: true,
asus_dbus,
gfx_dbus,
tray_enabled,
run_in_bg,
})
@@ -390,51 +89,3 @@ impl SystemState {
self.app_should_update = true;
}
}
impl Default for SystemState {
fn default() -> Self {
let (asus_dbus, conn) = RogDbusClientBlocking::new().expect("Couldn't connect to asusd");
let gfx_dbus = GfxProxyBlocking::builder(&conn)
.build()
.expect("Couldn't connect to supergfxd");
Self {
aura_creation: AuraCreation {
layout_testing: None,
layout_last_modified: SystemTime::now(),
keyboard_layout: KeyLayout::default_layout(),
keyboard_layouts: Default::default(),
keyboard_layout_index: 0,
},
enabled_notifications: Default::default(),
bios: PlatformState {
post_sound: Default::default(),
gpu_mux_mode: None,
charge_limit: Some(100),
..Default::default()
},
aura: AuraState {
current_mode: AuraModeNum::Static,
modes: Default::default(),
enabled: AuraPowerDev::default(),
..Default::default()
},
anime: AnimeState::default(),
fan_curves: FanCurvesState {
..Default::default()
},
gfx_state: GfxState {
has_supergfx: false,
mode: GfxMode::None,
power_status: GfxPower::Unknown,
},
error: Default::default(),
tray_should_update: true,
app_should_update: true,
asus_dbus,
gfx_dbus,
tray_enabled: true,
run_in_bg: true,
}
}
}

View File

@@ -11,7 +11,7 @@ use std::time::Duration;
use betrayer::{Icon, Menu, MenuItem, TrayEvent, TrayIcon, TrayIconBuilder};
use log::{debug, error, info, warn};
use rog_platform::platform::{GpuMode, Properties};
use rog_platform::platform::Properties;
use supergfxctl::pci_device::{GfxMode, GfxPower};
use supergfxctl::zbus_proxy::DaemonProxyBlocking as GfxProxy;
use versions::Versioning;
@@ -113,16 +113,7 @@ fn set_tray_icon_and_tip(lock: &SystemState, tray: &TrayIcon<TrayAction>, superg
}
};
let current_gpu_mode = if supergfx_active {
lock.gfx_state.mode
} else if let Some(mode) = lock.bios.gpu_mux_mode {
match mode {
GpuMode::Discrete => GfxMode::AsusMuxDgpu,
_ => GfxMode::Hybrid,
}
} else {
GfxMode::Hybrid
};
let current_gpu_mode = lock.gfx_state.mode;
tray.set_tooltip(format!(
"ROG: gpu mode = {current_gpu_mode:?}, gpu power = {gpu_status:?}"
@@ -137,59 +128,61 @@ pub fn init_tray(
config: Arc<Mutex<Config>>,
) {
std::thread::spawn(move || {
debug!("init_tray");
let rog_blue = read_icon(&PathBuf::from("asus_notif_blue.png"));
let rog_red = read_icon(&PathBuf::from("asus_notif_red.png"));
let rog_green = read_icon(&PathBuf::from("asus_notif_green.png"));
let rog_white = read_icon(&PathBuf::from("asus_notif_white.png"));
let gpu_integrated = read_icon(&PathBuf::from("rog-control-center.png"));
ICONS.get_or_init(|| Icons {
rog_blue,
rog_red: rog_red.clone(),
rog_green,
rog_white,
gpu_integrated,
});
let conn = zbus::blocking::Connection::system().unwrap();
let gfx_proxy = GfxProxy::new(&conn).unwrap();
let mut supergfx_active = false;
if gfx_proxy.mode().is_ok() {
supergfx_active = true;
if let Ok(version) = gfx_proxy.version() {
if let Some(version) = Versioning::new(&version) {
let curr_gfx = Versioning::new("5.0.3-RC4").unwrap();
warn!("supergfxd version = {version}");
if version < curr_gfx {
// Don't allow mode changing if too old a version
warn!("supergfxd found but is too old to use");
// tray.gfx_proxy_is_active = false;
}
}
}
};
let tray = TrayIconBuilder::<TrayAction>::new()
if let Ok(tray) = TrayIconBuilder::<TrayAction>::new()
.with_icon(rog_red.clone())
.with_tooltip(TRAY_LABEL)
.with_menu(build_menu())
.build(do_action)
.unwrap();
info!("Started ROGTray");
loop {
// let states = states.clone();
if let Ok(mut lock) = states.lock() {
if lock.tray_should_update {
set_tray_icon_and_tip(&lock, &tray, supergfx_active);
lock.tray_should_update = false;
if let Ok(lock) = config.try_lock() {
if !lock.enable_tray_icon {
return;
.map_err(|e| log::error!("Tray unable to be initialised: {e:?}"))
{
info!("Tray started");
let rog_blue = read_icon(&PathBuf::from("asus_notif_blue.png"));
let rog_green = read_icon(&PathBuf::from("asus_notif_green.png"));
let rog_white = read_icon(&PathBuf::from("asus_notif_white.png"));
let gpu_integrated = read_icon(&PathBuf::from("rog-control-center.png"));
ICONS.get_or_init(|| Icons {
rog_blue,
rog_red: rog_red.clone(),
rog_green,
rog_white,
gpu_integrated,
});
let conn = zbus::blocking::Connection::system().unwrap();
let gfx_proxy = GfxProxy::new(&conn).unwrap();
let mut supergfx_active = false;
if gfx_proxy.mode().is_ok() {
supergfx_active = true;
if let Ok(version) = gfx_proxy.version() {
if let Some(version) = Versioning::new(&version) {
let curr_gfx = Versioning::new("5.0.3-RC4").unwrap();
warn!("supergfxd version = {version}");
if version < curr_gfx {
// Don't allow mode changing if too old a version
warn!("supergfxd found but is too old to use");
// tray.gfx_proxy_is_active = false;
}
}
}
};
info!("Started ROGTray");
loop {
if let Ok(mut lock) = states.lock() {
if lock.tray_should_update {
set_tray_icon_and_tip(&lock, &tray, supergfx_active);
lock.tray_should_update = false;
if let Ok(lock) = config.try_lock() {
if !lock.enable_tray_icon {
return;
}
}
}
}
sleep(Duration::from_millis(50));
}
sleep(Duration::from_millis(50));
}
});
}

View File

@@ -1,3 +1,7 @@
use crate::slint_generatedMainWindow::{
AuraPowerState as SlintAuraPowerState, LaptopAuraPower as SlintLaptopAuraPower,
};
impl From<rog_aura::AuraEffect> for crate::slint_generatedMainWindow::AuraEffect {
fn from(m: rog_aura::AuraEffect) -> Self {
Self {
@@ -46,66 +50,20 @@ impl From<crate::slint_generatedMainWindow::AuraEffect> for rog_aura::AuraEffect
}
}
use rog_aura::power::KbAuraPowerState;
use rog_aura::aura_detection::PowerZones;
use rog_aura::keyboard::{AuraPowerState, LaptopAuraPower};
use slint::{Model, ModelRc, RgbaColor};
use crate::slint_generatedMainWindow::AuraDevTuf as SlintAuraDevTuf;
impl From<rog_aura::usb::AuraDevTuf> for SlintAuraDevTuf {
fn from(value: rog_aura::usb::AuraDevTuf) -> Self {
match value {
rog_aura::usb::AuraDevTuf::Boot => SlintAuraDevTuf::Boot,
rog_aura::usb::AuraDevTuf::Awake => SlintAuraDevTuf::Awake,
rog_aura::usb::AuraDevTuf::Sleep => SlintAuraDevTuf::Sleep,
rog_aura::usb::AuraDevTuf::Keyboard => SlintAuraDevTuf::Keyboard,
}
}
}
impl From<SlintAuraDevTuf> for rog_aura::usb::AuraDevTuf {
fn from(value: SlintAuraDevTuf) -> Self {
match value {
SlintAuraDevTuf::Boot => rog_aura::usb::AuraDevTuf::Boot,
SlintAuraDevTuf::Awake => rog_aura::usb::AuraDevTuf::Awake,
SlintAuraDevTuf::Sleep => rog_aura::usb::AuraDevTuf::Sleep,
SlintAuraDevTuf::Keyboard => rog_aura::usb::AuraDevTuf::Keyboard,
}
}
}
use crate::slint_generatedMainWindow::AuraDevRog1 as SlintAuraDevRog1;
impl From<rog_aura::usb::AuraDevRog1> for SlintAuraDevRog1 {
fn from(value: rog_aura::usb::AuraDevRog1) -> Self {
match value {
rog_aura::usb::AuraDevRog1::Awake => SlintAuraDevRog1::Awake,
rog_aura::usb::AuraDevRog1::Keyboard => SlintAuraDevRog1::Keyboard,
rog_aura::usb::AuraDevRog1::Lightbar => SlintAuraDevRog1::Lightbar,
rog_aura::usb::AuraDevRog1::Boot => SlintAuraDevRog1::Boot,
rog_aura::usb::AuraDevRog1::Sleep => SlintAuraDevRog1::Sleep,
}
}
}
impl From<SlintAuraDevRog1> for rog_aura::usb::AuraDevRog1 {
fn from(value: SlintAuraDevRog1) -> Self {
match value {
SlintAuraDevRog1::Awake => rog_aura::usb::AuraDevRog1::Awake,
SlintAuraDevRog1::Keyboard => rog_aura::usb::AuraDevRog1::Keyboard,
SlintAuraDevRog1::Lightbar => rog_aura::usb::AuraDevRog1::Lightbar,
SlintAuraDevRog1::Boot => rog_aura::usb::AuraDevRog1::Boot,
SlintAuraDevRog1::Sleep => rog_aura::usb::AuraDevRog1::Sleep,
}
}
}
use crate::slint_generatedMainWindow::PowerZones as SlintPowerZones;
impl From<rog_aura::aura_detection::PowerZones> for SlintPowerZones {
fn from(value: rog_aura::aura_detection::PowerZones) -> Self {
match value {
rog_aura::aura_detection::PowerZones::Logo => SlintPowerZones::Logo,
rog_aura::aura_detection::PowerZones::Keyboard => SlintPowerZones::Keyboard,
rog_aura::aura_detection::PowerZones::Lightbar => SlintPowerZones::Lightbar,
rog_aura::aura_detection::PowerZones::Lid => SlintPowerZones::Lid,
rog_aura::aura_detection::PowerZones::RearGlow => SlintPowerZones::RearGlow,
PowerZones::Logo => SlintPowerZones::Logo,
PowerZones::Keyboard => SlintPowerZones::Keyboard,
PowerZones::Lightbar => SlintPowerZones::Lightbar,
PowerZones::Lid => SlintPowerZones::Lid,
PowerZones::RearGlow => SlintPowerZones::RearGlow,
PowerZones::KeyboardAndLightbar => todo!(),
}
}
}
@@ -118,134 +76,72 @@ impl From<SlintPowerZones> for rog_aura::aura_detection::PowerZones {
SlintPowerZones::Lightbar => rog_aura::aura_detection::PowerZones::Lightbar,
SlintPowerZones::Lid => rog_aura::aura_detection::PowerZones::Lid,
SlintPowerZones::RearGlow => rog_aura::aura_detection::PowerZones::RearGlow,
SlintPowerZones::KeyboardAndLightbar => {
rog_aura::aura_detection::PowerZones::KeyboardAndLightbar
}
}
}
}
use crate::slint_generatedMainWindow::{
AuraPower as SlintAuraPower, KbAuraPowerState as SlintKbAuraPowerState,
};
impl From<rog_aura::power::AuraPower> for SlintAuraPower {
fn from(value: rog_aura::power::AuraPower) -> Self {
impl From<SlintAuraPowerState> for AuraPowerState {
fn from(value: SlintAuraPowerState) -> Self {
Self {
keyboard: SlintKbAuraPowerState {
awake: value.keyboard.awake,
boot: value.keyboard.boot,
shutdown: value.keyboard.shutdown,
sleep: value.keyboard.sleep,
zone: value.keyboard.zone.into(),
},
lid: SlintKbAuraPowerState {
awake: value.lid.awake,
boot: value.lid.boot,
shutdown: value.lid.shutdown,
sleep: value.lid.sleep,
zone: value.lid.zone.into(),
},
lightbar: SlintKbAuraPowerState {
awake: value.lightbar.awake,
boot: value.lightbar.boot,
shutdown: value.lightbar.shutdown,
sleep: value.lightbar.sleep,
zone: value.lightbar.zone.into(),
},
logo: SlintKbAuraPowerState {
awake: value.logo.awake,
boot: value.logo.boot,
shutdown: value.logo.shutdown,
sleep: value.logo.sleep,
zone: value.logo.zone.into(),
},
rear_glow: SlintKbAuraPowerState {
awake: value.rear_glow.awake,
boot: value.rear_glow.boot,
shutdown: value.rear_glow.shutdown,
sleep: value.rear_glow.sleep,
zone: value.rear_glow.zone.into(),
},
zone: value.zone.into(),
boot: value.boot.into(),
awake: value.awake.into(),
sleep: value.sleep.into(),
shutdown: value.shutdown.into(),
}
}
}
impl From<SlintAuraPower> for rog_aura::power::AuraPower {
fn from(value: SlintAuraPower) -> Self {
Self {
keyboard: KbAuraPowerState {
awake: value.keyboard.awake,
boot: value.keyboard.boot,
shutdown: value.keyboard.shutdown,
sleep: value.keyboard.sleep,
zone: value.keyboard.zone.into(),
},
lid: KbAuraPowerState {
awake: value.lid.awake,
boot: value.lid.boot,
shutdown: value.lid.shutdown,
sleep: value.lid.sleep,
zone: value.lid.zone.into(),
},
lightbar: KbAuraPowerState {
awake: value.lightbar.awake,
boot: value.lightbar.boot,
shutdown: value.lightbar.shutdown,
sleep: value.lightbar.sleep,
zone: value.lightbar.zone.into(),
},
logo: KbAuraPowerState {
awake: value.logo.awake,
boot: value.logo.boot,
shutdown: value.logo.shutdown,
sleep: value.logo.sleep,
zone: value.logo.zone.into(),
},
rear_glow: KbAuraPowerState {
awake: value.rear_glow.awake,
boot: value.rear_glow.boot,
shutdown: value.rear_glow.shutdown,
sleep: value.rear_glow.sleep,
zone: value.rear_glow.zone.into(),
},
impl From<AuraPowerState> for SlintAuraPowerState {
fn from(value: AuraPowerState) -> Self {
let zone = value.zone.into();
SlintAuraPowerState {
boot: value.boot.into(),
awake: value.awake.into(),
sleep: value.sleep.into(),
shutdown: value.shutdown.into(),
zone,
zone_name_idx: zone as i32,
}
}
}
use crate::slint_generatedMainWindow::AuraPowerDev as SlintAuraPowerDev;
impl From<rog_aura::usb::AuraPowerDev> for SlintAuraPowerDev {
fn from(value: rog_aura::usb::AuraPowerDev) -> Self {
let tuf: Vec<SlintAuraDevTuf> = value
.tuf
.iter()
.map(|n| SlintAuraDevTuf::from(*n))
.collect();
let old_rog: Vec<SlintAuraDevRog1> = value
.old_rog
.iter()
.map(|n| SlintAuraDevRog1::from(*n))
.collect();
Self {
tuf: ModelRc::from(tuf.as_slice()),
old_rog: ModelRc::from(old_rog.as_slice()),
rog: value.rog.into(),
impl From<&AuraPowerState> for SlintAuraPowerState {
fn from(value: &AuraPowerState) -> Self {
let zone = value.zone.into();
SlintAuraPowerState {
boot: value.boot.into(),
awake: value.awake.into(),
sleep: value.sleep.into(),
shutdown: value.shutdown.into(),
zone,
zone_name_idx: zone as i32,
}
}
}
impl From<SlintAuraPowerDev> for rog_aura::usb::AuraPowerDev {
fn from(value: SlintAuraPowerDev) -> Self {
let tuf: Vec<rog_aura::usb::AuraDevTuf> = value
.tuf
impl From<SlintLaptopAuraPower> for rog_aura::keyboard::LaptopAuraPower {
fn from(value: SlintLaptopAuraPower) -> Self {
let mut states = Vec::new();
for state in value.states.iter() {
states.push(state.into());
}
Self { states }
}
}
impl From<LaptopAuraPower> for SlintLaptopAuraPower {
fn from(value: LaptopAuraPower) -> Self {
let converted: Vec<SlintAuraPowerState> = value
.states
.iter()
.map(rog_aura::usb::AuraDevTuf::from)
.collect();
let old_rog: Vec<rog_aura::usb::AuraDevRog1> = value
.old_rog
.iter()
.map(rog_aura::usb::AuraDevRog1::from)
.map(|s| SlintAuraPowerState::from(s))
.collect();
Self {
tuf,
old_rog,
rog: value.rog.into(),
states: ModelRc::from(converted.as_slice()),
}
}
}

View File

@@ -1,6 +1,6 @@
use std::sync::{Arc, Mutex};
use rog_aura::usb::AuraPowerDev;
use rog_aura::keyboard::LaptopAuraPower;
use rog_dbus::zbus_aura::AuraProxy;
use slint::{ComponentHandle, Model, RgbaColor, SharedString};
@@ -166,11 +166,11 @@ pub fn setup_aura_page(ui: &MainWindow, _states: Arc<Mutex<Config>>) {
.on_set_led_power(move |power| {
let handle_copy = handle_copy.clone();
let proxy_copy = aura.clone();
let power: AuraPowerDev = power.into();
let power: LaptopAuraPower = power.into();
tokio::spawn(async move {
show_toast(
"Anime builtin animations changed".into(),
"Failed to set Anime builtin animations".into(),
"Aura power settings changed".into(),
"Failed to set Aura power settings".into(),
handle_copy,
proxy_copy.set_led_power(power).await,
);

View File

@@ -11,10 +11,8 @@ 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_aura::AuraProxy;
use rog_dbus::zbus_platform::PlatformProxy;
use rog_platform::platform::{GpuMode, ThrottlePolicy};
use rog_platform::platform::GpuMode;
use serde::{Deserialize, Serialize};
use supergfxctl::actions::UserActionRequired as GfxUserAction;
use supergfxctl::pci_device::{GfxMode, GfxPower};
@@ -31,45 +29,12 @@ const NOTIF_HEADER: &str = "ROG Control";
static mut POWER_AC_CMD: Option<Command> = None;
static mut POWER_BAT_CMD: Option<Command> = None;
#[derive(Debug, Clone, Deserialize, Serialize)]
#[derive(Debug, Default, Clone, Deserialize, Serialize)]
#[serde(default)]
pub struct EnabledNotifications {
pub receive_boot_sound_changed: bool,
pub receive_panel_od_changed: bool,
pub receive_mini_led_mode_changed: bool,
pub receive_dgpu_disable_changed: bool,
pub receive_egpu_enable_changed: bool,
pub receive_gpu_mux_mode_changed: bool,
pub receive_charge_control_end_threshold_changed: bool,
pub receive_notify_mains_online: 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,
pub receive_notify_gfx_status: bool,
pub all_enabled: bool,
}
impl Default for EnabledNotifications {
fn default() -> Self {
Self {
receive_boot_sound_changed: false,
receive_panel_od_changed: true,
receive_mini_led_mode_changed: true,
receive_dgpu_disable_changed: true,
receive_egpu_enable_changed: true,
receive_gpu_mux_mode_changed: true,
receive_charge_control_end_threshold_changed: true,
receive_notify_mains_online: false,
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,
all_enabled: false,
}
}
}
impl EnabledNotifications {
@@ -78,6 +43,18 @@ impl EnabledNotifications {
}
}
fn gpu_to_gfx(value: GpuMode) -> GfxMode {
match value {
GpuMode::Optimus => GfxMode::Hybrid,
GpuMode::Integrated => GfxMode::Integrated,
GpuMode::Egpu => GfxMode::AsusEgpu,
GpuMode::Vfio => GfxMode::Vfio,
GpuMode::Ultimate => GfxMode::AsusMuxDgpu,
GpuMode::Error => GfxMode::None,
GpuMode::NotSupported => GfxMode::None,
}
}
// TODO: drop the macro and use generics plus closure
macro_rules! recv_notif {
($proxy:ident,
@@ -107,7 +84,7 @@ macro_rules! recv_notif {
while let Some(e) = p.next().await {
if let Ok(out) = e.args() {
if let Ok(config) = notifs_enabled1.lock() {
if config.all_enabled && config.$signal {
if config.$signal {
trace!("zbus signal {}", stringify!($signal));
$notifier($msg, &out.$($out_arg)+()).ok();
}
@@ -124,49 +101,6 @@ macro_rules! recv_notif {
};
}
macro_rules! recv_changed {
($proxy:ident,
$signal:ident,
$last_notif:ident,
$notif_enabled:ident,
$page_states:ident,
($($args: tt)*),
// ($($out_arg:tt)+),
$msg:literal,
$notifier:ident) => {
let notifs_enabled1 = $notif_enabled.clone();
let page_states1 = $page_states.clone();
tokio::spawn(async move {
let conn = zbus::Connection::system().await.map_err(|e| {
log::error!("zbus signal: {}: {e}", stringify!($signal));
e
}).unwrap();
let proxy = $proxy::new(&conn).await.map_err(|e| {
log::error!("zbus signal: {}: {e}", stringify!($signal));
e
}).unwrap();
info!("Started zbus signal thread: {}", stringify!($signal));
while let Some(e) = proxy.$signal().await.next().await {
if let Ok(out) = e.get().await {
if let Ok(config) = notifs_enabled1.lock() {
if config.all_enabled && config.$signal {
trace!("zbus signal {}", stringify!($signal));
$notifier($msg, &out).ok();
}
}
if let Ok(mut lock) = page_states1.lock() {
lock.$($args)+ = out.into();
lock.set_notified();
}
}
sleep(Duration::from_millis(500)).await;
}
});
};
}
pub fn start_notifications(
config: &Config,
page_states: &Arc<Mutex<SystemState>>,
@@ -196,155 +130,6 @@ pub fn start_notifications(
}
}
// BIOS notif
recv_changed!(
PlatformProxy,
receive_boot_sound_changed,
last_notification,
enabled_notifications,
page_states,
(bios.post_sound),
"BIOS Post sound",
do_notification
);
recv_changed!(
PlatformProxy,
receive_panel_od_changed,
last_notification,
enabled_notifications,
page_states,
(bios.panel_overdrive),
"Panel Overdrive enabled:",
do_notification
);
recv_changed!(
PlatformProxy,
receive_mini_led_mode_changed,
last_notification,
enabled_notifications,
page_states,
(bios.mini_led_mode),
"MiniLED mode enabled:",
do_notification
);
recv_changed!(
PlatformProxy,
receive_dgpu_disable_changed,
last_notification,
enabled_notifications,
page_states,
(bios.dgpu_disable),
"BIOS dGPU disabled",
do_notification
);
recv_changed!(
PlatformProxy,
receive_egpu_enable_changed,
last_notification,
enabled_notifications,
page_states,
(bios.egpu_enable),
"BIOS eGPU enabled",
do_notification
);
// Charge notif
recv_changed!(
PlatformProxy,
receive_charge_control_end_threshold_changed,
last_notification,
enabled_notifications,
page_states,
(bios.charge_limit),
"Battery charge limit changed to",
do_notification
);
// Profile notif
recv_changed!(
PlatformProxy,
receive_throttle_thermal_policy_changed,
last_notification,
enabled_notifications,
page_states,
(bios.throttle),
"Profile changed to",
do_thermal_notif
);
// notify!(do_thermal_notif(&out.profile), lock);
// LED notif
recv_changed!(
AuraProxy,
receive_led_mode_data_changed,
last_notification,
enabled_notifications,
page_states,
(aura.current_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 = 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 {
let conn = zbus::Connection::system()
.await
.map_err(|e| {
error!("zbus signal: receive_device_state: {e}");
e
})
.unwrap();
let proxy = AnimeProxy::new(&conn)
.await
.map_err(|e| {
error!("zbus signal: receive_device_state: {e}");
e
})
.unwrap();
if let Ok(mut p) = proxy.receive_notify_device_state().await {
info!("Started zbus signal thread: receive_device_state");
while let Some(e) = p.next().await {
if let Ok(out) = e.args() {
if let Ok(mut lock) = page_states1.lock() {
lock.anime = out.data.into();
}
}
}
};
});
let page_states1 = page_states.clone();
tokio::spawn(async move {
let conn = zbus::Connection::system()
@@ -375,7 +160,7 @@ pub fn start_notifications(
continue;
}
if let Ok(mut lock) = page_states1.lock() {
lock.bios.gpu_mux_mode = Some(mode);
lock.gfx_state.mode = gpu_to_gfx(mode);
lock.set_notified();
}
do_mux_notification("Reboot required. BIOS GPU MUX mode set to", &mode).ok();
@@ -397,7 +182,7 @@ pub fn start_notifications(
if let Ok(status) = dev.get_runtime_status() {
if status != GfxPower::Unknown && status != last_status {
if let Ok(config) = notifs_enabled1.lock() {
if config.all_enabled && config.receive_notify_gfx_status {
if config.receive_notify_gfx_status {
// Required check because status cycles through
// active/unknown/suspended
do_gpu_status_notif("dGPU status changed:", &status).ok();
@@ -498,7 +283,7 @@ fn convert_gfx_mode(gfx: GfxMode) -> GpuMode {
match gfx {
GfxMode::Hybrid => GpuMode::Optimus,
GfxMode::Integrated => GpuMode::Integrated,
GfxMode::NvidiaNoModeset => GpuMode::Discrete,
GfxMode::NvidiaNoModeset => GpuMode::Optimus,
GfxMode::Vfio => GpuMode::Vfio,
GfxMode::AsusEgpu => GpuMode::Egpu,
GfxMode::AsusMuxDgpu => GpuMode::Ultimate,
@@ -553,17 +338,6 @@ fn _ac_power_notification(message: &str, on: &bool) -> Result<NotificationHandle
Ok(base_notification(message, &data).show()?)
}
fn do_thermal_notif(message: &str, profile: &ThrottlePolicy) -> Result<NotificationHandle> {
let icon = match profile {
ThrottlePolicy::Balanced => "asus_notif_yellow",
ThrottlePolicy::Performance => "asus_notif_red",
ThrottlePolicy::Quiet => "asus_notif_green",
};
let profile: &str = (*profile).into();
let mut notif = base_notification(message, &profile.to_uppercase());
Ok(notif.icon(icon).show()?)
}
fn do_gpu_status_notif(message: &str, data: &GfxPower) -> Result<NotificationHandle> {
// eww
let mut notif = base_notification(message, &<&str>::from(data).to_owned());

View File

@@ -2,7 +2,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2024-03-23 01:29+0000\n"
"POT-Creation-Date: 2024-04-09 09:23+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -237,51 +237,6 @@ msgctxt "PageAura"
msgid "Power Settings"
msgstr ""
#: rog-control-center/ui/pages/aura.slint:211 rog-control-center/ui/pages/aura.slint:369 rog-control-center/ui/pages/aura.slint:434
msgctxt "PageAura"
msgid "Keyboard"
msgstr ""
#: rog-control-center/ui/pages/aura.slint:235
msgctxt "PageAura"
msgid "Lid Logo"
msgstr ""
#: rog-control-center/ui/pages/aura.slint:259
msgctxt "PageAura"
msgid "Lightbar"
msgstr ""
#: rog-control-center/ui/pages/aura.slint:283
msgctxt "PageAura"
msgid "Lid Zone"
msgstr ""
#: rog-control-center/ui/pages/aura.slint:307
msgctxt "PageAura"
msgid "Rear Glow"
msgstr ""
#: rog-control-center/ui/pages/aura.slint:375 rog-control-center/ui/pages/aura.slint:440
msgctxt "PageAura"
msgid "Boot"
msgstr ""
#: rog-control-center/ui/pages/aura.slint:380 rog-control-center/ui/pages/aura.slint:445
msgctxt "PageAura"
msgid "Awake"
msgstr ""
#: rog-control-center/ui/pages/aura.slint:385 rog-control-center/ui/pages/aura.slint:450
msgctxt "PageAura"
msgid "Sleep"
msgstr ""
#: rog-control-center/ui/pages/aura.slint:390 rog-control-center/ui/pages/aura.slint:455
msgctxt "PageAura"
msgid "Shutdown"
msgstr ""
#: rog-control-center/ui/pages/fans.slint:27
msgctxt "FanTab"
msgid "This fan is not avilable on this machine"
@@ -487,162 +442,192 @@ msgctxt "PageSystem"
msgid "Throttle Policy on AC"
msgstr ""
#: rog-control-center/ui/types/aura_types.slint:69
#: rog-control-center/ui/types/aura_types.slint:46
msgctxt "Aura power zone"
msgid "Logo"
msgstr ""
#: rog-control-center/ui/types/aura_types.slint:47
msgctxt "Aura power zone"
msgid "Keyboard"
msgstr ""
#: rog-control-center/ui/types/aura_types.slint:48
msgctxt "Aura power zone"
msgid "Lightbar"
msgstr ""
#: rog-control-center/ui/types/aura_types.slint:49
msgctxt "Aura power zone"
msgid "Lid"
msgstr ""
#: rog-control-center/ui/types/aura_types.slint:50
msgctxt "Aura power zone"
msgid "Rear Glow"
msgstr ""
#: rog-control-center/ui/types/aura_types.slint:51
msgctxt "Aura power zone"
msgid "Keyboard and Lightbar"
msgstr ""
#: rog-control-center/ui/types/aura_types.slint:54
msgctxt "Aura brightness"
msgid "Off"
msgstr ""
#: rog-control-center/ui/types/aura_types.slint:70
#: rog-control-center/ui/types/aura_types.slint:55
msgctxt "Aura brightness"
msgid "Low"
msgstr ""
#: rog-control-center/ui/types/aura_types.slint:71
#: rog-control-center/ui/types/aura_types.slint:56
msgctxt "Aura brightness"
msgid "Med"
msgstr ""
#: rog-control-center/ui/types/aura_types.slint:72
#: rog-control-center/ui/types/aura_types.slint:57
msgctxt "Aura brightness"
msgid "High"
msgstr ""
#: rog-control-center/ui/types/aura_types.slint:77 rog-control-center/ui/types/aura_types.slint:92
#: rog-control-center/ui/types/aura_types.slint:62 rog-control-center/ui/types/aura_types.slint:77
msgctxt "Basic aura mode"
msgid "Static"
msgstr ""
#: rog-control-center/ui/types/aura_types.slint:78 rog-control-center/ui/types/aura_types.slint:93
#: rog-control-center/ui/types/aura_types.slint:63 rog-control-center/ui/types/aura_types.slint:78
msgctxt "Basic aura mode"
msgid "Breathe"
msgstr ""
#: rog-control-center/ui/types/aura_types.slint:79 rog-control-center/ui/types/aura_types.slint:94
#: rog-control-center/ui/types/aura_types.slint:64 rog-control-center/ui/types/aura_types.slint:79
msgctxt "Basic aura mode"
msgid "Strobe"
msgstr ""
#: rog-control-center/ui/types/aura_types.slint:80
#: rog-control-center/ui/types/aura_types.slint:65
msgctxt "Basic aura mode"
msgid "Rainbow"
msgstr ""
#: rog-control-center/ui/types/aura_types.slint:81
#: rog-control-center/ui/types/aura_types.slint:66
msgctxt "Basic aura mode"
msgid "Star"
msgstr ""
#: rog-control-center/ui/types/aura_types.slint:82
#: rog-control-center/ui/types/aura_types.slint:67
msgctxt "Basic aura mode"
msgid "Rain"
msgstr ""
#: rog-control-center/ui/types/aura_types.slint:83
#: rog-control-center/ui/types/aura_types.slint:68
msgctxt "Basic aura mode"
msgid "Highlight"
msgstr ""
#: rog-control-center/ui/types/aura_types.slint:84
#: rog-control-center/ui/types/aura_types.slint:69
msgctxt "Basic aura mode"
msgid "Laser"
msgstr ""
#: rog-control-center/ui/types/aura_types.slint:85
#: rog-control-center/ui/types/aura_types.slint:70
msgctxt "Basic aura mode"
msgid "Ripple"
msgstr ""
#: rog-control-center/ui/types/aura_types.slint:86
#: rog-control-center/ui/types/aura_types.slint:71
msgctxt "Basic aura mode"
msgid "Nothing"
msgstr ""
#: rog-control-center/ui/types/aura_types.slint:87
#: rog-control-center/ui/types/aura_types.slint:72
msgctxt "Basic aura mode"
msgid "Pulse"
msgstr ""
#: rog-control-center/ui/types/aura_types.slint:88
#: rog-control-center/ui/types/aura_types.slint:73
msgctxt "Basic aura mode"
msgid "Comet"
msgstr ""
#: rog-control-center/ui/types/aura_types.slint:89
#: rog-control-center/ui/types/aura_types.slint:74
msgctxt "Basic aura mode"
msgid "Flash"
msgstr ""
#: rog-control-center/ui/types/aura_types.slint:101
#: rog-control-center/ui/types/aura_types.slint:86
msgctxt "Aura zone"
msgid "None"
msgstr ""
#: rog-control-center/ui/types/aura_types.slint:102
#: rog-control-center/ui/types/aura_types.slint:87
msgctxt "Aura zone"
msgid "Key1"
msgstr ""
#: rog-control-center/ui/types/aura_types.slint:103
#: rog-control-center/ui/types/aura_types.slint:88
msgctxt "Aura zone"
msgid "Key2"
msgstr ""
#: rog-control-center/ui/types/aura_types.slint:104
#: rog-control-center/ui/types/aura_types.slint:89
msgctxt "Aura zone"
msgid "Key3"
msgstr ""
#: rog-control-center/ui/types/aura_types.slint:105
#: rog-control-center/ui/types/aura_types.slint:90
msgctxt "Aura zone"
msgid "Key4"
msgstr ""
#: rog-control-center/ui/types/aura_types.slint:106
#: rog-control-center/ui/types/aura_types.slint:91
msgctxt "Aura zone"
msgid "Logo"
msgstr ""
#: rog-control-center/ui/types/aura_types.slint:107
#: rog-control-center/ui/types/aura_types.slint:92
msgctxt "Aura zone"
msgid "Lightbar Left"
msgstr ""
#: rog-control-center/ui/types/aura_types.slint:108
#: rog-control-center/ui/types/aura_types.slint:93
msgctxt "Aura zone"
msgid "Lightbar Right"
msgstr ""
#: rog-control-center/ui/types/aura_types.slint:112
#: rog-control-center/ui/types/aura_types.slint:97
msgctxt "Aura direction"
msgid "Right"
msgstr ""
#: rog-control-center/ui/types/aura_types.slint:113
#: rog-control-center/ui/types/aura_types.slint:98
msgctxt "Aura direction"
msgid "Left"
msgstr ""
#: rog-control-center/ui/types/aura_types.slint:114
#: rog-control-center/ui/types/aura_types.slint:99
msgctxt "Aura direction"
msgid "Up"
msgstr ""
#: rog-control-center/ui/types/aura_types.slint:115
#: rog-control-center/ui/types/aura_types.slint:100
msgctxt "Aura direction"
msgid "Down"
msgstr ""
#: rog-control-center/ui/types/aura_types.slint:119
#: rog-control-center/ui/types/aura_types.slint:104
msgctxt "Aura speed"
msgid "Low"
msgstr ""
#: rog-control-center/ui/types/aura_types.slint:120
#: rog-control-center/ui/types/aura_types.slint:105
msgctxt "Aura speed"
msgid "Medium"
msgstr ""
#: rog-control-center/ui/types/aura_types.slint:121
#: rog-control-center/ui/types/aura_types.slint:106
msgctxt "Aura speed"
msgid "High"
msgstr ""

View File

@@ -10,8 +10,8 @@ import { Node } from "widgets/graph.slint";
export { Node }
import { FanPageData, FanType, Profile } from "types/fan_types.slint";
export { FanPageData, FanType, Profile }
import { AuraPageData, AuraDevType, AuraDevTuf, AuraDevRog1, PowerZones, KbAuraPowerState, AuraPowerDev, AuraEffect } from "types/aura_types.slint";
export { AuraPageData, AuraDevType, AuraDevTuf, AuraDevRog1, PowerZones, KbAuraPowerState, AuraPowerDev, AuraEffect }
import { AuraPageData, AuraDevType, LaptopAuraPower, AuraPowerState, PowerZones, AuraEffect } from "types/aura_types.slint";
export { AuraPageData, AuraDevType, LaptopAuraPower, AuraPowerState, PowerZones, AuraEffect }
import { PageAppSettings, AppSettingsPageData } from "pages/app_settings.slint";
export { AppSize, AvailableSystemProperties, SystemPageData, AnimePageData, AppSettingsPageData }

View File

@@ -2,7 +2,7 @@ import { SystemDropdown, RogItem, SystemToggle, SystemToggleVert } from "../widg
import { Palette, Button, ComboBox, VerticalBox, GroupBox } from "std-widgets.slint";
import { StyleMetrics, Slider, HorizontalBox, TextEdit, SpinBox, LineEdit, ScrollView } from "std-widgets.slint";
import { ColourSlider } from "../widgets/colour_picker.slint";
import { AuraPageData, AuraDevType, AuraDevTuf, AuraDevRog1, PowerZones, KbAuraPowerState, AuraPowerDev, AuraEffect } from "../types/aura_types.slint";
import { AuraPageData, AuraDevType, PowerZones, LaptopAuraPower, AuraEffect } from "../types/aura_types.slint";
import { AuraPowerGroup } from "../widgets/aura_power.slint";
export component PageAura inherits Rectangle {
@@ -206,268 +206,42 @@ export component PageAura inherits Rectangle {
padding: 30px;
padding-top: 10px;
spacing: 10px;
for power in AuraPageData.supported_power_zones: gr := HorizontalLayout {
if power == PowerZones.Keyboard: zone1 := AuraPowerGroup {
group-title: @tr("Keyboard");
boot_checked: AuraPageData.led_power.rog.keyboard.boot;
boot_toggled => {
AuraPageData.led_power.rog.keyboard.boot = zone1.boot_checked;
AuraPageData.set_led_power(AuraPageData.led_power);
}
awake_checked: AuraPageData.led_power.rog.keyboard.awake;
awake_toggled => {
AuraPageData.led_power.rog.keyboard.awake = zone1.awake_checked;
AuraPageData.set_led_power(AuraPageData.led_power);
}
sleep_checked: AuraPageData.led_power.rog.keyboard.sleep;
sleep_toggled => {
AuraPageData.led_power.rog.keyboard.sleep = zone1.sleep_checked;
AuraPageData.set_led_power(AuraPageData.led_power);
}
shutdown_checked: AuraPageData.led_power.rog.keyboard.shutdown;
shutdown_toggled => {
AuraPageData.led_power.rog.keyboard.shutdown = zone1.shutdown_checked;
AuraPageData.set_led_power(AuraPageData.led_power);
}
}
if power == PowerZones.Logo: zone2 := AuraPowerGroup {
group-title: @tr("Lid Logo");
boot_checked: AuraPageData.led_power.rog.logo.boot;
boot_toggled => {
AuraPageData.led_power.rog.logo.boot = zone2.boot_checked;
AuraPageData.set_led_power(AuraPageData.led_power);
}
awake_checked: AuraPageData.led_power.rog.logo.awake;
awake_toggled => {
AuraPageData.led_power.rog.logo.awake = zone2.awake_checked;
AuraPageData.set_led_power(AuraPageData.led_power);
}
sleep_checked: AuraPageData.led_power.rog.logo.sleep;
sleep_toggled => {
AuraPageData.led_power.rog.logo.sleep = zone2.sleep_checked;
AuraPageData.set_led_power(AuraPageData.led_power);
}
shutdown_checked: AuraPageData.led_power.rog.logo.shutdown;
shutdown_toggled => {
AuraPageData.led_power.rog.logo.shutdown = zone2.shutdown_checked;
AuraPageData.set_led_power(AuraPageData.led_power);
}
for state[idx] in AuraPageData.led_power.states: zone := AuraPowerGroup {
group-title: AuraPageData.power_zone_names[state.zone_name_idx];
// TODO: use the zone name
boot_checked: state.boot;
boot_toggled => {
AuraPageData.led_power.states[idx].boot = zone.boot_checked;
AuraPageData.set_led_power(AuraPageData.led_power);
}
if power == PowerZones.Lightbar: zone3 := AuraPowerGroup {
group-title: @tr("Lightbar");
boot_checked: AuraPageData.led_power.rog.lightbar.boot;
boot_toggled => {
AuraPageData.led_power.rog.lightbar.boot = zone3.boot_checked;
AuraPageData.set_led_power(AuraPageData.led_power);
}
awake_checked: AuraPageData.led_power.rog.lightbar.awake;
awake_toggled => {
AuraPageData.led_power.rog.lightbar.awake = zone3.awake_checked;
AuraPageData.set_led_power(AuraPageData.led_power);
}
sleep_checked: AuraPageData.led_power.rog.lightbar.sleep;
sleep_toggled => {
AuraPageData.led_power.rog.lightbar.sleep = zone3.sleep_checked;
AuraPageData.set_led_power(AuraPageData.led_power);
}
shutdown_checked: AuraPageData.led_power.rog.lightbar.shutdown;
shutdown_toggled => {
AuraPageData.led_power.rog.lightbar.shutdown = zone3.shutdown_checked;
AuraPageData.set_led_power(AuraPageData.led_power);
}
awake_checked: state.awake;
awake_toggled => {
AuraPageData.led_power.states[idx].awake = zone.awake_checked;
AuraPageData.set_led_power(AuraPageData.led_power);
}
if power == PowerZones.Lid: zone4 := AuraPowerGroup {
group-title: @tr("Lid Zone");
boot_checked: AuraPageData.led_power.rog.lid.boot;
boot_toggled => {
AuraPageData.led_power.rog.lid.boot = zone4.boot_checked;
AuraPageData.set_led_power(AuraPageData.led_power);
}
awake_checked: AuraPageData.led_power.rog.lid.awake;
awake_toggled => {
AuraPageData.led_power.rog.lid.awake = zone4.awake_checked;
AuraPageData.set_led_power(AuraPageData.led_power);
}
sleep_checked: AuraPageData.led_power.rog.lid.sleep;
sleep_toggled => {
AuraPageData.led_power.rog.lid.sleep = zone4.sleep_checked;
AuraPageData.set_led_power(AuraPageData.led_power);
}
shutdown_checked: AuraPageData.led_power.rog.lid.shutdown;
shutdown_toggled => {
AuraPageData.led_power.rog.lid.shutdown = zone4.shutdown_checked;
AuraPageData.set_led_power(AuraPageData.led_power);
}
sleep_checked: state.sleep;
sleep_toggled => {
AuraPageData.led_power.states[idx].sleep = zone.sleep_checked;
AuraPageData.set_led_power(AuraPageData.led_power);
}
if power == PowerZones.RearGlow: zone5 := AuraPowerGroup {
group-title: @tr("Rear Glow");
boot_checked: AuraPageData.led_power.rog.rear-glow.boot;
boot_toggled => {
AuraPageData.led_power.rog.rear-glow.boot = zone5.boot_checked;
AuraPageData.set_led_power(AuraPageData.led_power);
}
awake_checked: AuraPageData.led_power.rog.rear-glow.awake;
awake_toggled => {
AuraPageData.led_power.rog.rear-glow.awake = zone5.awake_checked;
AuraPageData.set_led_power(AuraPageData.led_power);
}
sleep_checked: AuraPageData.led_power.rog.rear-glow.sleep;
sleep_toggled => {
AuraPageData.led_power.rog.rear-glow.sleep = zone5.sleep_checked;
AuraPageData.set_led_power(AuraPageData.led_power);
}
shutdown_checked: AuraPageData.led_power.rog.rear-glow.shutdown;
shutdown_toggled => {
AuraPageData.led_power.rog.rear-glow.shutdown = zone5.shutdown_checked;
AuraPageData.set_led_power(AuraPageData.led_power);
}
shutdown_checked: state.shutdown;
shutdown_toggled => {
AuraPageData.led_power.states[idx].shutdown = zone.shutdown_checked;
AuraPageData.set_led_power(AuraPageData.led_power);
}
}
}
}
Button {
x: root.width - self.width - 6px;
y: 6px;
text: "X";
height: 40px;
clicked => {
root.show_aura_power = false;
root.show_fade_cover = false;
}
}
}
if root.show_aura_power && AuraPageData.aura_type == AuraDevType.Old: Rectangle {
width: 100%;
height: 100%;
opacity: 1;
ScrollView {
VerticalLayout {
padding: 30px;
padding-top: 10px;
spacing: 10px;
Text {
text: "WIP: this is not complete and won't change keyboard state";
Button {
x: root.width - self.width - 6px;
y: 6px;
text: "X";
height: 40px;
clicked => {
root.show_aura_power = false;
root.show_fade_cover = false;
}
Rectangle {
border-radius: 20px;
background: Palette.control-background;
VerticalBox {
spacing: 10px;
alignment: LayoutAlignment.start;
Text {
font-size: 18px;
color: Palette.control-foreground;
horizontal-alignment: TextHorizontalAlignment.center;
text: @tr("Keyboard");
}
HorizontalBox {
SystemToggleVert {
max-height: 42px;
text: @tr("Boot");
}
SystemToggleVert {
max-height: 42px;
text: @tr("Awake");
}
SystemToggleVert {
max-height: 42px;
text: @tr("Sleep");
}
SystemToggleVert {
max-height: 42px;
text: @tr("Shutdown");
}
}
}
}
}
}
Button {
x: root.width - self.width - 6px;
y: 6px;
text: "X";
height: 40px;
clicked => {
root.show_aura_power = false;
root.show_fade_cover = false;
}
}
}
if root.show_aura_power && AuraPageData.aura_type == AuraDevType.Tuf: Rectangle {
width: 100%;
height: 100%;
opacity: 1;
ScrollView {
VerticalLayout {
padding: 30px;
padding-top: 10px;
spacing: 10px;
Text {
text: "WIP: this is not complete and won't change keyboard state";
}
Rectangle {
border-radius: 20px;
background: Palette.control-background;
VerticalBox {
spacing: 10px;
alignment: LayoutAlignment.start;
Text {
font-size: 18px;
color: Palette.control-foreground;
horizontal-alignment: TextHorizontalAlignment.center;
text: @tr("Keyboard");
}
HorizontalBox {
SystemToggleVert {
max-height: 42px;
text: @tr("Boot");
}
SystemToggleVert {
max-height: 42px;
text: @tr("Awake");
}
SystemToggleVert {
max-height: 42px;
text: @tr("Sleep");
}
SystemToggleVert {
max-height: 42px;
text: @tr("Shutdown");
}
}
}
}
}
}
Button {
x: root.width - self.width - 6px;
y: 6px;
text: "X";
height: 40px;
clicked => {
root.show_aura_power = false;
root.show_fade_cover = false;
}
}
}

View File

@@ -1,7 +1,7 @@
export enum AuraDevType {
Tuf,
Old,
New,
Old,
Tuf,
}
export struct AuraEffect {
@@ -19,52 +19,37 @@ export struct AuraEffect {
direction: int,
}
export enum AuraDevTuf {
Boot,
Awake,
Sleep,
Keyboard,
}
export enum AuraDevRog1 {
Awake,
Keyboard,
Lightbar,
Boot,
Sleep,
}
export enum PowerZones {
Logo,
Keyboard,
Lightbar,
Lid,
RearGlow,
KeyboardAndLightbar
}
export struct KbAuraPowerState {
export struct AuraPowerState {
zone: PowerZones,
zone_name_idx: int,
boot: bool,
awake: bool,
sleep: bool,
shutdown: bool,
}
export struct AuraPower {
keyboard: KbAuraPowerState,
logo: KbAuraPowerState,
lightbar: KbAuraPowerState,
lid: KbAuraPowerState,
rear_glow: KbAuraPowerState,
}
export struct AuraPowerDev {
tuf: [AuraDevTuf],
old_rog: [AuraDevRog1],
rog: AuraPower,
export struct LaptopAuraPower {
states: [AuraPowerState],
}
export global AuraPageData {
in-out property <[string]> power_zone_names: [
@tr("Aura power zone" => "Logo"),
@tr("Aura power zone" => "Keyboard"),
@tr("Aura power zone" => "Lightbar"),
@tr("Aura power zone" => "Lid"),
@tr("Aura power zone" => "Rear Glow"),
@tr("Aura power zone" => "Keyboard and Lightbar"),
];
in-out property <[string]> brightness_names: [
@tr("Aura brightness" => "Off"),
@tr("Aura brightness" => "Low"),
@@ -158,6 +143,14 @@ export global AuraPageData {
PowerZones.Lightbar,
PowerZones.Logo
];
in-out property <AuraPowerDev> led_power;
callback set_led_power(AuraPowerDev);
in-out property <LaptopAuraPower> led_power: {
states: [{
zone: PowerZones.Keyboard,
boot: true,
awake: true,
sleep: true,
shutdown: true,
}]
};
callback set_led_power(LaptopAuraPower);
}

View File

@@ -77,12 +77,12 @@ export component ColourSlider inherits VerticalLayout {
callback external_colour_change();
external_colour_change => {
if (root.final_colour.hue() < 0) {
c1.value = (root.base_colours.length - 1) * ((root.final_colour.hue() + 360) / 360);
if (root.final_colour.hue < 0) {
c1.value = (root.base_colours.length - 1) * ((root.final_colour.hue + 360) / 360);
} else {
c1.value = (root.base_colours.length - 1) * (root.final_colour.hue() / 360);
c1.value = (root.base_colours.length - 1) * (root.final_colour.hue / 360);
}
c2.value = root.base_shade.length - (root.base_shade.length * root.final_colour.brightness());
c2.value = root.base_shade.length - (root.base_shade.length * root.final_colour.value);
root.set_base_colour();
}
Rectangle {