split execute.rs
This commit is contained in:
parent
304317a86e
commit
2dcf092100
5 changed files with 81 additions and 77 deletions
20
src/brightness.rs
Normal file
20
src/brightness.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
use servicepoint::{Brightness, Command, Connection};
|
||||
use log::info;
|
||||
use crate::cli::BrightnessCommand;
|
||||
|
||||
pub(crate) fn brightness(connection: &Connection, brightness_command: BrightnessCommand) {
|
||||
match brightness_command {
|
||||
BrightnessCommand::Max => brightness_set(connection, Brightness::MAX),
|
||||
BrightnessCommand::Min => brightness_set(connection, Brightness::MIN),
|
||||
BrightnessCommand::Set { brightness } => {
|
||||
brightness_set(connection, Brightness::saturating_from(brightness))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn brightness_set(connection: &Connection, brightness: Brightness) {
|
||||
connection
|
||||
.send(Command::Brightness(brightness))
|
||||
.expect("Failed to set brightness");
|
||||
info!("set brightness to {brightness:?}");
|
||||
}
|
||||
Loading…
Reference in a new issue