Skip to content

Commit

Permalink
Move keyboard animator task to a function
Browse files Browse the repository at this point in the history
  • Loading branch information
JosuGZ committed Oct 29, 2024
1 parent 541c028 commit 76ab9df
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions razer_control_gui/src/daemon/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,7 @@ fn main() {
}
}

// Start the keyboard animator thread,
thread::spawn(move || {
loop {
if let Some(laptop) = DEV_MANAGER.lock().unwrap().get_device() {
EFFECT_MANAGER.lock().unwrap().update(laptop);
}
std::thread::sleep(std::time::Duration::from_millis(kbd::ANIMATION_SLEEP_MS));
}
});
start_keyboard_animator_task();

thread::spawn(move || {
let dbus_session = Connection::new_session()
Expand Down Expand Up @@ -238,6 +230,19 @@ fn init_logging() {
builder.init();
}

/// Handles keyboard animations
pub fn start_keyboard_animator_task() -> JoinHandle<()> {
// Start the keyboard animator thread,
thread::spawn(|| {
loop {
if let Some(laptop) = DEV_MANAGER.lock().unwrap().get_device() {
EFFECT_MANAGER.lock().unwrap().update(laptop);
}
thread::sleep(std::time::Duration::from_millis(kbd::ANIMATION_SLEEP_MS));
}
})
}

/// Monitors signals and stops the daemon when receiving one
pub fn start_shutdown_task() -> JoinHandle<()> {
thread::spawn(|| {
Expand Down

0 comments on commit 76ab9df

Please sign in to comment.