From e3c5108bd890d8f1da3faa03e97eed7ca3b7c73b Mon Sep 17 00:00:00 2001 From: Tassilo Horn Date: Wed, 17 Feb 2021 14:44:25 +0100 Subject: [PATCH] Move demon init into demon.rs --- src/bin/swayrd.rs | 15 +-------------- src/demon.rs | 13 +++++++++++++ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/bin/swayrd.rs b/src/bin/swayrd.rs index 7cf86d3..7341e33 100644 --- a/src/bin/swayrd.rs +++ b/src/bin/swayrd.rs @@ -3,21 +3,8 @@ extern crate serde; extern crate serde_json; -use std::collections::HashMap; -use std::sync::Arc; -use std::sync::RwLock; -use std::thread; use swayr::demon; -use swayr::ipc; fn main() { - let con_props: Arc>> = - Arc::new(RwLock::new(HashMap::new())); - let con_props_for_ev_handler = con_props.clone(); - - thread::spawn(move || { - demon::monitor_sway_events(con_props_for_ev_handler); - }); - - demon::serve_client_requests(con_props); + demon::run_demon(); } diff --git a/src/demon.rs b/src/demon.rs index 6383641..18549bb 100644 --- a/src/demon.rs +++ b/src/demon.rs @@ -9,11 +9,24 @@ use std::io::Read; use std::os::unix::net::{UnixListener, UnixStream}; use std::sync::Arc; use std::sync::RwLock; +use std::thread; use std::time::{SystemTime, UNIX_EPOCH}; use swayipc as s; use swayipc::reply as r; +pub fn run_demon() { + let con_props: Arc>> = + Arc::new(RwLock::new(HashMap::new())); + let con_props_for_ev_handler = con_props.clone(); + + thread::spawn(move || { + monitor_sway_events(con_props_for_ev_handler); + }); + + serve_client_requests(con_props); +} + fn connect_and_subscribe() -> s::Fallible { s::Connection::new()? .subscribe(&[s::EventType::Window, s::EventType::Workspace])