diff --git a/Cargo.lock b/Cargo.lock index bed08a0..4cb3801 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1041,7 +1041,7 @@ dependencies = [ [[package]] name = "sway-flash-indicator" -version = "0.6.2" +version = "0.6.3" dependencies = [ "directories", "futures-util", diff --git a/Cargo.toml b/Cargo.toml index 79b4372..800bf52 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sway-flash-indicator" -version = "0.6.2" +version = "0.6.3" edition = "2021" [dependencies] diff --git a/packaging/PKGBUILD b/packaging/PKGBUILD index af3ee7c..0cc778d 100644 --- a/packaging/PKGBUILD +++ b/packaging/PKGBUILD @@ -1,7 +1,7 @@ # Maintainer: Alex Janka pkgname=sway-flash-indicator -pkgver=0.6.2 +pkgver=0.6.3 pkgrel=1 pkgdesc="flashes sway indicator border rather than always showing it" arch=('x86_64' 'aarch64') diff --git a/src/config.rs b/src/config.rs index d7d6eab..322eb93 100644 --- a/src/config.rs +++ b/src/config.rs @@ -12,6 +12,7 @@ pub struct Config { pub flash_colour: colour::Format, pub autosplit_enabled: bool, pub autosplit_ratio: f64, + pub force_stacking: Vec, pub force_tabbed: Vec, pub output_blocklist: Vec, #[serde(default = "default_log_dir")] @@ -131,6 +132,7 @@ impl Default for Config { flash_colour: colour::parse_hex("#ff0000").unwrap(), autosplit_enabled: true, autosplit_ratio: 1.0, + force_stacking: Vec::new(), force_tabbed: Vec::new(), output_blocklist: Vec::new(), log_dir: std::path::PathBuf::new(), diff --git a/src/main.rs b/src/main.rs index f813e52..943a0e4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -77,33 +77,49 @@ async fn main() -> Res<()> { let node = window.container; let tree = command_connection.get_tree().await?; let config = CONFIG.get().await; - if window.change == swayipc_async::WindowChange::New - && node.app_id.as_ref().is_some_and(|app_id| { + if window.change == swayipc_async::WindowChange::New { + if node.app_id.as_ref().is_some_and(|app_id| { config .force_tabbed .iter() .any(|name| name.eq_ignore_ascii_case(app_id)) - }) - { - if let Some(parent) = tree.find_as_ref(|n| n.focus.contains(&node.id)) { - if parent.layout == swayipc_async::NodeLayout::SplitH - || parent.layout == swayipc_async::NodeLayout::SplitV - { - command_connection.run_command("splith").await?; - command_connection.run_command("layout tabbed").await?; + }) { + if let Some(parent) = tree.find_as_ref(|n| n.focus.contains(&node.id)) { + if parent.layout == swayipc_async::NodeLayout::SplitH + || parent.layout == swayipc_async::NodeLayout::SplitV + { + command_connection.run_command("splith").await?; + command_connection.run_command("layout tabbed").await?; + } + } + } else if node.app_id.as_ref().is_some_and(|app_id| { + config + .force_stacking + .iter() + .any(|name| name.eq_ignore_ascii_case(app_id)) + }) { + if let Some(parent) = tree.find_as_ref(|n| n.focus.contains(&node.id)) { + if parent.layout == swayipc_async::NodeLayout::SplitH + || parent.layout == swayipc_async::NodeLayout::SplitV + { + command_connection.run_command("splith").await?; + command_connection.run_command("layout stacking").await?; + } } } - } - if window.change == swayipc_async::WindowChange::New - && node.app_id == Some(String::from("code-url-handler")) - { - recent_code = Some((std::time::Instant::now(), node.id)); - } else if recent_code.is_some_and(|(t, _)| { - std::time::Instant::now().duration_since(t) - > std::time::Duration::from_millis(200) - }) { - recent_code = None; + if node + .app_id + .as_ref() + .is_some_and(|app_id| app_id.eq_ignore_ascii_case("code-url-handler")) + { + recent_code = Some((std::time::Instant::now(), node.id)); + } else if recent_code.is_some_and(|(t, _)| { + std::time::Instant::now().duration_since(t) + > std::time::Duration::from_millis(200) + }) { + recent_code = None; + } } if let Some((_, id)) = recent_code {