| Crates.io | librazer |
| lib.rs | librazer |
| version | 0.8.2 |
| created_at | 2025-12-26 22:54:32.259054+00 |
| updated_at | 2025-12-27 21:42:13.035008+00 |
| description | Library for controlling Razer laptop BIOS settings via USB HID |
| homepage | |
| repository | https://github.com/stvnksslr/razer-ctl |
| max_upload_size | |
| id | 2006376 |
| size | 63,707 |
A Rust library for controlling Razer laptop BIOS settings via USB HID protocol.
Add to your Cargo.toml:
[dependencies]
librazer = "0.7"
Install libudev-dev for USB HID support:
# Debian/Ubuntu
sudo apt install libudev-dev
# Fedora
sudo dnf install systemd-devel
use librazer::{device::Device, command};
fn main() -> anyhow::Result<()> {
// Auto-detect connected Razer laptop
let device = Device::detect()?;
println!("Connected to: {}", device.info.name);
// Get current performance mode
let (perf_mode, fan_mode) = command::get_perf_mode(&device)?;
println!("Performance: {:?}, Fan: {:?}", perf_mode, fan_mode);
Ok(())
}
use librazer::{device::Device, command, types::PerfMode};
fn main() -> anyhow::Result<()> {
let device = Device::detect()?;
// Set to silent mode for better battery life
command::set_perf_mode(&device, PerfMode::Silent)?;
Ok(())
}
use librazer::{device::Device, command, types::{PerfMode, CpuBoost, GpuBoost}};
fn main() -> anyhow::Result<()> {
let device = Device::detect()?;
// Enable custom mode first
command::set_perf_mode(&device, PerfMode::Custom)?;
// Configure boost levels
command::set_cpu_boost(&device, CpuBoost::High)?;
command::set_gpu_boost(&device, GpuBoost::Medium)?;
Ok(())
}
use librazer::{device::Device, command, types::{PerfMode, FanMode}};
fn main() -> anyhow::Result<()> {
let device = Device::detect()?;
// Switch to balanced mode (required for manual fan)
command::set_perf_mode(&device, PerfMode::Balanced)?;
command::set_fan_mode(&device, FanMode::Manual)?;
// Set fan speed (2000-5000 RPM)
command::set_fan_rpm(&device, 3500)?;
Ok(())
}
use librazer::{device::Device, command, types::{BatteryCare, LogoMode, LightsAlwaysOn}};
fn main() -> anyhow::Result<()> {
let device = Device::detect()?;
// Enable battery care (limits charging to 80%)
command::set_battery_care(&device, BatteryCare::Enable)?;
// Set keyboard brightness (0-255)
command::set_keyboard_brightness(&device, 128)?;
// Set logo mode (if supported)
command::set_logo_mode(&device, LogoMode::Static)?;
// Keep lights on when sleeping
command::set_lights_always_on(&device, LightsAlwaysOn::Enable)?;
Ok(())
}
| Model | Model Number | Features |
|---|---|---|
| Razer Blade 14" (2023) Mercury | RZ09-0482X | Perf, Fan, Keyboard, Battery Care, Lights Always On |
| Razer Blade 16" (2023) Black | RZ09-0483T | Perf, Fan, Keyboard, Logo, Battery Care, Lights Always On |
lsusb | grep 1532Descriptor entry in src/descriptor.rs:Descriptor {
model_number_prefix: "RZ09-XXXXX",
name: "Razer Blade XX\" (Year)",
pid: 0xXXXX,
features: &[
feature::BATTERYCARE,
feature::FAN,
feature::KBDBACKLIGHT,
feature::PERF,
],
},
Communication uses 90-byte USB HID feature reports:
| Bytes | Purpose |
|---|---|
| 0-1 | Status + transaction ID |
| 2-7 | Protocol metadata (data_size, command_class, command_id) |
| 8-87 | Command arguments (80 bytes) |
| 88 | CRC (XOR of bytes 2-87) |
| 89 | Reserved |
Razer vendor ID: 0x1532
MIT