respect config.autosplit_enabled

This commit is contained in:
Alex Janka 2024-09-24 12:42:18 +10:00
parent 0ced792b8c
commit 4abdca0ca1
4 changed files with 12 additions and 8 deletions

2
Cargo.lock generated
View file

@ -1041,7 +1041,7 @@ dependencies = [
[[package]] [[package]]
name = "sway-flash-indicator" name = "sway-flash-indicator"
version = "0.5.0" version = "0.5.1"
dependencies = [ dependencies = [
"directories", "directories",
"futures-util", "futures-util",

View file

@ -1,6 +1,6 @@
[package] [package]
name = "sway-flash-indicator" name = "sway-flash-indicator"
version = "0.5.0" version = "0.5.1"
edition = "2021" edition = "2021"
[dependencies] [dependencies]

View file

@ -1,7 +1,7 @@
# Maintainer: Alex Janka <alex@alexjanka.com> # Maintainer: Alex Janka <alex@alexjanka.com>
pkgname=sway-flash-indicator pkgname=sway-flash-indicator
pkgver=0.5.0 pkgver=0.5.1
pkgrel=1 pkgrel=1
pkgdesc="flashes sway indicator border rather than always showing it" pkgdesc="flashes sway indicator border rather than always showing it"
arch=('x86_64' 'aarch64') arch=('x86_64' 'aarch64')

View file

@ -27,7 +27,7 @@ async fn main() -> Res<()> {
logger::init_logger(!cfg!(debug_assertions)).await?; logger::init_logger(!cfg!(debug_assertions)).await?;
let mut event_connection = swayipc_async::Connection::new().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?; get_sway_config(&mut event_connection).await?;
@ -84,7 +84,7 @@ async fn main() -> Res<()> {
recent_code = None; recent_code = None;
log::info!("focused the window we want with id {id}"); log::info!("focused the window we want with id {id}");
if let Err(e) = code_trigger( if let Err(e) = code_trigger(
&mut autosplit_connection, &mut command_connection,
id, id,
&CONFIG.get().await.output_blocklist, &CONFIG.get().await.output_blocklist,
) )
@ -98,16 +98,20 @@ async fn main() -> Res<()> {
// TODO: also change on window closed - // TODO: also change on window closed -
// the node we're given is the one that closes // the node we're given is the one that closes
if node.node_type == swayipc_async::NodeType::Con { 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); let (width, height) = (node.window_rect.width, node.window_rect.height);
if width == 0 || height == 0 { if width == 0 || height == 0 {
continue; continue;
} }
let ratio = (width as f64) / (height as f64); 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 { if let Err(e) = if ratio > autosplit_ratio {
autosplit_connection.run_command("splith").await command_connection.run_command("splith").await
} else { } else {
autosplit_connection.run_command("splitv").await command_connection.run_command("splitv").await
} { } {
log::warn!("error {e:?} setting split"); log::warn!("error {e:?} setting split");
} }