mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-04-18 06:50:01 +02:00
This commit renames a number of border-related code refs, removing the ActiveWindow prefix since these borders are no longer just for the active window. Aliases have been added to preserve backwards compat for existing configs. An example AHK configuration file has been added to the Common Workflows section of the docs site. A link to the docs site has been added to the output of komorebic start. A note has been added recommending that users disable system animations for the best experience in the Getting Started guide.
91 lines
2.6 KiB
Rust
91 lines
2.6 KiB
Rust
#![warn(clippy::all, clippy::nursery, clippy::pedantic)]
|
|
#![allow(clippy::missing_errors_doc)]
|
|
|
|
pub use komorebi::colour::Colour;
|
|
pub use komorebi::colour::Rgb;
|
|
pub use komorebi::container::Container;
|
|
pub use komorebi::monitor::Monitor;
|
|
pub use komorebi::ring::Ring;
|
|
pub use komorebi::window::Window;
|
|
pub use komorebi::window_manager_event::WindowManagerEvent;
|
|
pub use komorebi::workspace::Workspace;
|
|
pub use komorebi::BorderColours;
|
|
pub use komorebi::GlobalState;
|
|
pub use komorebi::Notification;
|
|
pub use komorebi::NotificationEvent;
|
|
pub use komorebi::RuleDebug;
|
|
pub use komorebi::StackbarConfig;
|
|
pub use komorebi::State;
|
|
pub use komorebi::StaticConfig;
|
|
pub use komorebi::TabsConfig;
|
|
pub use komorebi_core::Arrangement;
|
|
pub use komorebi_core::Axis;
|
|
pub use komorebi_core::BorderStyle;
|
|
pub use komorebi_core::CustomLayout;
|
|
pub use komorebi_core::CycleDirection;
|
|
pub use komorebi_core::DefaultLayout;
|
|
pub use komorebi_core::Direction;
|
|
pub use komorebi_core::Layout;
|
|
pub use komorebi_core::OperationDirection;
|
|
pub use komorebi_core::Rect;
|
|
pub use komorebi_core::SocketMessage;
|
|
pub use komorebi_core::StackbarMode;
|
|
pub use komorebi_core::WindowKind;
|
|
|
|
use komorebi::DATA_DIR;
|
|
|
|
use std::io::BufReader;
|
|
use std::io::Read;
|
|
use std::io::Write;
|
|
use std::net::Shutdown;
|
|
pub use uds_windows::UnixListener;
|
|
use uds_windows::UnixStream;
|
|
|
|
const KOMOREBI: &str = "komorebi.sock";
|
|
|
|
pub fn send_message(message: &SocketMessage) -> std::io::Result<()> {
|
|
let socket = DATA_DIR.join(KOMOREBI);
|
|
let mut connected = false;
|
|
while !connected {
|
|
if let Ok(mut stream) = UnixStream::connect(&socket) {
|
|
connected = true;
|
|
stream.write_all(serde_json::to_string(message)?.as_bytes())?;
|
|
}
|
|
}
|
|
|
|
Ok(())
|
|
}
|
|
pub fn send_query(message: &SocketMessage) -> std::io::Result<String> {
|
|
let socket = DATA_DIR.join(KOMOREBI);
|
|
|
|
let mut stream = UnixStream::connect(socket)?;
|
|
stream.write_all(serde_json::to_string(message)?.as_bytes())?;
|
|
stream.shutdown(Shutdown::Write)?;
|
|
|
|
let mut reader = BufReader::new(stream);
|
|
let mut response = String::new();
|
|
reader.read_to_string(&mut response)?;
|
|
|
|
Ok(response)
|
|
}
|
|
|
|
pub fn subscribe(name: &str) -> std::io::Result<UnixListener> {
|
|
let socket = DATA_DIR.join(name);
|
|
|
|
match std::fs::remove_file(&socket) {
|
|
Ok(()) => {}
|
|
Err(error) => match error.kind() {
|
|
std::io::ErrorKind::NotFound => {}
|
|
_ => {
|
|
return Err(error);
|
|
}
|
|
},
|
|
};
|
|
|
|
let listener = UnixListener::bind(&socket)?;
|
|
|
|
send_message(&SocketMessage::AddSubscriberSocket(name.to_string()))?;
|
|
|
|
Ok(listener)
|
|
}
|