Skip to content

Commit

Permalink
fix(cli): add monitor-information command
Browse files Browse the repository at this point in the history
This commit adds a new monitor-information command to make it easier for
people to find the values they need to use the display_index_preferences
configuration option.

re #860
  • Loading branch information
LGUG2Z committed Jun 1, 2024
1 parent 1320b74 commit aa24c41
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 15 deletions.
5 changes: 3 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 7 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@ members = [
]

[workspace.dependencies]
windows-interface = { version = "0.53" }
windows-implement = { version = "0.53" }
dunce = "1"
dirs = "5"
color-eyre = "0.6"
serde_json = { package = "serde_json_lenient", version = "0.1" }
sysinfo = "0.30"
dirs = "5"
dunce = "1"
serde = { version = "1", features = ["derive"] }
serde_json = { package = "serde_json_lenient", version = "0.2" }
sysinfo = "0.30"
uds_windows = "1"
win32-display-data = { git = "https://github.com/LGUG2Z/win32-display-data", rev = "2a0f7166da154880a1750b91829b1186d9c6a00c" }
windows-implement = { version = "0.53" }
windows-interface = { version = "0.53" }

[workspace.dependencies.windows]
version = "0.54"
Expand Down
1 change: 1 addition & 0 deletions komorebi-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ pub enum SocketMessage {
State,
GlobalState,
VisibleWindows,
MonitorInformation,
Query(StateQuery),
FocusFollowsMouse(FocusFollowsMouseImplementation, bool),
ToggleFocusFollowsMouse(FocusFollowsMouseImplementation),
Expand Down
3 changes: 1 addition & 2 deletions komorebi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,12 @@ tracing-subscriber = { version = "0.3", features = ["env-filter"] }
uds_windows = "1"
which = "6"
widestring = "1"
win32-display-data = { workspace = true }
windows = { workspace = true }
windows-implement = { workspace = true }
windows-interface = { workspace = true }
winput = "0.2"
winreg = "0.52"

win32-display-data = { git = "https://github.com/LGUG2Z/win32-display-data", rev = "2a0f7166da154880a1750b91829b1186d9c6a00c" }

[features]
deadlock_detection = ["parking_lot/deadlock_detection"]
17 changes: 12 additions & 5 deletions komorebi/src/process_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -797,15 +797,22 @@ impl WindowManager {
}
}

let visible_windows_state =
match serde_json::to_string_pretty(&monitor_visible_windows) {
Ok(state) => state,
Err(error) => error.to_string(),
};
let visible_windows_state = serde_json::to_string_pretty(&monitor_visible_windows)
.unwrap_or_else(|error| error.to_string());

reply.write_all(visible_windows_state.as_bytes())?;
}
SocketMessage::MonitorInformation => {
let mut monitors = HashMap::new();
for monitor in self.monitors() {
monitors.insert(monitor.device_id(), monitor.size());
}

let monitors_state = serde_json::to_string_pretty(&monitors)
.unwrap_or_else(|error| error.to_string());

reply.write_all(monitors_state.as_bytes())?;
}
SocketMessage::Query(query) => {
let response = match query {
StateQuery::FocusedMonitorIndex => self.focused_monitor_idx(),
Expand Down
1 change: 1 addition & 0 deletions komorebic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ sysinfo = { workspace = true }
thiserror = "1"
uds_windows = "1"
which = "6"
win32-display-data = { workspace = true }
windows = { workspace = true }

[build-dependencies]
Expand Down
6 changes: 6 additions & 0 deletions komorebic/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,9 @@ enum SubCommand {
Gui,
/// Show a JSON representation of visible windows
VisibleWindows,
/// Show information about connected monitors
#[clap(alias = "monitor-info")]
MonitorInformation,
/// Query the current window manager state
#[clap(arg_required_else_help = true)]
Query(Query),
Expand Down Expand Up @@ -2144,6 +2147,9 @@ Stop-Process -Name:komorebi -ErrorAction SilentlyContinue
SubCommand::VisibleWindows => {
print_query(&SocketMessage::VisibleWindows.as_bytes()?);
}
SubCommand::MonitorInformation => {
print_query(&SocketMessage::MonitorInformation.as_bytes()?);
}
SubCommand::Query(arg) => {
print_query(&SocketMessage::Query(arg.state_query).as_bytes()?);
}
Expand Down

0 comments on commit aa24c41

Please sign in to comment.