niri-tag/daemon/main.rs

35 lines
1.2 KiB
Rust

mod ipc;
mod manager;
mod socket;
use anyhow::{Context, Result};
fn main() -> Result<()> {
// let systemd know we're ready
let _ = libsystemd::daemon::notify(false, &[libsystemd::daemon::NotifyState::Ready])?;
// debug stuff
tracing_subscriber::fmt()
.with_max_level(tracing::Level::DEBUG)
.init();
let span = tracing::span!(tracing::Level::DEBUG, "main");
let _ = span.enter();
// spawn socket consumer for niri event stream
let (niri_tx, niri_rx) = smol::channel::unbounded();
smol::spawn(ipc::event_consumer(niri_tx)).detach();
// spawn socket listener for ipc
let (ipc_tx, ipc_rx) = smol::channel::unbounded();
smol::spawn(ipc::ipc_provider(ipc_tx)).detach();
// spawn socket listener for events
let (event_tx, event_rx) = smol::channel::unbounded();
let (fullstate_tx, fullstate_rx) = smol::channel::unbounded();
smol::spawn(ipc::event_provider(event_rx, fullstate_tx)).detach();
// begin managing niri tags
smol::block_on(async {
let niri_tag = manager::NiriTag::new(event_tx)
.await
.context("Initialising niri tag manager")
.unwrap();
niri_tag.manage_tags(niri_rx, ipc_rx, fullstate_rx).await
})
}