From 01d2e148a0d350ad18f83a727fd56764b5b010e5 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Mon, 23 Mar 2026 16:16:31 +0545 Subject: [PATCH] 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 --- src/daemon/dbus_iface.rs | 16 ++++++++-------- src/daemon/mod.rs | 3 --- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/daemon/dbus_iface.rs b/src/daemon/dbus_iface.rs index b0e5396..15ebad2 100644 --- a/src/daemon/dbus_iface.rs +++ b/src/daemon/dbus_iface.rs @@ -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(()) } diff --git a/src/daemon/mod.rs b/src/daemon/mod.rs index f05c99e..5cae0f7 100644 --- a/src/daemon/mod.rs +++ b/src/daemon/mod.rs @@ -6,9 +6,6 @@ mod dbus_iface; pub async fn run() -> Result<(), Box> { 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())?