refactor(src/daemon): replace execute calls with execute_local for dbus commands
Why: Adopt local execution path to streamline command handling and reduce RPC overhead. New Features - Enhancements - Replace `gpu::execute` with `gpu::execute_local` in integrated, hybrid, and nvidia command invocations. - Replace `crate::commands::power`, `battery`, `cooling`, and `touchpad` executions with `execute_local`. - Remove the unused `LAPCTL_DAEMON_INTERNAL` environment variable setting. Bug Fixes - None
This commit is contained in:
2 files changed
+8
-11
No files matched your search
@@ -20,7 +20,7 @@ impl Default for LapctlInterface {
|
||||
#[interface(name = "org.lapctl1")]
|
||||
impl LapctlInterface {
|
||||
pub async fn switch_gpu_integrated(&self, no_reboot: bool) -> zbus::fdo::Result<()> {
|
||||
gpu::execute(&GpuCommands::Integrated { no_reboot });
|
||||
gpu::execute_local(&GpuCommands::Integrated { no_reboot });
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ impl LapctlInterface {
|
||||
no_reboot: bool,
|
||||
) -> zbus::fdo::Result<()> {
|
||||
let rtd3_opt = if rtd3 < 0 { None } else { Some(rtd3 as u8) };
|
||||
gpu::execute(&GpuCommands::Hybrid {
|
||||
gpu::execute_local(&GpuCommands::Hybrid {
|
||||
rtd3: rtd3_opt,
|
||||
use_nvidia_current,
|
||||
no_reboot,
|
||||
@@ -54,7 +54,7 @@ impl LapctlInterface {
|
||||
} else {
|
||||
Some(coolbits as u32)
|
||||
};
|
||||
gpu::execute(&GpuCommands::Nvidia {
|
||||
gpu::execute_local(&GpuCommands::Nvidia {
|
||||
dm: dm_opt,
|
||||
force_comp,
|
||||
coolbits: coolbits_opt,
|
||||
@@ -66,7 +66,7 @@ impl LapctlInterface {
|
||||
}
|
||||
|
||||
pub async fn set_battery_limit(&self, percent: u32) -> zbus::fdo::Result<()> {
|
||||
crate::commands::battery::execute(&crate::cli::BatteryCommands::Limit {
|
||||
crate::commands::battery::execute_local(&crate::cli::BatteryCommands::Limit {
|
||||
percent: percent as u8,
|
||||
});
|
||||
Ok(())
|
||||
@@ -84,12 +84,12 @@ impl LapctlInterface {
|
||||
)));
|
||||
}
|
||||
};
|
||||
crate::commands::power::execute(&cmd);
|
||||
crate::commands::power::execute_local(&cmd);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn set_tdp_limit(&self, watts: u32) -> zbus::fdo::Result<()> {
|
||||
crate::commands::power::execute(&crate::cli::PowerCommands::LimitTdp { watts });
|
||||
crate::commands::power::execute_local(&crate::cli::PowerCommands::LimitTdp { watts });
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ impl LapctlInterface {
|
||||
)));
|
||||
}
|
||||
};
|
||||
crate::commands::cooling::execute(&cmd);
|
||||
crate::commands::cooling::execute_local(&cmd);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ impl LapctlInterface {
|
||||
} else {
|
||||
crate::cli::TouchpadCommands::Enable
|
||||
};
|
||||
crate::commands::touchpad::execute(&cmd);
|
||||
crate::commands::touchpad::execute_local(&cmd);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -6,9 +6,6 @@ mod dbus_iface;
|
||||
|
||||
pub async fn run() -> Result<(), Box<dyn Error>> {
|
||||
info!("Starting lapctld daemon...");
|
||||
unsafe {
|
||||
std::env::set_var("LAPCTL_DAEMON_INTERNAL", "1");
|
||||
}
|
||||
let _connection = Builder::system()?
|
||||
.name("org.lapctl")?
|
||||
.serve_at("/org/lapctl", dbus_iface::LapctlInterface::default())?
|
||||
|
||||
Reference in new issue
Block a user