Move demon init into demon.rs

timeout_old
Tassilo Horn 4 years ago
parent 01ac7bfae1
commit e3c5108bd8
  1. 15
      src/bin/swayrd.rs
  2. 13
      src/demon.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<RwLock<HashMap<i64, ipc::ExtraProps>>> =
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();
}

@ -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<RwLock<HashMap<i64, ipc::ExtraProps>>> =
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::EventIterator> {
s::Connection::new()?
.subscribe(&[s::EventType::Window, s::EventType::Workspace])

Loading…
Cancel
Save