mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-04-17 22:39:46 +02:00
feat(config): add static json loader and whkd flag
This commit is an implementation of a static JSON configuration loader. An example komorebi.json configuration file has been added. The application-specific configurations can be loaded directly from a file, and workspace configuration can be defined declaratively in the JSON. Individual rules etc. can also be added directly in the static configuration as one-offs. A JSONSchema can be generated using komorebic's static-config-schema command. This should be added to something like SchemaStore later. Loading from static configuration is significantly faster on startup, as the lock does not have to be reacquired for every command that is sent over the socket. When loading configuration from a static JSON file, a hotwatch instance will automatically be created to listen to file changes and apply any updates to both the global and window manager configuration state. A new --whkd flag has been added to the komorebic start command to optionally start whkd in a background process. A new komorebic command 'generate-static-config' has been added to help existing users migrate to a static JSON config file. Currently, custom layout file path information can not be automatically populated in the output of this command and must be added manually by the user if required. A new komorebic command 'fetch-asc' has been added to help users update to the latest version of the application-specific configurations in-place. resolve #427
This commit is contained in:
@@ -78,7 +78,7 @@ pub struct ApplicationConfiguration {
|
||||
pub struct ApplicationConfigurationGenerator;
|
||||
|
||||
impl ApplicationConfigurationGenerator {
|
||||
fn load(content: &str) -> Result<Vec<ApplicationConfiguration>> {
|
||||
pub fn load(content: &str) -> Result<Vec<ApplicationConfiguration>> {
|
||||
Ok(serde_yaml::from_str(content)?)
|
||||
}
|
||||
|
||||
|
||||
@@ -118,6 +118,7 @@ pub enum SocketMessage {
|
||||
ClearNamedWorkspaceLayoutRules(String),
|
||||
// Configuration
|
||||
ReloadConfiguration,
|
||||
ReloadStaticConfiguration(PathBuf),
|
||||
WatchConfiguration(bool),
|
||||
CompleteConfiguration,
|
||||
AltFocusHack(bool),
|
||||
@@ -151,6 +152,8 @@ pub enum SocketMessage {
|
||||
RemoveSubscriber(String),
|
||||
NotificationSchema,
|
||||
SocketSchema,
|
||||
StaticConfigSchema,
|
||||
GenerateStaticConfig,
|
||||
}
|
||||
|
||||
impl SocketMessage {
|
||||
@@ -192,10 +195,12 @@ pub enum StateQuery {
|
||||
Copy, Clone, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum, JsonSchema,
|
||||
)]
|
||||
#[strum(serialize_all = "snake_case")]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum ApplicationIdentifier {
|
||||
#[serde(alias = "exe")]
|
||||
Exe,
|
||||
#[serde(alias = "class")]
|
||||
Class,
|
||||
#[serde(alias = "title")]
|
||||
Title,
|
||||
}
|
||||
|
||||
@@ -204,7 +209,9 @@ pub enum ApplicationIdentifier {
|
||||
)]
|
||||
#[strum(serialize_all = "snake_case")]
|
||||
pub enum FocusFollowsMouseImplementation {
|
||||
/// A custom FFM implementation (slightly more CPU-intensive)
|
||||
Komorebi,
|
||||
/// The native (legacy) Windows FFM implementation
|
||||
Windows,
|
||||
}
|
||||
|
||||
@@ -213,7 +220,9 @@ pub enum FocusFollowsMouseImplementation {
|
||||
)]
|
||||
#[strum(serialize_all = "snake_case")]
|
||||
pub enum WindowContainerBehaviour {
|
||||
/// Create a new container for each new window
|
||||
Create,
|
||||
/// Append new windows to the focused window container
|
||||
Append,
|
||||
}
|
||||
|
||||
@@ -222,7 +231,9 @@ pub enum WindowContainerBehaviour {
|
||||
)]
|
||||
#[strum(serialize_all = "snake_case")]
|
||||
pub enum MoveBehaviour {
|
||||
/// Swap the window container with the window container at the edge of the adjacent monitor
|
||||
Swap,
|
||||
/// Insert the window container into the focused workspace on the adjacent monitor
|
||||
Insert,
|
||||
}
|
||||
|
||||
@@ -231,8 +242,11 @@ pub enum MoveBehaviour {
|
||||
)]
|
||||
#[strum(serialize_all = "snake_case")]
|
||||
pub enum HidingBehaviour {
|
||||
/// Use the SW_HIDE flag to hide windows when switching workspaces (has issues with Electron apps)
|
||||
Hide,
|
||||
/// Use the SW_MINIMIZE flag to hide windows when switching workspaces (has issues with frequent workspace switching)
|
||||
Minimize,
|
||||
/// Use the undocumented SetCloak Win32 function to hide windows when switching workspaces (has foregrounding issues)
|
||||
Cloak,
|
||||
}
|
||||
|
||||
@@ -241,7 +255,9 @@ pub enum HidingBehaviour {
|
||||
)]
|
||||
#[strum(serialize_all = "snake_case")]
|
||||
pub enum OperationBehaviour {
|
||||
/// Process komorebic commands on temporarily unmanaged/floated windows
|
||||
Op,
|
||||
/// Ignore komorebic commands on temporarily unmanaged/floated windows
|
||||
NoOp,
|
||||
}
|
||||
|
||||
|
||||
@@ -5,9 +5,13 @@ use windows::Win32::Foundation::RECT;
|
||||
|
||||
#[derive(Debug, Default, Clone, Copy, Serialize, Deserialize, Eq, PartialEq, JsonSchema)]
|
||||
pub struct Rect {
|
||||
/// The left point in a Win32 Rect
|
||||
pub left: i32,
|
||||
/// The top point in a Win32 Rect
|
||||
pub top: i32,
|
||||
/// The right point in a Win32 Rect
|
||||
pub right: i32,
|
||||
/// The bottom point in a Win32 Rect
|
||||
pub bottom: i32,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user