-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
hopefully this is the first and last commit
- Loading branch information
0 parents
commit a844a7e
Showing
4 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/target |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[package] | ||
name = "i3-alternating" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
i3ipc = "*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use i3ipc::{reply::NodeLayout, I3Connection, I3EventListener, Subscription, event::Event, event::inner::WindowChange}; | ||
|
||
fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
let mut connection = I3Connection::connect()?; | ||
let mut listener = I3EventListener::connect()?; | ||
let subs = [Subscription::Window]; | ||
listener.subscribe(&subs)?; | ||
for event in listener.listen() { | ||
if let Event::WindowEvent(info) = event? { | ||
match info.container.layout { | ||
NodeLayout::SplitH | NodeLayout::SplitV if info.change == WindowChange::New => { | ||
let (_, _, w, h) = info.container.window_rect; | ||
if w > h { | ||
connection.run_command("split h")?; | ||
} else { | ||
connection.run_command("split v")?; | ||
} | ||
}, | ||
_ => (), | ||
} | ||
} | ||
} | ||
Ok(()) | ||
} |