Skip to content

Commit

Permalink
feat(cli): add stackbar-mode command
Browse files Browse the repository at this point in the history
This commit adds a new komorebic command "stackbar-mode" to allow users
to change stackbar modes programmatically.
  • Loading branch information
LGUG2Z committed Jan 5, 2025
1 parent ba52dc3 commit c063302
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 4 deletions.
5 changes: 4 additions & 1 deletion docs/cli/check.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
```
Check komorebi configuration and related files for common errors
Usage: komorebic.exe check
Usage: komorebic.exe check [OPTIONS]
Options:
-k, --komorebi-config <KOMOREBI_CONFIG>
Path to a static configuration JSON file
-h, --help
Print help
Expand Down
18 changes: 18 additions & 0 deletions docs/cli/stackbar-mode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# stackbar-mode

```
Set the stackbar mode
Usage: komorebic.exe stackbar-mode <MODE>
Arguments:
<MODE>
Desired stackbar mode
[possible values: always, never, on-stack]
Options:
-h, --help
Print help
```
4 changes: 3 additions & 1 deletion komorebi/src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,9 @@ pub struct SubscribeOptions {
pub filter_state_changes: bool,
}

#[derive(Debug, Copy, Clone, Eq, PartialEq, Display, Serialize, Deserialize, JsonSchema)]
#[derive(
Debug, Copy, Clone, Eq, PartialEq, Display, Serialize, Deserialize, JsonSchema, ValueEnum,
)]
pub enum StackbarMode {
Always,
Never,
Expand Down
1 change: 1 addition & 0 deletions komorebi/src/process_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1662,6 +1662,7 @@ impl WindowManager {
}
SocketMessage::StackbarMode(mode) => {
STACKBAR_MODE.store(mode);
self.retile_all(true)?;
}
SocketMessage::StackbarLabel(label) => {
STACKBAR_LABEL.store(label);
Expand Down
13 changes: 13 additions & 0 deletions komorebic/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,13 @@ struct BorderImplementation {
style: komorebi_client::BorderImplementation,
}

#[derive(Parser)]
struct StackbarMode {
/// Desired stackbar mode
#[clap(value_enum)]
mode: komorebi_client::StackbarMode,
}

#[derive(Parser)]
struct Animation {
#[clap(value_enum)]
Expand Down Expand Up @@ -1368,6 +1375,9 @@ enum SubCommand {
/// Set the border implementation
#[clap(arg_required_else_help = true)]
BorderImplementation(BorderImplementation),
/// Set the stackbar mode
#[clap(arg_required_else_help = true)]
StackbarMode(StackbarMode),
/// Enable or disable transparency for unfocused windows
#[clap(arg_required_else_help = true)]
Transparency(Transparency),
Expand Down Expand Up @@ -2785,6 +2795,9 @@ if (Get-Command Get-CimInstance -ErrorAction SilentlyContinue) {
SubCommand::BorderImplementation(arg) => {
send_message(&SocketMessage::BorderImplementation(arg.style))?;
}
SubCommand::StackbarMode(arg) => {
send_message(&SocketMessage::StackbarMode(arg.mode))?;
}
SubCommand::Transparency(arg) => {
send_message(&SocketMessage::Transparency(arg.boolean_state.into()))?;
}
Expand Down
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ nav:
- cli/border-offset.md
- cli/border-style.md
- cli/border-implementation.md
- cli/stackbar-mode.md
- cli/transparency.md
- cli/transparency-alpha.md
- cli/toggle-transparency.md
Expand Down
2 changes: 1 addition & 1 deletion schema.bar.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "KomobarConfig",
"description": "The `komorebi.bar.json` configuration file reference for `v0.1.32`",
"description": "The `komorebi.bar.json` configuration file reference for `v0.1.33`",
"type": "object",
"required": [
"left_widgets",
Expand Down
11 changes: 10 additions & 1 deletion schema.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "StaticConfig",
"description": "The `komorebi.json` static configuration file reference for `v0.1.32`",
"description": "The `komorebi.json` static configuration file reference for `v0.1.33`",
"type": "object",
"properties": {
"animation": {
Expand Down Expand Up @@ -1227,6 +1227,15 @@
"RightMainVerticalStack"
]
},
"layout_flip": {
"description": "Specify an axis on which to flip the selected layout (default: None)",
"type": "string",
"enum": [
"Horizontal",
"Vertical",
"HorizontalAndVertical"
]
},
"layout_rules": {
"description": "Layout rules (default: None)",
"type": "object",
Expand Down

0 comments on commit c063302

Please sign in to comment.