mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-04-19 07:19:50 +02:00
feat(subscriptions): add and remove subscribers
This commit adds two new commands to add and remove subscribers to WindowManagerEvent and SocketMessage notifications after they have been handled by komorebi. Interprocess communication is achieved using Named Pipes; the subscribing process must first create the Named Pipe, and then run the 'add-subscriber' command, specifying the pipe name as the argument (without the pipe filesystem path prepended). Whenever a pipe is closing or has been closed, komorebi will flag this as a stale subscription and remove it automatically. resolve #54
This commit is contained in:
@@ -31,6 +31,7 @@ pub mod operation_direction;
|
||||
pub mod rect;
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, Display)]
|
||||
#[serde(tag = "type", content = "content")]
|
||||
pub enum SocketMessage {
|
||||
// Window / Container Commands
|
||||
FocusWindow(OperationDirection),
|
||||
@@ -92,16 +93,14 @@ pub enum SocketMessage {
|
||||
Query(StateQuery),
|
||||
FocusFollowsMouse(FocusFollowsMouseImplementation, bool),
|
||||
ToggleFocusFollowsMouse(FocusFollowsMouseImplementation),
|
||||
AddSubscriber(String),
|
||||
RemoveSubscriber(String),
|
||||
}
|
||||
|
||||
impl SocketMessage {
|
||||
pub fn as_bytes(&self) -> Result<Vec<u8>> {
|
||||
Ok(serde_json::to_string(self)?.as_bytes().to_vec())
|
||||
}
|
||||
|
||||
pub fn from_bytes(bytes: &[u8]) -> Result<Self> {
|
||||
Ok(serde_json::from_slice(bytes)?)
|
||||
}
|
||||
}
|
||||
|
||||
impl FromStr for SocketMessage {
|
||||
|
||||
Reference in New Issue
Block a user