split execute.rs

This commit is contained in:
Vinzenz Schroeter 2025-02-13 20:14:29 +01:00
commit 2dcf092100
5 changed files with 81 additions and 77 deletions

20
src/brightness.rs Normal file
View 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:?}");
}