diff --git a/daemon/ipc.rs b/daemon/ipc.rs index 39ca00e..ebcff06 100644 --- a/daemon/ipc.rs +++ b/daemon/ipc.rs @@ -154,6 +154,7 @@ pub async fn event_provider( }; if let Res::BadSockets(bad) = res { bad.into_iter().for_each(|b| { + // TODO does Drop close this? sockets.remove(&b); }); } diff --git a/daemon/main.rs b/daemon/main.rs index dd9dba8..72ff03e 100644 --- a/daemon/main.rs +++ b/daemon/main.rs @@ -2,7 +2,7 @@ mod ipc; mod manager; mod socket; -use std::io::Read; +use std::{env, io::Read}; use anyhow::{Context, Result, anyhow}; use microxdg::Xdg; @@ -28,10 +28,19 @@ fn main() -> Result<()> { // let systemd know we're ready let _ = libsystemd::daemon::notify(false, &[libsystemd::daemon::NotifyState::Ready])?; // debug stuff + let debug = env::var("NIRI_TAG_DEBUG").is_ok(); tracing_subscriber::fmt() - .with_max_level(tracing::Level::DEBUG) + .with_max_level(if debug { + tracing::Level::DEBUG + } else { + tracing::Level::INFO + }) .init(); - let span = tracing::span!(tracing::Level::DEBUG, "main"); + let span = if debug { + tracing::span!(tracing::Level::DEBUG, "main") + } else { + tracing::span!(tracing::Level::INFO, "main") + }; let _ = span.enter(); // spawn socket consumer for niri event stream let (niri_tx, niri_rx) = smol::channel::unbounded(); diff --git a/daemon/manager.rs b/daemon/manager.rs index bf87060..11bd436 100644 --- a/daemon/manager.rs +++ b/daemon/manager.rs @@ -158,7 +158,6 @@ impl NiriTag { Tag(tag) => { tracing::debug!("Changing tag {}", tag); let tag_visible = *self.tags.entry(tag).or_insert(true); - tracing::debug!("Windows: {:?}", self.windows); let affected_windows: Vec = self .windows .iter() @@ -239,7 +238,7 @@ impl NiriTag { }) .detach(); }; - let add_tag = async |tx: Sender, windows: &HashMap, t| { + let add_tag_fire = async |tx: Sender, windows: &HashMap, t| { if windows .iter() .filter(|(_, tag)| **tag == t) @@ -249,8 +248,7 @@ impl NiriTag { send_event(tx, TagEvent::TagOccupied(t)).await; } }; - let rm_tag = async |tx: Sender, windows: &HashMap, wid, old_tag| { - tracing::debug!("removing tag {}", wid); + let rm_tag_fire = async |tx: Sender, windows: &HashMap, wid, old_tag| { let same_tagged = windows .iter() .filter(|(w, tag)| **tag == old_tag && **w != wid) @@ -293,7 +291,7 @@ impl NiriTag { self.windows.insert(wid, t); tracing::debug!("adding tag {} to {}", t, wid); let tx = self.ev_tx.clone(); - add_tag(tx, &self.windows, t).await; + add_tag_fire(tx, &self.windows, t).await; Window(wid) } TagCmd::RemoveTagFromWin(_) => { @@ -302,7 +300,7 @@ impl NiriTag { let old_tag = self.windows.insert(wid, 0).unwrap_or(0); tracing::debug!("resetting tag on {}", wid); let tx = self.ev_tx.clone(); - rm_tag(tx, &self.windows, wid, old_tag).await; + rm_tag_fire(tx, &self.windows, wid, old_tag).await; Window(wid) } TagCmd::ToggleTagOnWin(t) => { @@ -313,9 +311,9 @@ impl NiriTag { let toggle = if this_tag == t { 0 } else { t }; let tx = self.ev_tx.clone(); if toggle == 0 { - rm_tag(tx, &self.windows, wid, this_tag).await; + rm_tag_fire(tx, &self.windows, wid, this_tag).await; } else { - add_tag(tx, &self.windows, t).await; + add_tag_fire(tx, &self.windows, t).await; } tracing::debug!("toggling {} to tag {}", wid, toggle); self.windows.insert(wid, toggle); diff --git a/lib/main.rs b/lib/main.rs index cc8a6b7..0da2435 100644 --- a/lib/main.rs +++ b/lib/main.rs @@ -31,8 +31,17 @@ pub struct TagState { pub urgent: bool, } -#[derive(Default, Deserialize)] +#[derive(Deserialize)] pub struct Config { pub prepopulate: u8, pub strict: bool, } + +impl Default for Config { + fn default() -> Self { + Self { + prepopulate: 3, + strict: true, + } + } +}