From 4abdca0ca1d80b3cd86383c9e74a13acbec6fea3 Mon Sep 17 00:00:00 2001 From: Alex Janka Date: Tue, 24 Sep 2024 12:42:18 +1000 Subject: [PATCH] respect config.autosplit_enabled --- Cargo.lock | 2 +- Cargo.toml | 2 +- packaging/PKGBUILD | 2 +- src/main.rs | 14 +++++++++----- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2055b18..d2e0254 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1041,7 +1041,7 @@ dependencies = [ [[package]] name = "sway-flash-indicator" -version = "0.5.0" +version = "0.5.1" dependencies = [ "directories", "futures-util", diff --git a/Cargo.toml b/Cargo.toml index 51f45b7..74fe569 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sway-flash-indicator" -version = "0.5.0" +version = "0.5.1" edition = "2021" [dependencies] diff --git a/packaging/PKGBUILD b/packaging/PKGBUILD index b75176b..e0ae3c0 100644 --- a/packaging/PKGBUILD +++ b/packaging/PKGBUILD @@ -1,7 +1,7 @@ # Maintainer: Alex Janka pkgname=sway-flash-indicator -pkgver=0.5.0 +pkgver=0.5.1 pkgrel=1 pkgdesc="flashes sway indicator border rather than always showing it" arch=('x86_64' 'aarch64') diff --git a/src/main.rs b/src/main.rs index 9335b98..188278e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -27,7 +27,7 @@ async fn main() -> Res<()> { logger::init_logger(!cfg!(debug_assertions)).await?; let mut event_connection = swayipc_async::Connection::new().await?; - let mut autosplit_connection = swayipc_async::Connection::new().await?; + let mut command_connection = swayipc_async::Connection::new().await?; get_sway_config(&mut event_connection).await?; @@ -84,7 +84,7 @@ async fn main() -> Res<()> { recent_code = None; log::info!("focused the window we want with id {id}"); if let Err(e) = code_trigger( - &mut autosplit_connection, + &mut command_connection, id, &CONFIG.get().await.output_blocklist, ) @@ -98,16 +98,20 @@ async fn main() -> Res<()> { // TODO: also change on window closed - // the node we're given is the one that closes if node.node_type == swayipc_async::NodeType::Con { + let config = CONFIG.get().await; + if !config.autosplit_enabled { + continue; + } let (width, height) = (node.window_rect.width, node.window_rect.height); if width == 0 || height == 0 { continue; } let ratio = (width as f64) / (height as f64); - let autosplit_ratio = CONFIG.get().await.autosplit_ratio; + let autosplit_ratio = config.autosplit_ratio; if let Err(e) = if ratio > autosplit_ratio { - autosplit_connection.run_command("splith").await + command_connection.run_command("splith").await } else { - autosplit_connection.run_command("splitv").await + command_connection.run_command("splitv").await } { log::warn!("error {e:?} setting split"); }