From 66c3bab2fa62eaf81943e3d470b55bf8bd1687c3 Mon Sep 17 00:00:00 2001 From: atagen Date: Sat, 5 Jul 2025 15:30:44 +1000 Subject: [PATCH] feat: add activation on fill --- README.md | 4 ++++ daemon/manager.rs | 14 ++++++++++++++ lib/main.rs | 2 ++ 3 files changed, 20 insertions(+) diff --git a/README.md b/README.md index a17d68c..c9e404b 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,10 @@ prepopulate = 3 # paradigm, or get your desktop stuck in a weird state. strict = true +# activation on fill +# this will auto-activate an empty + disabled tags if you send a window to it +activation_on_fill = true + ```` ## ipc diff --git a/daemon/manager.rs b/daemon/manager.rs index 108f0ab..6a21416 100644 --- a/daemon/manager.rs +++ b/daemon/manager.rs @@ -295,7 +295,14 @@ impl NiriTag { TagCmd::AddTagToWin(t) => { let wid = self.get_focused_window().await?.id; self.change_window_tag(wid, Some(t)).await?; + let entry = self.tags.entry(t).or_default(); + if entry.windows.len() == 1 && self.config.activation_on_fill { + entry.enabled = true; + self.fire_event(TagEvent::TagEnabled(t)).await; + &[Tag(t), Window(wid)] + } else { &[Window(wid)] + } } TagCmd::RemoveTagFromWin(_) => { let wid = self.get_focused_window().await?.id; @@ -311,7 +318,14 @@ impl NiriTag { }; self.change_window_tag(wid, Some(new_tag)).await?; tracing::debug!("toggling {} to tag {}", wid, new_tag); + let entry = self.tags.entry(new_tag).or_default(); + if new_tag != 0 && entry.windows.len() == 1 && self.config.activation_on_fill { + entry.enabled = true; + self.fire_event(TagEvent::TagEnabled(t)).await; + &[Tag(t), Window(wid)] + } else { &[Window(wid)] + } } TagCmd::EnableTag(t) => { diff --git a/lib/main.rs b/lib/main.rs index c1bfa66..a705d06 100644 --- a/lib/main.rs +++ b/lib/main.rs @@ -48,6 +48,7 @@ impl Default for TagState { pub struct Config { pub prepopulate: u8, pub strict: bool, + pub activation_on_fill: bool, } impl Default for Config { @@ -55,6 +56,7 @@ impl Default for Config { Self { prepopulate: 3, strict: true, + activation_on_fill: true, } } }