mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-05-07 11:23:33 +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:
15
README.md
15
README.md
@@ -276,8 +276,8 @@ start Start komorebi.exe as a background process
|
||||
stop Stop the komorebi.exe process and restore all hidden windows
|
||||
state Show a JSON representation of the current window manager state
|
||||
query Query the current window manager state
|
||||
add-subscriber Subscribe to all komorebi events on a named pipe
|
||||
remove-subscriber Subscribe to all komorebi events on a named pipe
|
||||
subscribe Subscribe to komorebi events
|
||||
unsubscribe Unsubscribe from komorebi events
|
||||
log Tail komorebi.exe's process logs (cancel with Ctrl-C)
|
||||
quick-save Quicksave the current 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:
|
||||
|
||||
```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
|
||||
exists, `komorebi` will start pushing JSON data of successfully handled events and messages:
|
||||
Note that you do not have to incldue the full path of the named pipe, just the name.
|
||||
|
||||
If the named pipe exists, `komorebi` will start pushing JSON data of successfully handled events and messages:
|
||||
|
||||
```json lines
|
||||
{"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
|
||||
notification types, refer to the enum variants of `WindowManagerEvent` in `komorebi` and `SocketMessage`
|
||||
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
|
||||
}
|
||||
|
||||
AddSubscriber(named_pipe) {
|
||||
Run, komorebic.exe add-subscriber %named_pipe%, , Hide
|
||||
Subscribe(named_pipe) {
|
||||
Run, komorebic.exe subscribe %named_pipe%, , Hide
|
||||
}
|
||||
|
||||
RemoveSubscriber(named_pipe) {
|
||||
Run, komorebic.exe remove-subscriber %named_pipe%, , Hide
|
||||
Unsubscribe(named_pipe) {
|
||||
Run, komorebic.exe unsubscribe %named_pipe%, , Hide
|
||||
}
|
||||
|
||||
Log() {
|
||||
|
||||
@@ -315,14 +315,14 @@ struct LoadCustomLayout {
|
||||
}
|
||||
|
||||
#[derive(Clap, AhkFunction)]
|
||||
struct AddSubscriber {
|
||||
/// Name of the pipe to send notifications to (without "\\.\pipe\" prepended)
|
||||
struct Subscribe {
|
||||
/// Name of the pipe to send event notifications to (without "\\.\pipe\" prepended)
|
||||
named_pipe: String,
|
||||
}
|
||||
|
||||
#[derive(Clap, AhkFunction)]
|
||||
struct RemoveSubscriber {
|
||||
/// Name of the pipe to stop sending notifications to (without "\\.\pipe\" prepended)
|
||||
struct Unsubscribe {
|
||||
/// Name of the pipe to stop sending event notifications to (without "\\.\pipe\" prepended)
|
||||
named_pipe: String,
|
||||
}
|
||||
|
||||
@@ -344,12 +344,12 @@ enum SubCommand {
|
||||
/// Query the current window manager state
|
||||
#[clap(setting = AppSettings::ArgRequiredElseHelp)]
|
||||
Query(Query),
|
||||
/// Subscribe to all komorebi events on a named pipe
|
||||
/// Subscribe to komorebi events
|
||||
#[clap(setting = AppSettings::ArgRequiredElseHelp)]
|
||||
AddSubscriber(AddSubscriber),
|
||||
/// Subscribe to all komorebi events on a named pipe
|
||||
Subscribe(Subscribe),
|
||||
/// Unsubscribe from komorebi events
|
||||
#[clap(setting = AppSettings::ArgRequiredElseHelp)]
|
||||
RemoveSubscriber(RemoveSubscriber),
|
||||
Unsubscribe(Unsubscribe),
|
||||
/// Tail komorebi.exe's process logs (cancel with Ctrl-C)
|
||||
Log,
|
||||
/// Quicksave the current resize layout dimensions
|
||||
@@ -913,10 +913,10 @@ fn main() -> Result<()> {
|
||||
SubCommand::Load(arg) => {
|
||||
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()?)?;
|
||||
}
|
||||
SubCommand::RemoveSubscriber(arg) => {
|
||||
SubCommand::Unsubscribe(arg) => {
|
||||
send_message(&*SocketMessage::RemoveSubscriber(arg.named_pipe).as_bytes()?)?;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user