Add readme

This commit is contained in:
Triston Armstrong 2023-08-11 23:21:48 -05:00
parent 087a0658fd
commit a8930c7fb6
2 changed files with 24 additions and 4 deletions

13
README.md Normal file
View File

@ -0,0 +1,13 @@
# Keyboard Backlight CLI
This essentially is just a CLI that you can install via `cargo` so you can quickly adjust the keyboard backlight of your mac
## Target OS
I build this for me to use in Asahi linux on the mac because i, for the life of me, couldnt find a ui control for the keyboard backlight.
## How To Use
1. Download this repo
2. Go to the directory
3. Run `cargo build`
4. Then Run `cargo install --path .`
5. Run `sudo kbd-bl <value>` anywhere in your terminal to adjust the backlight on the fly
6. Take a swig of taquila

View File

@ -3,23 +3,30 @@ use std::fs;
fn main() {
let args: Vec<String> = env::args().collect();
if args.len() < 2 {
println!("ERR: Must provide an argument");
return;
}
let value = &args[1];
let parsed = value.trim().parse::<i32>();
if parsed.is_err() {
panic!("Value entered ({}) is not number", value);
println!("ERR: Value entered ({}) is not number", value);
return;
}
let parsed_value = parsed.unwrap();
if parsed_value > 255 {
panic!("value entered ({}) must be <= 255", value);
println!("ERR: value entered ({}) must be <= 255", value);
return;
}
if parsed_value < 0 {
panic!("value entered ({}) must be >= 0", value);
println!("ERR: value entered ({}) must be >= 0", value);
return;
}
fs::write("/sys/class/leds/kbd_backlight/brightness", value)
.expect("Something went wrong writing to file")
.expect("Something went wrong writing to file - you may not have elevated privs aka sudo")
}