From 8095b50ac51966ec7881ef35aced984b5b1a294b Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Thu, 12 Mar 2026 19:00:26 +0545 Subject: [PATCH] feat(src): add inhibit command to prevent system sleep The new inhibit subcommand lets users block suspend/sleep while optionally running a command, specifying why and who, and running in daemon mode. - New Features - Introduce Inhibit subcommand with command, why, who, and daemon options - Enhancements - Extend CLI parsing to support additional arguments - Enable background inhibition via daemon flag for continuous prevention --- src/cli.rs | 14 ++++++++++++++ src/main.rs | 6 ++++++ 2 files changed, 20 insertions(+) diff --git a/src/cli.rs b/src/cli.rs index 51bd38b..d324475 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -41,6 +41,20 @@ pub enum Commands { Status, /// Install udev rules for rootless operation InstallRules, + /// Inhibit system sleep/suspend + Inhibit { + /// The command to run while inhibiting (optional) + command: Vec, + /// Why the system is being inhibited + #[arg(long, default_value = "lapctl inhibiting sleep")] + why: String, + /// Who is inhibiting the system + #[arg(long, default_value = "lapctl")] + who: String, + /// Run the inhibitor in the background (daemon mode) + #[arg(long)] + daemon: bool, + }, } #[derive(Subcommand, Debug)] diff --git a/src/main.rs b/src/main.rs index f5ae9bd..b1e9c85 100644 --- a/src/main.rs +++ b/src/main.rs @@ -28,5 +28,11 @@ fn main() { Commands::Cooling { command } => commands::cooling::execute(command), Commands::Status => commands::status::execute(), Commands::InstallRules => commands::install_rules::execute(), + Commands::Inhibit { + command, + why, + who, + daemon, + } => commands::inhibit::execute(command, why, who, *daemon), } }