mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
anime: CLI and user-daemon work
This commit is contained in:
60
daemon-user/src/main.rs
Normal file
60
daemon-user/src/main.rs
Normal file
@@ -0,0 +1,60 @@
|
||||
use rog_anime::Action;
|
||||
use rog_dbus::AuraDbusClient;
|
||||
use rog_user::user_config::*;
|
||||
|
||||
use std::{
|
||||
thread::sleep,
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
println!(" rog-dbus version {}", rog_dbus::VERSION);
|
||||
|
||||
let (client, _) = AuraDbusClient::new().unwrap();
|
||||
|
||||
let mut config = UserConfig::new();
|
||||
config.load_config()?;
|
||||
let anime = config.create_anime()?;
|
||||
|
||||
// TODO:
|
||||
// - find user config dir with xdg
|
||||
// - load user config
|
||||
// - start anime
|
||||
// A way to reload when the config changes
|
||||
|
||||
loop {
|
||||
for action in anime.iter() {
|
||||
let start = Instant::now();
|
||||
|
||||
match action {
|
||||
Action::Animation(frames) => 'animation: loop {
|
||||
for frame in frames.frames() {
|
||||
client.proxies().anime().write(frame.frame().clone())?;
|
||||
if let Some(time) = frames.duration() {
|
||||
if Instant::now().duration_since(start) > time {
|
||||
break 'animation;
|
||||
}
|
||||
}
|
||||
sleep(frame.delay());
|
||||
}
|
||||
if frames.duration().is_none() {
|
||||
break 'animation;
|
||||
}
|
||||
},
|
||||
Action::Image(image) => {
|
||||
client.proxies().anime().write(image.as_ref().clone())?;
|
||||
}
|
||||
Action::Pause(duration) => 'pause: loop {
|
||||
if Instant::now().duration_since(start) > *duration {
|
||||
break 'pause;
|
||||
}
|
||||
sleep(Duration::from_millis(10));
|
||||
},
|
||||
Action::AudioEq => {}
|
||||
Action::SystemInfo => {}
|
||||
Action::TimeDate => {}
|
||||
Action::Matrix => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user