feat(cli): implement generate-static-config cmd

This commit is contained in:
LGUG2Z committed 2025-09-25 12:41:10 -07:00
1 parent c59e882a2d
commit 8f36549fae
4 files changed
+17 -4

No files matched your search

+1 -1
View File
@@ -406,7 +406,7 @@ pub enum SocketMessage {
NotificationSchema,
SocketSchema,
StaticConfigSchema,
// GenerateStaticConfig,
GenerateStaticConfig,
// DebugWindow(isize),
}
+6
View File
@@ -29,6 +29,7 @@ use crate::monitor::MonitorInformation;
use crate::notify_subscribers;
use crate::state::GlobalState;
use crate::state::State;
use crate::static_config::StaticConfig;
use crate::window::AdhocWindow;
use crate::window_manager::WindowManager;
use crate::workspace::WorkspaceLayer;
@@ -1533,6 +1534,11 @@ impl WindowManager {
SocketMessage::StopIgnoreRestore => {
self.stop(true)?;
}
SocketMessage::GenerateStaticConfig => {
let config = serde_json::to_string_pretty(&StaticConfig::from(&*self))?;
reply.write_all(config.as_bytes())?;
}
}
notify_subscribers(
+5 -1
View File
@@ -258,7 +258,11 @@ impl From<&Workspace> for WorkspaceConfig {
work_area_offset: value.work_area_offset,
apply_window_based_work_area_offset: Some(value.apply_window_based_work_area_offset),
window_container_behaviour: value.window_container_behaviour,
window_container_behaviour_rules: Option::from(window_container_behaviour_rules),
window_container_behaviour_rules: if window_container_behaviour_rules.is_empty() {
None
} else {
Some(window_container_behaviour_rules)
},
float_override: value.float_override,
tile,
layout_flip: value.layout_flip,
+5 -2
View File
@@ -1098,8 +1098,8 @@ enum SubCommand {
SocketSchema,
/// Generate a JSON Schema of the static configuration file
StaticConfigSchema,
// /// Generates a static configuration JSON file based on the current window manager state
// GenerateStaticConfig,
/// Generates a static configuration JSON file based on the current window manager state
GenerateStaticConfig,
// /// Generates the komorebi.lnk shortcut in shell:startup to autostart komorebi
// EnableAutostart(EnableAutostart),
// /// Deletes the komorebi.lnk shortcut in shell:startup to disable autostart
@@ -1773,6 +1773,9 @@ fn main() -> eyre::Result<()> {
SubCommand::UnsubscribeSocket(arg) => {
send_message(&SocketMessage::RemoveSubscriberSocket(arg.socket))?;
}
SubCommand::GenerateStaticConfig => {
print_query(&SocketMessage::GenerateStaticConfig);
}
}
Ok(())