respect config.autosplit_enabled
This commit is contained in:
parent
0ced792b8c
commit
4abdca0ca1
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -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",
|
||||||
|
|
|
@ -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]
|
||||||
|
|
|
@ -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')
|
||||||
|
|
14
src/main.rs
14
src/main.rs
|
@ -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");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue