mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Better everything
This commit is contained in:
@@ -17,6 +17,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- More logging
|
||||
- Fix TUF laptop led power
|
||||
- Sanitize the dbus path for aura devices (remove `.` chars)
|
||||
- Even more error handling (gracefully)
|
||||
- Better checking for dbus interfaces
|
||||
- Remove dbus `supported_interfaces`
|
||||
- dbus ObjectManager is now at root `/`
|
||||
|
||||
## [v6.0.5]
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ use rog_anime::usb::get_anime_type;
|
||||
use rog_anime::{AnimTime, AnimeDataBuffer, AnimeDiagonal, AnimeGif, AnimeImage, AnimeType, Vec2};
|
||||
use rog_aura::keyboard::{AuraPowerState, LaptopAuraPower};
|
||||
use rog_aura::{self, AuraDeviceType, AuraEffect, PowerZones};
|
||||
use rog_dbus::list_iface_blocking;
|
||||
use rog_dbus::zbus_anime::AnimeProxyBlocking;
|
||||
use rog_dbus::zbus_aura::AuraProxyBlocking;
|
||||
use rog_dbus::zbus_fan_curves::FanCurvesProxyBlocking;
|
||||
@@ -65,7 +66,7 @@ fn main() {
|
||||
}
|
||||
|
||||
let supported_properties = platform_proxy.supported_properties().unwrap();
|
||||
let supported_interfaces = platform_proxy.supported_interfaces().unwrap();
|
||||
let supported_interfaces = list_iface_blocking().unwrap();
|
||||
|
||||
if parsed.version {
|
||||
println!("asusctl v{}", env!("CARGO_PKG_VERSION"));
|
||||
@@ -89,7 +90,10 @@ fn print_error_help(
|
||||
print_info();
|
||||
println!();
|
||||
println!("Supported interfaces:\n\n{:#?}\n", supported_interfaces);
|
||||
println!("Supported properties:\n\n{:#?}\n", supported_properties);
|
||||
println!(
|
||||
"Supported properties on Platform:\n\n{:#?}\n",
|
||||
supported_properties
|
||||
);
|
||||
}
|
||||
|
||||
fn print_info() {
|
||||
@@ -120,12 +124,8 @@ fn check_service(name: &str) -> bool {
|
||||
|
||||
fn find_aura_iface() -> Result<Vec<AuraProxyBlocking<'static>>, Box<dyn std::error::Error>> {
|
||||
let conn = zbus::blocking::Connection::system().unwrap();
|
||||
let f = zbus::blocking::fdo::ObjectManagerProxy::new(
|
||||
&conn,
|
||||
"org.asuslinux.Daemon",
|
||||
"/org/asuslinux",
|
||||
)
|
||||
.unwrap();
|
||||
let f =
|
||||
zbus::blocking::fdo::ObjectManagerProxy::new(&conn, "org.asuslinux.Daemon", "/").unwrap();
|
||||
let interfaces = f.get_managed_objects().unwrap();
|
||||
let mut aura_paths = Vec::new();
|
||||
for v in interfaces.iter() {
|
||||
@@ -203,6 +203,31 @@ fn do_parsed(
|
||||
};
|
||||
let commands: Vec<String> = cmdlist.lines().map(|s| s.to_owned()).collect();
|
||||
for command in commands.iter().filter(|command| {
|
||||
if command.trim().starts_with("fan-curve")
|
||||
&& !supported_interfaces
|
||||
.contains(&"org.asuslinux.FanCurves".to_string())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if command.trim().starts_with("anime")
|
||||
&& !supported_interfaces.contains(&"org.asuslinux.Anime".to_string())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if command.trim().starts_with("slash")
|
||||
&& !supported_interfaces.contains(&"org.asuslinux.Slash".to_string())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if command.trim().starts_with("bios")
|
||||
&& !supported_interfaces.contains(&"org.asuslinux.Platform".to_string())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if !dev_type.is_old_laptop()
|
||||
&& !dev_type.is_tuf_laptop()
|
||||
&& command.trim().starts_with("led-pow-1")
|
||||
|
||||
@@ -62,7 +62,7 @@ async fn start_daemon() -> Result<(), Box<dyn Error>> {
|
||||
let mut connection = Connection::system().await?;
|
||||
connection
|
||||
.object_server()
|
||||
.at("/org/asuslinux", ObjectManager)
|
||||
.at("/", ObjectManager)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
|
||||
@@ -6,12 +6,12 @@ pub mod setup_system;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use config_traits::StdConfig;
|
||||
use rog_dbus::zbus_platform::PlatformProxyBlocking;
|
||||
use rog_dbus::has_iface_blocking;
|
||||
use slint::{ComponentHandle, PhysicalSize, SharedString, Weak};
|
||||
|
||||
use crate::config::Config;
|
||||
use crate::ui::setup_anime::setup_anime_page;
|
||||
use crate::ui::setup_aura::{has_aura_iface_blocking, setup_aura_page};
|
||||
use crate::ui::setup_aura::setup_aura_page;
|
||||
use crate::ui::setup_fans::setup_fan_curve_page;
|
||||
use crate::ui::setup_system::{setup_system_page, setup_system_page_callbacks};
|
||||
use crate::{AppSettingsPageData, MainWindow};
|
||||
@@ -108,19 +108,13 @@ pub fn setup_window(config: Arc<Mutex<Config>>) -> MainWindow {
|
||||
}
|
||||
};
|
||||
|
||||
let conn = zbus::blocking::Connection::system().unwrap();
|
||||
let platform = PlatformProxyBlocking::new(&conn).unwrap();
|
||||
|
||||
let interfaces = platform.supported_interfaces().unwrap();
|
||||
log::debug!("Available interfaces: {interfaces:?}");
|
||||
// "Anime", "Aura", "FanCurves", "Platform"
|
||||
ui.set_sidebar_items_avilable(
|
||||
[
|
||||
// Needs to match the order of slint sidebar items
|
||||
interfaces.contains(&"Platform".into()),
|
||||
has_aura_iface_blocking().unwrap_or(false),
|
||||
interfaces.contains(&"Anime".into()),
|
||||
interfaces.contains(&"FanCurves".into()),
|
||||
has_iface_blocking("org.asuslinux.Platform").unwrap_or(false),
|
||||
has_iface_blocking("org.asuslinux.Aura").unwrap_or(false),
|
||||
has_iface_blocking("org.asuslinux.Anime").unwrap_or(false),
|
||||
has_iface_blocking("org.asuslinux.FanCurves").unwrap_or(false),
|
||||
true,
|
||||
true,
|
||||
]
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use log::{error, info, warn};
|
||||
use rog_anime::Animations;
|
||||
use rog_dbus::zbus_anime::AnimeProxy;
|
||||
use slint::ComponentHandle;
|
||||
@@ -11,8 +12,13 @@ use crate::{set_ui_callbacks, set_ui_props_async, AnimePageData, MainWindow};
|
||||
pub fn setup_anime_page(ui: &MainWindow, _states: Arc<Mutex<Config>>) {
|
||||
let handle = ui.as_weak();
|
||||
tokio::spawn(async move {
|
||||
let conn = zbus::Connection::system().await.unwrap();
|
||||
let anime = AnimeProxy::new(&conn).await.unwrap();
|
||||
let Ok(conn) = zbus::Connection::system().await.map_err(|e| warn!("{e:}")) else {
|
||||
return;
|
||||
};
|
||||
let Ok(anime) = AnimeProxy::new(&conn).await.map_err(|e| warn!("{e:}")) else {
|
||||
info!("This device may not have an AniMe. If not then the error can be ignored");
|
||||
return;
|
||||
};
|
||||
|
||||
set_ui_props_async!(handle, anime, AnimePageData, brightness);
|
||||
set_ui_props_async!(handle, anime, AnimePageData, builtins_enabled);
|
||||
@@ -123,6 +129,7 @@ pub fn setup_anime_page(ui: &MainWindow, _states: Arc<Mutex<Config>>) {
|
||||
"Setting Anime off_when_unplugged failed"
|
||||
);
|
||||
})
|
||||
.unwrap();
|
||||
.map_err(|e| error!("setup_anime_page: upgrade_in_event_loop: {e:?}"))
|
||||
.ok();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use log::info;
|
||||
use log::{error, info};
|
||||
use rog_aura::keyboard::LaptopAuraPower;
|
||||
use rog_dbus::zbus_aura::AuraProxy;
|
||||
use slint::{ComponentHandle, Model, RgbaColor, SharedString};
|
||||
@@ -33,31 +33,11 @@ fn decode_hex(s: &str) -> RgbaColor<u8> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn has_aura_iface_blocking() -> Result<bool, Box<dyn std::error::Error>> {
|
||||
let conn = zbus::blocking::Connection::system()?;
|
||||
let f = zbus::blocking::fdo::ObjectManagerProxy::new(
|
||||
&conn,
|
||||
"org.asuslinux.Daemon",
|
||||
"/org/asuslinux",
|
||||
)?;
|
||||
let interfaces = f.get_managed_objects()?;
|
||||
let mut aura_paths = Vec::new();
|
||||
for v in interfaces.iter() {
|
||||
for k in v.1.keys() {
|
||||
if k.as_str() == "org.asuslinux.Aura" {
|
||||
aura_paths.push(v.0.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(!aura_paths.is_empty())
|
||||
}
|
||||
|
||||
/// Returns the first available Aura interface
|
||||
// TODO: return all
|
||||
async fn find_aura_iface() -> Result<AuraProxy<'static>, Box<dyn std::error::Error>> {
|
||||
let conn = zbus::Connection::system().await?;
|
||||
let f =
|
||||
zbus::fdo::ObjectManagerProxy::new(&conn, "org.asuslinux.Daemon", "/org/asuslinux").await?;
|
||||
let f = zbus::fdo::ObjectManagerProxy::new(&conn, "org.asuslinux.Daemon", "/").await?;
|
||||
let interfaces = f.get_managed_objects().await?;
|
||||
let mut aura_paths = Vec::new();
|
||||
for v in interfaces.iter() {
|
||||
@@ -93,9 +73,7 @@ pub fn setup_aura_page(ui: &MainWindow, _states: Arc<Mutex<Config>>) {
|
||||
|
||||
let handle = ui.as_weak();
|
||||
tokio::spawn(async move {
|
||||
let aura = if let Ok(aura) = find_aura_iface().await {
|
||||
aura
|
||||
} else {
|
||||
let Ok(aura) = find_aura_iface().await else {
|
||||
info!("This device appears to have no aura interfaces");
|
||||
return;
|
||||
};
|
||||
@@ -138,6 +116,7 @@ pub fn setup_aura_page(ui: &MainWindow, _states: Arc<Mutex<Config>>) {
|
||||
.global::<AuraPageData>()
|
||||
.set_available_mode_names(res.as_slice().into());
|
||||
})
|
||||
.map_err(|e| error!("{e:}"))
|
||||
.ok();
|
||||
}
|
||||
|
||||
@@ -196,7 +175,8 @@ pub fn setup_aura_page(ui: &MainWindow, _states: Arc<Mutex<Config>>) {
|
||||
});
|
||||
});
|
||||
})
|
||||
.unwrap();
|
||||
.map_err(|e| error!("{e:}"))
|
||||
.ok();
|
||||
|
||||
// Need to update the UI if the mode changes
|
||||
let handle_copy = handle.clone();
|
||||
@@ -213,6 +193,7 @@ pub fn setup_aura_page(ui: &MainWindow, _states: Arc<Mutex<Config>>) {
|
||||
.invoke_update_led_mode_data(out.into());
|
||||
handle.invoke_external_colour_change();
|
||||
})
|
||||
.map_err(|e| error!("{e:}"))
|
||||
.ok();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use log::{error, info};
|
||||
use rog_dbus::zbus_fan_curves::FanCurvesProxy;
|
||||
use rog_platform::platform::ThrottlePolicy;
|
||||
use rog_profiles::fan_curve_set::CurveData;
|
||||
@@ -81,7 +82,8 @@ pub fn update_fan_data(
|
||||
}
|
||||
}
|
||||
})
|
||||
.unwrap();
|
||||
.map_err(|e| error!("update_fan_data: upgrade_in_event_loop: {e:?}"))
|
||||
.ok();
|
||||
}
|
||||
|
||||
pub fn setup_fan_curve_page(ui: &MainWindow, _config: Arc<Mutex<Config>>) {
|
||||
@@ -89,17 +91,44 @@ pub fn setup_fan_curve_page(ui: &MainWindow, _config: Arc<Mutex<Config>>) {
|
||||
|
||||
tokio::spawn(async move {
|
||||
// Create the connections/proxies here to prevent future delays in process
|
||||
let conn = zbus::Connection::system().await.unwrap();
|
||||
let fans = FanCurvesProxy::new(&conn).await.unwrap();
|
||||
let conn = if let Ok(conn) = zbus::Connection::system().await.map_err(|e| error!("{e:}")) {
|
||||
conn
|
||||
} else {
|
||||
return;
|
||||
};
|
||||
let fans = if let Ok(fans) = FanCurvesProxy::new(&conn).await.map_err(|e| error!("{e:}")) {
|
||||
fans
|
||||
} else {
|
||||
info!(
|
||||
"This device may not have an Fan Curve control. If not then the error can be \
|
||||
ignored"
|
||||
);
|
||||
return;
|
||||
};
|
||||
|
||||
let handle_copy = handle.clone();
|
||||
// Do initial setup
|
||||
let balanced = fans.fan_curve_data(ThrottlePolicy::Balanced).await.unwrap();
|
||||
let perf = fans
|
||||
let Ok(balanced) = fans
|
||||
.fan_curve_data(ThrottlePolicy::Balanced)
|
||||
.await
|
||||
.map_err(|e| error!("{e:}"))
|
||||
else {
|
||||
return;
|
||||
};
|
||||
let Ok(perf) = fans
|
||||
.fan_curve_data(ThrottlePolicy::Performance)
|
||||
.await
|
||||
.unwrap();
|
||||
let quiet = fans.fan_curve_data(ThrottlePolicy::Quiet).await.unwrap();
|
||||
.map_err(|e| error!("{e:}"))
|
||||
else {
|
||||
return;
|
||||
};
|
||||
let Ok(quiet) = fans
|
||||
.fan_curve_data(ThrottlePolicy::Quiet)
|
||||
.await
|
||||
.map_err(|e| error!("{e:}"))
|
||||
else {
|
||||
return;
|
||||
};
|
||||
update_fan_data(handle, balanced, perf, quiet);
|
||||
|
||||
let handle_next1 = handle_copy.clone();
|
||||
@@ -111,14 +140,30 @@ pub fn setup_fan_curve_page(ui: &MainWindow, _config: Arc<Mutex<Config>>) {
|
||||
let fans = fans1.clone();
|
||||
let handle_next = handle_next1.clone();
|
||||
tokio::spawn(async move {
|
||||
fans.set_curves_to_defaults(profile.into()).await.unwrap();
|
||||
|
||||
let balanced = fans.fan_curve_data(ThrottlePolicy::Balanced).await.unwrap();
|
||||
let perf = fans
|
||||
if fans.set_curves_to_defaults(profile.into()).await.is_err() {
|
||||
return;
|
||||
}
|
||||
let Ok(balanced) = fans
|
||||
.fan_curve_data(ThrottlePolicy::Balanced)
|
||||
.await
|
||||
.map_err(|e| error!("{e:}"))
|
||||
else {
|
||||
return;
|
||||
};
|
||||
let Ok(perf) = fans
|
||||
.fan_curve_data(ThrottlePolicy::Performance)
|
||||
.await
|
||||
.unwrap();
|
||||
let quiet = fans.fan_curve_data(ThrottlePolicy::Quiet).await.unwrap();
|
||||
.map_err(|e| error!("{e:}"))
|
||||
else {
|
||||
return;
|
||||
};
|
||||
let Ok(quiet) = fans
|
||||
.fan_curve_data(ThrottlePolicy::Quiet)
|
||||
.await
|
||||
.map_err(|e| error!("{e:}"))
|
||||
else {
|
||||
return;
|
||||
};
|
||||
update_fan_data(handle_next, balanced, perf, quiet);
|
||||
});
|
||||
});
|
||||
@@ -127,11 +172,15 @@ pub fn setup_fan_curve_page(ui: &MainWindow, _config: Arc<Mutex<Config>>) {
|
||||
let data: Vec<Node> = data.iter().collect();
|
||||
let data = fan_data_for(fan, enabled, data);
|
||||
tokio::spawn(async move {
|
||||
fans.set_fan_curve(profile.into(), data).await.unwrap();
|
||||
fans.set_fan_curve(profile.into(), data)
|
||||
.await
|
||||
.map_err(|e| error!("{e:}"))
|
||||
.ok()
|
||||
});
|
||||
});
|
||||
})
|
||||
.unwrap();
|
||||
.map_err(|e| error!("setup_fan_curve_page: upgrade_in_event_loop: {e:?}"))
|
||||
.ok();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -7,3 +7,44 @@ pub mod zbus_platform;
|
||||
pub mod zbus_slash;
|
||||
|
||||
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||
|
||||
pub fn list_iface_blocking() -> Result<Vec<String>, Box<dyn std::error::Error>> {
|
||||
let conn = zbus::blocking::Connection::system()?;
|
||||
let f = zbus::blocking::fdo::ObjectManagerProxy::new(&conn, "org.asuslinux.Daemon", "/")?;
|
||||
let interfaces = f.get_managed_objects()?;
|
||||
let mut ifaces = Vec::new();
|
||||
for v in interfaces.iter() {
|
||||
for k in v.1.keys() {
|
||||
ifaces.push(k.to_string());
|
||||
}
|
||||
}
|
||||
Ok(ifaces)
|
||||
}
|
||||
|
||||
pub fn has_iface_blocking(iface: &str) -> Result<bool, Box<dyn std::error::Error>> {
|
||||
let conn = zbus::blocking::Connection::system()?;
|
||||
let f = zbus::blocking::fdo::ObjectManagerProxy::new(&conn, "org.asuslinux.Daemon", "/")?;
|
||||
let interfaces = f.get_managed_objects()?;
|
||||
for v in interfaces.iter() {
|
||||
for k in v.1.keys() {
|
||||
if k.as_str() == iface {
|
||||
return Ok(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(false)
|
||||
}
|
||||
|
||||
pub async fn has_iface(iface: &str) -> Result<bool, Box<dyn std::error::Error>> {
|
||||
let conn = zbus::Connection::system().await?;
|
||||
let f = zbus::fdo::ObjectManagerProxy::new(&conn, "org.asuslinux.Daemon", "/").await?;
|
||||
let interfaces = f.get_managed_objects().await?;
|
||||
for v in interfaces.iter() {
|
||||
for k in v.1.keys() {
|
||||
if k.as_str() == iface {
|
||||
return Ok(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(false)
|
||||
}
|
||||
|
||||
@@ -36,9 +36,6 @@ trait Platform {
|
||||
/// NextThrottleThermalPolicy method
|
||||
fn next_throttle_thermal_policy(&self) -> zbus::Result<()>;
|
||||
|
||||
/// SupportedInterfaces method
|
||||
fn supported_interfaces(&self) -> zbus::Result<Vec<String>>;
|
||||
|
||||
/// SupportedProperties method
|
||||
fn supported_properties(&self) -> zbus::Result<Vec<Properties>>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user