mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-07-08 05:55:09 +02:00
refactor(subscriptions): ensure consistent naming
This commit renames add-subscriber and remove-subscriber to subscribe and unsubscribe for more semantic consistency in command names, as well as improving and fixing the cli documentation for these commands. @denBot's example of how to create named pipes and subscribe to events has also been added to the readme.
This commit is contained in:
@@ -276,8 +276,8 @@ start Start komorebi.exe as a background process
|
|||||||
stop Stop the komorebi.exe process and restore all hidden windows
|
stop Stop the komorebi.exe process and restore all hidden windows
|
||||||
state Show a JSON representation of the current window manager state
|
state Show a JSON representation of the current window manager state
|
||||||
query Query the current window manager state
|
query Query the current window manager state
|
||||||
add-subscriber Subscribe to all komorebi events on a named pipe
|
subscribe Subscribe to komorebi events
|
||||||
remove-subscriber Subscribe to all komorebi events on a named pipe
|
unsubscribe Unsubscribe from komorebi events
|
||||||
log Tail komorebi.exe's process logs (cancel with Ctrl-C)
|
log Tail komorebi.exe's process logs (cancel with Ctrl-C)
|
||||||
quick-save Quicksave the current resize layout dimensions
|
quick-save Quicksave the current resize layout dimensions
|
||||||
quick-load Load the last quicksaved resize layout dimensions
|
quick-load Load the last quicksaved resize layout dimensions
|
||||||
@@ -462,11 +462,12 @@ by `komorebi` using [Named Pipes](https://docs.microsoft.com/en-us/windows/win32
|
|||||||
First, your application must create a named pipe. Once the named pipe has been created, run the following command:
|
First, your application must create a named pipe. Once the named pipe has been created, run the following command:
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
komorebic.exe add-subscriber <your pipe name>
|
komorebic.exe subscribe <your pipe name>
|
||||||
```
|
```
|
||||||
|
|
||||||
Note that you do not have to incldue the full path of the named pipe, just the name. If the named pipe
|
Note that you do not have to incldue the full path of the named pipe, just the name.
|
||||||
exists, `komorebi` will start pushing JSON data of successfully handled events and messages:
|
|
||||||
|
If the named pipe exists, `komorebi` will start pushing JSON data of successfully handled events and messages:
|
||||||
|
|
||||||
```json lines
|
```json lines
|
||||||
{"type":"AddSubscriber","content":"test-pipe"}
|
{"type":"AddSubscriber","content":"test-pipe"}
|
||||||
@@ -484,3 +485,7 @@ exists, `komorebi` will start pushing JSON data of successfully handled events a
|
|||||||
You may then filter on the `type` key to listen to the events that you are interested in. For a full list of possible
|
You may then filter on the `type` key to listen to the events that you are interested in. For a full list of possible
|
||||||
notification types, refer to the enum variants of `WindowManagerEvent` in `komorebi` and `SocketMessage`
|
notification types, refer to the enum variants of `WindowManagerEvent` in `komorebi` and `SocketMessage`
|
||||||
in `komorebi-core`.
|
in `komorebi-core`.
|
||||||
|
|
||||||
|
An example of how to create a named pipe and a subscription to `komorebi`'s handled events in Python
|
||||||
|
by [@denBot](https://github.com/denBot) can be
|
||||||
|
found [here](https://gist.github.com/denBot/4136279812f87819f86d99eba77c1ee0).
|
||||||
|
|||||||
@@ -16,12 +16,12 @@ Query(state_query) {
|
|||||||
Run, komorebic.exe query %state_query%, , Hide
|
Run, komorebic.exe query %state_query%, , Hide
|
||||||
}
|
}
|
||||||
|
|
||||||
AddSubscriber(named_pipe) {
|
Subscribe(named_pipe) {
|
||||||
Run, komorebic.exe add-subscriber %named_pipe%, , Hide
|
Run, komorebic.exe subscribe %named_pipe%, , Hide
|
||||||
}
|
}
|
||||||
|
|
||||||
RemoveSubscriber(named_pipe) {
|
Unsubscribe(named_pipe) {
|
||||||
Run, komorebic.exe remove-subscriber %named_pipe%, , Hide
|
Run, komorebic.exe unsubscribe %named_pipe%, , Hide
|
||||||
}
|
}
|
||||||
|
|
||||||
Log() {
|
Log() {
|
||||||
|
|||||||
+10
-10
@@ -315,14 +315,14 @@ struct LoadCustomLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clap, AhkFunction)]
|
#[derive(Clap, AhkFunction)]
|
||||||
struct AddSubscriber {
|
struct Subscribe {
|
||||||
/// Name of the pipe to send notifications to (without "\\.\pipe\" prepended)
|
/// Name of the pipe to send event notifications to (without "\\.\pipe\" prepended)
|
||||||
named_pipe: String,
|
named_pipe: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clap, AhkFunction)]
|
#[derive(Clap, AhkFunction)]
|
||||||
struct RemoveSubscriber {
|
struct Unsubscribe {
|
||||||
/// Name of the pipe to stop sending notifications to (without "\\.\pipe\" prepended)
|
/// Name of the pipe to stop sending event notifications to (without "\\.\pipe\" prepended)
|
||||||
named_pipe: String,
|
named_pipe: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -344,12 +344,12 @@ enum SubCommand {
|
|||||||
/// Query the current window manager state
|
/// Query the current window manager state
|
||||||
#[clap(setting = AppSettings::ArgRequiredElseHelp)]
|
#[clap(setting = AppSettings::ArgRequiredElseHelp)]
|
||||||
Query(Query),
|
Query(Query),
|
||||||
/// Subscribe to all komorebi events on a named pipe
|
/// Subscribe to komorebi events
|
||||||
#[clap(setting = AppSettings::ArgRequiredElseHelp)]
|
#[clap(setting = AppSettings::ArgRequiredElseHelp)]
|
||||||
AddSubscriber(AddSubscriber),
|
Subscribe(Subscribe),
|
||||||
/// Subscribe to all komorebi events on a named pipe
|
/// Unsubscribe from komorebi events
|
||||||
#[clap(setting = AppSettings::ArgRequiredElseHelp)]
|
#[clap(setting = AppSettings::ArgRequiredElseHelp)]
|
||||||
RemoveSubscriber(RemoveSubscriber),
|
Unsubscribe(Unsubscribe),
|
||||||
/// Tail komorebi.exe's process logs (cancel with Ctrl-C)
|
/// Tail komorebi.exe's process logs (cancel with Ctrl-C)
|
||||||
Log,
|
Log,
|
||||||
/// Quicksave the current resize layout dimensions
|
/// Quicksave the current resize layout dimensions
|
||||||
@@ -913,10 +913,10 @@ fn main() -> Result<()> {
|
|||||||
SubCommand::Load(arg) => {
|
SubCommand::Load(arg) => {
|
||||||
send_message(&*SocketMessage::Load(resolve_windows_path(&arg.path)?).as_bytes()?)?;
|
send_message(&*SocketMessage::Load(resolve_windows_path(&arg.path)?).as_bytes()?)?;
|
||||||
}
|
}
|
||||||
SubCommand::AddSubscriber(arg) => {
|
SubCommand::Subscribe(arg) => {
|
||||||
send_message(&*SocketMessage::AddSubscriber(arg.named_pipe).as_bytes()?)?;
|
send_message(&*SocketMessage::AddSubscriber(arg.named_pipe).as_bytes()?)?;
|
||||||
}
|
}
|
||||||
SubCommand::RemoveSubscriber(arg) => {
|
SubCommand::Unsubscribe(arg) => {
|
||||||
send_message(&*SocketMessage::RemoveSubscriber(arg.named_pipe).as_bytes()?)?;
|
send_message(&*SocketMessage::RemoveSubscriber(arg.named_pipe).as_bytes()?)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user