Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
162 changes: 162 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "lapctl"
version = "0.1.0"
version = "0.2.0"
edition = "2024"

[dependencies]
Expand All @@ -10,3 +10,5 @@ serde_json = "1.0"
log = "0.4"
env_logger = "0.11"
regex = "1.10"
wayland-client = "0.31"
wayland-protocols-wlr = { version = "0.3", features = ["client"] }
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Built with performance and simplicity in mind, it talks directly to your system'
- **Battery Health**: Modern batteries hate being at 100% all the time. Set custom charge limits (like 80%) to significantly extend your battery's lifespan.
- **Power Tuning**: Switch through performance profiles or set hard CPU power (TDP) limits in Watts to keep things cool or let them loose.
- **Intelligent Cooling**: Force your fans into Performance, Balanced, or Quiet modes (supporting ASUS and Lenovo laptops).
- **Display Refresh Rate**: Easily query available refresh rates and change your active display's Hz on-the-fly (100% native Rust Wayland implementation using `zwlr_output_manager_v1` for wlroots compositors like Sway and Hyprland).
- **Touchpad Toggle**: Quickly enable or disable your touchpad from the terminal when using an external mouse.
- **Sleep Inhibitor**: Running a long compile or a critical download? Use the inhibitor to stop your laptop from falling asleep mid task.
- **Instant Status**: Get a bird's eye view of your hardware state, battery health, and current limits with one simple command.
Expand All @@ -47,7 +48,11 @@ cargo install --path .

#### Requirements
- **systemd**: For sleep inhibitor (`systemd-inhibit`)
- **X11/NVIDIA Tools**: `xrandr`, `nvidia-settings` for GPU management
- **GPU Switching (Optional)**: `xrandr` and `nvidia-settings` are strictly required **ONLY** when using the `lapctl gpu` command on X11 (to route proprietary NVIDIA Optimus drivers).
- **Wayland Display**: Built entirely natively using `wayland-client` and `wayland-protocols-wlr` (no `wlr-randr` required!)

#### Limitations
- **GNOME / KDE Plasma (Wayland)**: The display refresh rate feature relies heavily on the `zwlr_output_manager_v1` protocol. This protocol is exclusive to wlroots-based compositors (like Sway and Hyprland). GNOME and KDE use their own disparate internal display protocols, meaning this feature will **not work** out-of-the-box on those Desktop Environments.

---

Expand All @@ -58,6 +63,7 @@ cargo install --path .
lapctl gpu integrated # Max battery
lapctl gpu hybrid # Best of both worlds
lapctl gpu nvidia # High performance
lapctl gpu run steam # Run 'steam' on dGPU directly while in Hybrid mode

# Prolong battery life
lapctl battery limit 80
Expand All @@ -76,6 +82,10 @@ lapctl cooling performance
lapctl touchpad disable
lapctl touchpad enable

# Manage your display refresh rate
lapctl display rates
lapctl display set-rate 144

# Keep it awake
lapctl inhibit --daemon # Run in background
lapctl inhibit -- why "Critical update" ./long-task.sh
Expand Down
22 changes: 22 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ pub enum Commands {
#[command(subcommand)]
command: CoolingCommands,
},
/// Display management commands
Display {
#[command(subcommand)]
command: DisplayCommands,
},
/// Hardware status
Status,
/// Install udev rules for rootless operation
Expand Down Expand Up @@ -105,6 +110,12 @@ pub enum GpuCommands {
CacheDelete,
/// Show cache created by lapctl
CacheQuery,
/// Run an application on the discrete GPU (Requires Hybrid Mode)
Run {
/// The command and arguments to execute
#[arg(trailing_var_arg = true, allow_hyphen_values = true)]
command: Vec<String>,
},
}

#[derive(Subcommand, Debug)]
Expand Down Expand Up @@ -144,3 +155,14 @@ pub enum TouchpadCommands {
/// Disable the touchpad
Disable,
}

#[derive(Subcommand, Debug)]
pub enum DisplayCommands {
/// Show available and active refresh rates
Rates,
/// Set the display refresh rate
SetRate {
/// Target refresh rate in Hz
rate: f32,
},
}
Loading
Loading