diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml index b60021ed6..5b01766d7 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yaml +++ b/.github/ISSUE_TEMPLATE/bug_report.yaml @@ -39,6 +39,27 @@ body: validations: required: true + - type: textarea + attributes: + label: Config + description: A `whim.config.yaml` that can be used to reproduce the issue. + placeholder: | + # yaml-language-server: $schema=WHIM_PATH\plugins\Whim.Yaml\schema.json + workspaces: + entries: + - name: Workspace 1 + - name: Workspace 2 + - name: Workspace 3 + - name: Workspace 4 + + layout_engines: + entries: + - type: tree + initial_direction: right + render: yaml + validations: + required: false + - type: textarea attributes: label: Environment diff --git a/README.md b/README.md index f2e7709bc..78508d0d0 100644 --- a/README.md +++ b/README.md @@ -1,42 +1,54 @@ -# [Whim](https://dalyisaac.github.io/Whim) +# [Whim](https://dalyisaac.github.io/Whim) 🪟 -Whim is a hackable, pluggable and scriptable dynamic window manager for Windows 10 and 11, built using WinUI 3, .NET, and C# scripting. +Whim is a hackable, pluggable and scriptable dynamic window manager for Windows. -![Whim demo](docs/images/demo.gif) +Whim lets you easily layout your windows in a way that suits your workflow via [keyboard shortcuts](https://dalyisaac.github.io/Whim/configure/core/keybinds.html), dragging windows using your mouse, or plugins including a [command palette](https://dalyisaac.github.io/Whim/configure/plugins/command-palette.html) or [bar](https://dalyisaac.github.io/Whim/configure/plugins/bar.html). -## Installation +## Key Features ✨ + +- **Multiple Layout Engines**: Choose from various [layout engines](https://dalyisaac.github.io/Whim/configure/core/layout-engines.html) to suit your workflow. +- **Simple Configuration**: Use [YAML or JSON](https://dalyisaac.github.io/Whim/configure/yaml-json-configuration.html) for easy setup. +- **Hackable and Pluggable**: Extend Whim with powerful [C# scripts](https://dalyisaac.github.io/Whim/script/scripting.html). +- **Workspace Management**: Manage windows efficiently across multiple [workspaces](https://dalyisaac.github.io/Whim/configure/core/workspaces.html). +- **User-Centric Design**: Full control over your window management. + +> All the power to the user! + +![Whim demo](docs/images/readme.gif) + +## Installation 🛠️ Alpha builds are available on the [releases page](https://github.com/dalyIsaac/Whim/releases) on GitHub. Whim has an [updater plugin](https://dalyisaac.github.io/Whim/docs/plugins/updater.html) to keep you up to date. Installation via package managers is coming in [dalyIsaac/Whim#792](https://github.com/dalyIsaac/Whim/issues/792). -## Why use Whim? +## Why use Whim? 🤔 A window manager is responsible for controlling the layout of windows in your desktop environment. Whim is a [dynamic window manager](https://en.wikipedia.org/wiki/Dynamic_window_manager), where windows are arranged according to different layouts. Whim supports multiple layout engines. Each [workspace](https://dalyisaac.github.io/Whim/docs/customize/workspaces.html) can switch between different layout engines. For example, the `TreeLayoutEngine` allows users to create arbitrary grids of windows during runtime (similar to `i3`), while the `SliceLayoutEngine` fully automates windows placement using a predefined, customizable logic (similar to `Awesome` or `dwm`) . For more, see [Layout Engines](https://dalyisaac.github.io/Whim/docs/customize/layout-engines.html). -Whim is configured using C# scripting - no YAML to be found here. This means you can use the full power of C# to configure Whim. Whim also exposes its API for plugins to use. Accordingly, much of the more custom functionality has been implemented as plugins which users can choose to use or not. +Whim has a simple configuration system that uses [YAML or JSON](https://dalyisaac.github.io/Whim/configure/yaml-json-configuration.html). Whim also has a [C# scripting system](https://dalyisaac.github.io/Whim/script/scripting.html) for more advanced users. This means you can start out with a simple configuration and gradually add more complex functionality, using the full power of C#. Whim exposes its API for plugins to use. Accordingly, much of the more custom functionality has been implemented as plugins which users can choose to use or not. Whim works by sitting on top of Windows' own window manager. It listens to window events and moves windows accordingly. Whim does not use Windows' native "virtual" desktops, as they lack the ability to activate "desktops" independently of monitors. Instead, Whim has [workspaces](https://dalyisaac.github.io/Whim/docs/customize/workspaces.html). To see how Whim compares to other Windows window managers, see [Whim vs. Other Window Managers](https://dalyisaac.github.io/Whim/docs/getting-started/comparison.html). -## Documentation +## Documentation 📖 You can find the Whim documentation at [dalyisaac.github.io/Whim](https://dalyisaac.github.io/Whim). -## Contributing +## Contributing 🤝 Whim is an open-source project and contributions are welcome! For more information, see the [Contributing](https://dalyisaac.github.io/Whim/docs/contribute/guide.html) page. -## Community +## Community 🌐 Whim has a [Discord server](https://discord.gg/gEFq9wr7jb) where you can ask questions, get help, and chat with other users. -## Thanks +## Thanks 🙏 Whim is heavily inspired by the [workspacer](https://github.com/workspacer/workspacer) project - for more, see the [Inspiration](https://dalyisaac.github.io/Whim/getting-started/inspiration.html) page. diff --git a/docs/_includes/plugins/tree-layout-command-palette.md b/docs/_includes/plugins/tree-layout-command-palette.md index afba876f8..c1fa1a855 100644 --- a/docs/_includes/plugins/tree-layout-command-palette.md +++ b/docs/_includes/plugins/tree-layout-command-palette.md @@ -1,4 +1,4 @@ -## Tree Layout Commands +## Tree Layout Commands | Identifier | Title | Keybind | | ------------------------------------------------ | ----------------------------------------------------------------------------------- | ------------------ | diff --git a/docs/configure/core/layout-engines.md b/docs/configure/core/layout-engines.md index e61b47a20..1e0cdf93a 100644 --- a/docs/configure/core/layout-engines.md +++ b/docs/configure/core/layout-engines.md @@ -4,11 +4,12 @@ A "layout engine" or in Whim is responsible for arrang ## Available layout engines -| Engine | TL;DR | -| ----------------- | ------------------------------------------------------------------------ | -| [`focus`](#focus) | One window at a time | -| [`slice`](#slice) | `Awesome`/`dwm`-style dynamic tiling (primary/stack, multi-column, etc.) | -| [`tree`](#tree) | `i3`-style dynamic tiling (arbitrary grids) | +| Engine | TL;DR | +| ----------------------- | ------------------------------------------------------------------------ | +| [`focus`](#focus) | One window at a time | +| [`slice`](#slice) | `Awesome`/`dwm`-style dynamic tiling (primary/stack, multi-column, etc.) | +| [`tree`](#tree) | `i3`-style dynamic tiling (arbitrary grids) | +| [`floating`](#floating) | All windows are free-floating | ## Example Usage @@ -66,7 +67,7 @@ To reorder windows, calling `whim.core.swap_window_in_direction.(left|right|up|d Windows which are not focused are minimized to the taskbar. -![Focus demo](../../images/focus-layout-demo.gif) +![Focus demo](../../images/layout-engines/focus.gif) ## `slice` @@ -90,6 +91,8 @@ Commands for the `slice` layout engine can be found on the [Slice Layout](../plu variant: column ``` +![Column layout demo](../../images/layout-engines/column.gif) + #### Row Layout - **Description**: Creates a row layout, where windows are stacked horizontally. @@ -102,6 +105,8 @@ Commands for the `slice` layout engine can be found on the [Slice Layout](../plu variant: row ``` +![Row layout demo](../../images/layout-engines/row.gif) + #### Primary Stack Layout - **Description**: Creates a primary stack layout, where the first window takes up half the screen, and the remaining windows are stacked vertically on the other half. @@ -114,6 +119,8 @@ Commands for the `slice` layout engine can be found on the [Slice Layout](../plu variant: primary_stack ``` +![Primary stack layout demo](../../images/layout-engines/primary-stack.gif) + #### Multi-Column Stack Layout - **Description**: Creates a multi-column layout with the given number of windows in each column. `[2, 1, 0]` will create a layout with 3 columns, where the first column has 2 windows, the second column has 1 window, and the third column has infinite windows. @@ -129,6 +136,8 @@ Commands for the `slice` layout engine can be found on the [Slice Layout](../plu columns: [2, 1, 0] ``` +![Multi-column stack layout demo](../../images/layout-engines/multi-column-stack.gif) + #### Secondary Primary Stack Layout - **Description**: Creates a three-column layout, where the primary column is in the middle, the secondary column is on the left, and the overflow column is on the right. The middle column takes up 50% of the screen, and the left and right columns take up 25%. @@ -146,7 +155,7 @@ Commands for the `slice` layout engine can be found on the [Slice Layout](../plu secondary_capacity: 2 ``` -![Slice demo](../../images/slice-layout-demo.gif) +![Secondary primary stack demo](../../images/layout-engines/secondary-primary-stack.gif) ## `tree` @@ -161,15 +170,18 @@ layout_engines: initial_direction: right ``` -![Tree demo](../../images/tree-layout-demo.gif) +![Tree demo](../../images/layout-engines/tree.gif) Commands for the `tree` layout engine can be found on the [Tree Layout](../plugins/tree-layout.md#commands) plugin page. -## `FloatingLayoutEngine` +## `floating` -> [!WARNING] -> This is not yet supported by the YAML/JSON configuration. +The `floating` layout engine is a layout that has all windows being free-floating. To have specific windows float within a different layout, see the [Floating Window Plugin](../plugins/floating-window.md). - is a layout that has all windows being free-floating. To have specific windows float within a different layout, see the [Floating Window Plugin](../plugins/floating-window.md). +```yaml +layout_engines: + entries: + - type: floating +``` -![FloatingLayoutEngine demo](../../images/floating-layout-demo.gif) +![Floating layout demo](../../images/layout-engines/floating.gif) diff --git a/docs/configure/core/logging.md b/docs/configure/core/logging.md deleted file mode 100644 index 399020bc3..000000000 --- a/docs/configure/core/logging.md +++ /dev/null @@ -1,3 +0,0 @@ -# Logging - -👷🏗️🚧 diff --git a/docs/configure/core/monitors.md b/docs/configure/core/monitors.md index dcd53bd8e..4341a005f 100644 --- a/docs/configure/core/monitors.md +++ b/docs/configure/core/monitors.md @@ -1,3 +1,5 @@ # Monitors +Customization of your monitor setup is not yet available - sticky workspaces are being tracked in [this GitHub issue](https://github.com/dalyIsaac/Whim/issues/660). + 👷🏗️🚧 diff --git a/docs/configure/core/styling.md b/docs/configure/core/styling.md index dfd612d4b..957d7a326 100644 --- a/docs/configure/core/styling.md +++ b/docs/configure/core/styling.md @@ -1,7 +1,5 @@ # Styling -[!INCLUDE [Styling](../../_includes/core/styling.md)] - ## Backdrops Different Whim windows can support custom backdrops. They will generally be associated with a `backdrop` key in the YAML/JSON configuration. The following backdrops are available: @@ -24,3 +22,7 @@ Different Whim windows can support custom backdrops. They will generally be asso | ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `type` | The type of backdrop to use. | | `always_show_backdrop` | By default, WinUI will disable the backdrop when the window loses focus. Whim overrides this setting. Set this to false to disable the backdrop when the window loses focus. | + +## XAML Styling + +Loading XAML styles via YAML/JSON is being tracked in [this GitHub issue](https://github.com/dalyIsaac/Whim/issues/1064). In the meantime, it is available [via C# scripting](../../script/core/styling.md). diff --git a/docs/configure/plugins/overview.md b/docs/configure/plugins/overview.md index 8c2e4056c..828756cd0 100644 --- a/docs/configure/plugins/overview.md +++ b/docs/configure/plugins/overview.md @@ -1,17 +1,17 @@ # Plugins Overview -Whim is build around plugins. Plugins are loaded as required by Whim based on the configuration. +Whim is built around plugins. They provide additional functionality to Whim, such as a bar, floating windows, or a command palette. Plugins are loaded as required by Whim based on the configuration. -| Plugin | TL;DR | Docs | -| --------------------------- | -------------------------------------------------------------------------------------- | ----------------------------------------------------------- | -| Bar | Adds a configurable bar to the top of each screen | [`plugins.bar`](bar.md) | -| Command Palette | Fuzzy command palette filled with [commands](../core/commands.md) | [`plugins.command_palette`](command-palette.md) | -| Floating Window | Lets windows float outside other layout engines | [`plugins.floating_window`](floating-window.md) | -| Focus | Adds a border around the current window | [`plugins.focus_indicator`](focus-indicator.md) | -| Gaps | Adds gaps between windows | [`plugins.gaps`](gaps.md) | -| Layout Preview | Shows a preview when dragging windows | [`plugins.layout_preview`](layout-preview.md) | -| Slice Layout | Plugin for the [`SliceLayoutEngine`](../core/layout-engines.md#slice) | [`plugins.slice_layout`](slice-layout.md) | -| Tree Layout | Plugin for the [`TreeLayoutEngine`](../core/layout-engines.md#tree) | [`plugins.tree_layout`](tree-layout.md) | -| Tree Layout Bar | Provides a widget for the [Bar](bar.md), for the `TreeLayoutEngine` | [`plugins.bar`](bar.md#tree-layout-widget) | -| Tree Layout Command Palette | Adds `TreeLayoutEngine`-specific commands to the [Command Palette](command-palette.md) | [`plugins.command_palette`](command-palette.md#tree-layout) | -| Updater | Plugin to automatically update Whim | [`plugins.updater`](updater.md) | +| Plugin | TL;DR | Docs | +| --------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------- | +| Bar | Adds a configurable bar to the top of each screen | [`plugins.bar`](bar.md) | +| Command Palette | Fuzzy command palette filled with [commands](../core/commands.md) | [`plugins.command_palette`](command-palette.md) | +| Floating Window | Lets windows float outside other layout engines | [`plugins.floating_window`](floating-window.md) | +| Focus | Adds a border around the current window | [`plugins.focus_indicator`](focus-indicator.md) | +| Gaps | Adds gaps between windows | [`plugins.gaps`](gaps.md) | +| Layout Preview | Shows a preview when dragging windows | [`plugins.layout_preview`](layout-preview.md) | +| Slice Layout | Plugin for the [`SliceLayoutEngine`](../core/layout-engines.md#slice) | [`plugins.slice_layout`](slice-layout.md) | +| Tree Layout | Plugin for the [`TreeLayoutEngine`](../core/layout-engines.md#tree) | [`plugins.tree_layout`](tree-layout.md) | +| Tree Layout Bar | Provides a widget for the [Bar](bar.md), for the `TreeLayoutEngine` | [`plugins.bar`](bar.md#tree-layout-widget) | +| Tree Layout Command Palette | Adds `TreeLayoutEngine`-specific commands to the [Command Palette](command-palette.md) | [`plugins.command_palette`](command-palette.md#tree-layout-commands) | +| Updater | Plugin to automatically check for updates | [`plugins.updater`](updater.md) | diff --git a/docs/configure/toc.yml b/docs/configure/toc.yml index f184529b1..ad92bf7c1 100644 --- a/docs/configure/toc.yml +++ b/docs/configure/toc.yml @@ -10,7 +10,6 @@ items: - href: core/routing.md - href: core/filtering.md - href: core/styling.md - - href: core/logging.md - name: Plugins - href: plugins/overview.md diff --git a/docs/configure/yaml-json-configuration.md b/docs/configure/yaml-json-configuration.md index d832be11e..04fd40cc5 100644 --- a/docs/configure/yaml-json-configuration.md +++ b/docs/configure/yaml-json-configuration.md @@ -1,57 +1,36 @@ -# YAML/JSON Configuration (WIP) +# YAML/JSON Configuration -Whim is in the process of adding YAML configuration support - this is being tracked in [#1009](https://github.com/dalyIsaac/Whim/issues/1009). +Whim can be configured using YAML. During installation, Whim will install [this template](https://github.com/dalyIsaac/Whim/blob/main/src/Whim/Template/whim.config.yaml) to your `.whim` directory. JSON is also supported, in the form of [`whim.config.json`](https://github.com/dalyIsaac/Whim/blob/main/src/Whim/Template/whim.config.csx). -This has been implemented in the `Whim.Yaml` plugin, and may have breaking changes for the lifetime of the GitHub issue. +Integration with C# scripting is also possible - see [YAML/JSON and C# integration](../script/snippets.md#yamljson-and-c-integration). -In the meantime, Whim can be configured fully in C# - see [Scripting](../script/scripting.md) for more information. - -## Setup - -The YAML/JSON configuration is not yet included in the default Whim configuration. - -Add to your `whim.config.csx`: - -```csharp -// ...previous references - -// NOTE: Replace WHIM_PATH with the path to your Whim installation -#r "WHIM_PATH\plugins\Whim.Yaml\Whim.Yaml.dll" - -using System; -// ...usings... -using Whim.Yaml; - -// ... - -void DoConfig(IContext context) -{ - // Make sure to place this at the top of your config - YamlLoader.Load(context, showErrorWindow: false); -} -``` +## Schema -Whim will then look for a `whim.config.yaml` or `whim.config.json` file in the root of your `.whim` directory. If it finds one, it will use that file to configure Whim. +Whim's YAML and JSON configuration is validated using a JSON schema, which provides autocompletion and validation in supported text editors, like Visual Studio Code. -## Schema +![Screenshot of YAML validation in Visual Studio Code](../images/yaml-validation.png) -The schema for the YAML and JSON configuration is available [here](https://raw.githubusercontent.com/dalyIsaac/Whim/main/src/Whim.Yaml/schema.json). This schema will eventually be bundled with the Whim installation. +The schema can be found in your Whim installation at `WHIM_PATH/plugins/Whim.Yaml/schema.json` (replace `WHIM_PATH` with the path to your Whim installation). The latest schema is available [here](https://raw.githubusercontent.com/dalyIsaac/Whim/main/src/Whim.Yaml/schema.json). To use the schema in your YAML file, add the following line at the top of your file: ```yaml -# yaml-language-server: $schema=https://raw.githubusercontent.com/dalyIsaac/Whim/main/src/Whim.Yaml/schema.json +# yaml-language-server: $schema=WHIM_PATH/plugins/Whim.Yaml/schema.json ``` To use the schema in your JSON file, add the following line at the top of your file: ```json { - "$schema": "https://raw.githubusercontent.com/dalyIsaac/Whim/main/src/Whim.Yaml/schema.json", + "$schema": "WHIM_PATH/plugins/Whim.Yaml/schema.json", ... } ``` ## Errors -Your YAML/JSON file will be validated against the schema. If there are any errors, your text editor should show them. Whim will also open a window with any errors. +Whim will make a best effort to load the parts of the configuration that are valid, even if there are errors in other parts of the configuration. Errors will be shown in: + +- your text editor (provided your text editor supports YAML/JSON validation) +- a window that opens when Whim starts +- log files in your `.whim` directory diff --git a/docs/images/demo.gif b/docs/images/demo.gif deleted file mode 100644 index 0a769a16c..000000000 Binary files a/docs/images/demo.gif and /dev/null differ diff --git a/docs/images/focus-layout-demo.gif b/docs/images/focus-layout-demo.gif deleted file mode 100644 index 95077dc9e..000000000 Binary files a/docs/images/focus-layout-demo.gif and /dev/null differ diff --git a/docs/images/floating-layout-demo.gif b/docs/images/layout-engines/column.gif similarity index 51% rename from docs/images/floating-layout-demo.gif rename to docs/images/layout-engines/column.gif index 1fcd02c37..de9f26574 100644 Binary files a/docs/images/floating-layout-demo.gif and b/docs/images/layout-engines/column.gif differ diff --git a/docs/images/layout-engines/floating.gif b/docs/images/layout-engines/floating.gif new file mode 100644 index 000000000..cf57c9bfd Binary files /dev/null and b/docs/images/layout-engines/floating.gif differ diff --git a/docs/images/layout-engines/focus.gif b/docs/images/layout-engines/focus.gif new file mode 100644 index 000000000..1071d7020 Binary files /dev/null and b/docs/images/layout-engines/focus.gif differ diff --git a/docs/images/layout-engines/multi-column-stack.gif b/docs/images/layout-engines/multi-column-stack.gif new file mode 100644 index 000000000..fcc038650 Binary files /dev/null and b/docs/images/layout-engines/multi-column-stack.gif differ diff --git a/docs/images/layout-engines/primary-stack.gif b/docs/images/layout-engines/primary-stack.gif new file mode 100644 index 000000000..35f1c0561 Binary files /dev/null and b/docs/images/layout-engines/primary-stack.gif differ diff --git a/docs/images/layout-engines/row.gif b/docs/images/layout-engines/row.gif new file mode 100644 index 000000000..4ab6c08d8 Binary files /dev/null and b/docs/images/layout-engines/row.gif differ diff --git a/docs/images/slice-layout-demo.gif b/docs/images/layout-engines/secondary-primary-stack.gif similarity index 66% rename from docs/images/slice-layout-demo.gif rename to docs/images/layout-engines/secondary-primary-stack.gif index ced7a64f5..6333244df 100644 Binary files a/docs/images/slice-layout-demo.gif and b/docs/images/layout-engines/secondary-primary-stack.gif differ diff --git a/docs/images/tree-layout-demo.gif b/docs/images/layout-engines/tree.gif similarity index 54% rename from docs/images/tree-layout-demo.gif rename to docs/images/layout-engines/tree.gif index aaa882833..6279419c9 100644 Binary files a/docs/images/tree-layout-demo.gif and b/docs/images/layout-engines/tree.gif differ diff --git a/docs/images/readme.gif b/docs/images/readme.gif new file mode 100644 index 000000000..8319b9bbb Binary files /dev/null and b/docs/images/readme.gif differ diff --git a/docs/images/yaml-validation.png b/docs/images/yaml-validation.png new file mode 100644 index 000000000..f59cb5cd1 Binary files /dev/null and b/docs/images/yaml-validation.png differ diff --git a/docs/index.md b/docs/index.md index bc739f9d6..1099ab9b6 100644 --- a/docs/index.md +++ b/docs/index.md @@ -2,28 +2,50 @@ -> All the power to the user! +Whim is a hackable, pluggable and scriptable dynamic window manager for Windows. + +Whim lets you easily layout your windows in a way that suits your workflow via [keyboard shortcuts](configure/core/keybinds.md), dragging windows using your mouse, or plugins including a [command palette](configure/plugins/command-palette.md) or [bar](configure/plugins/bar.md). + +## Key Features ✨ -Whim is a hackable, pluggable and scriptable dynamic window manager for Windows 10 and 11, built using WinUI 3, .NET, and C# scripting. Whim supports multiple layout engines, workspaces, and plugins. Whim is designed to be highly customizable and extensible, allowing users to create their own layouts, workspaces, and plugins. +- **Multiple Layout Engines**: Choose from various [layout engines](configure/core/layout-engines.md) to suit your workflow. +- **Simple Configuration**: Use [YAML or JSON](configure/yaml-json-configuration.md) for easy setup. +- **Hackable and Pluggable**: Extend Whim with powerful [C# scripts](script/scripting.md). +- **Workspace Management**: Manage windows efficiently across multiple [workspaces](configure/core/workspaces.md). +- **User-Centric Design**: Full control over your window management. -Whim can be configured using YAML, JSON, or C# scripting. +> All the power to the user! -![Whim demo](images/demo.gif) +![Whim demo](images/readme.gif) -## Installation +## Installation 🛠️ Alpha builds are available on the [releases page](https://github.com/dalyIsaac/Whim/releases) on GitHub. Whim has an [updater plugin](configure/plugins/updater.md) to notify you of new releases. Installation via package managers is coming in [dalyIsaac/Whim#792](https://github.com/dalyIsaac/Whim/issues/792). -## Why use Whim? +## Why use Whim? 🤔 A window manager is responsible for controlling the layout of windows in your desktop environment. Whim is a [dynamic window manager](https://en.wikipedia.org/wiki/Dynamic_window_manager), where windows are arranged according to different layouts. Whim supports multiple layout engines. Each [workspace](configure/core/workspaces.md) can switch between different layout engines. For example, the [`TreeLayoutEngine`](configure/core/layout-engines.md#tree) allows users to create arbitrary grids of windows during runtime (similar to `i3`), while the [`SliceLayoutEngine`](configure/core/layout-engines.md#slice) fully automates windows placement using a predefined, customizable logic (similar to `Awesome` or `dwm`) . For more, see [Layout Engines](configure/core/layout-engines.md). -Whim is configured using C# scripting - no YAML to be found here. This means you can use the full power of C# to configure Whim. Whim also exposes its API for plugins to use. Accordingly, much of the more custom functionality has been implemented as plugins which users can choose to use or not. +Whim has a simple configuration system that uses [YAML or JSON](configure/yaml-json-configuration.md). Whim also has a [C# scripting system](script/scripting.md) for more advanced users. This means you can start out with a simple configuration and gradually add more complex functionality, using the full power of C#. Whim exposes its API for plugins to use. Accordingly, much of the more custom functionality has been implemented as plugins which users can choose to use or not. Whim works by sitting on top of Windows' own window manager. It listens to window events and moves windows accordingly. Whim does not use Windows' native "virtual" desktops, as they lack the ability to activate "desktops" independently of monitors. Instead, Whim has [workspaces](configure/core/workspaces.md). To see how Whim compares to other Windows window managers, see [Whim vs. Other Window Managers](intro/comparison.md). + +## Contributing 🤝 + +Whim is an open-source project and contributions are welcome! For more information, see the [Contributing](contribute/guide.md) page. + +## Community 🌐 + +Whim has a [Discord server](https://discord.gg/gEFq9wr7jb) where you can ask questions, get help, and chat with other users. + +## Thanks 🙏 + +Whim is heavily inspired by the [workspacer](https://github.com/workspacer/workspacer) project - for more, see the [Inspiration](intro/inspiration.md) page. + +Thank you to all the contributors to Whim for their help and support! 💖 diff --git a/docs/intro/customize.md b/docs/intro/customize.md index e4c7242c4..19d8424be 100644 --- a/docs/intro/customize.md +++ b/docs/intro/customize.md @@ -1,24 +1,26 @@ # Customizing Whim -## Scripting +Whim can be configured using [YAML/JSON](#yamljson) or [C# scripting](#c-scripting). -When you run Whim for the first time, it will create the `C:\Users\{username}\.whim` directory populated with a [C# script](https://github.com/dalyIsaac/Whim/blob/main/src/Whim/Template/whim.config.csx) and resources. +When you run Whim for the first time, it will create the `C:\Users\{username}\.whim` directory populated with: -`whim.config.csx` is a C# script file, and is reloaded every time Whim starts. On first run, it is populated with a pre-filled example which you can use as a starting point - see the config [here](https://github.com/dalyIsaac/Whim/blob/main/src/Whim/Template/whim.config.csx). +- [`whim.config.yaml`](https://github.com/dalyIsaac/Whim/blob/main/src/Whim/Template/whim.config.yaml) - the YAML configuration file +- [`whim.config.csx`](https://github.com/dalyIsaac/Whim/blob/main/src/Whim/Template/whim.config.csx) - the C# configuration script -The core of the configuration is nested inside a function, which is written in typical C# code. The function takes an parameter. `DoConfig` is the entry point for your config. Prior to calling `DoConfig`, Whim will set up the `IContext` and its constituent parts, which exposes Whim's [API](/api) to be used in the configuration. -**For more, see the [Scripting](../script/scripting.md) page**. +To customize the location of the `.whim` directory, set the `--dir` command-line argument when starting Whim. + +## YAML/JSON -YAML and JSON configuration is in the works - see [#1009](https://github.com/dalyIsaac/Whim/issues/1009) for more information. +Files named `whim.config.yaml` or `whim.config.json` in the `.whim` directory can be used to configure Whim. The configuration file can be used to set up plugins, commands, and keybindings. The configuration file is loaded by the `Whim.Yaml` plugin, which is included with Whim. -## Recommended tooling +`whim.config.yaml` and `whim.config.json` can be edited in any text editor with YAML/JSON support, like [Visual Studio Code](https://code.visualstudio.com/download). -Whim will install a self-contained .NET 8 instance as part of the installation process. To have the best experience while configuring Whim, it's recommended to install the following tools: +**For more, see the [YAML/JSON Configuration](../configure/yaml-json-configuration.md) page**. -- [Visual Studio Code](https://code.visualstudio.com/download) -- [C# Dev Kit](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csdevkit) extension for Visual Studio Code -- [.NET 8 SDK](https://dotnet.microsoft.com/download/dotnet/8.0) for Windows +## C# Scripting -## Script location +`whim.config.csx` is a C# script file, and is reloaded every time Whim starts. On first run, it is populated with a pre-filled example which you can use as a starting point - see the config [here](https://github.com/dalyIsaac/Whim/blob/main/src/Whim/Template/whim.config.csx). + +The core of the configuration is nested inside a function, which is written in typical C# code. The function takes an parameter. `DoConfig` is the entry point for your config. Prior to calling `DoConfig`, Whim will set up the `IContext` and its constituent parts, which exposes Whim's [API](/api) to be used in the configuration. -To customize the location of the `.whim` directory, set the `--dir` CLI argument when starting Whim. +**For more, see the [Scripting](../script/scripting.md) page**. diff --git a/docs/intro/plugins.md b/docs/intro/plugins.md index 623ccfea8..0729b8c71 100644 --- a/docs/intro/plugins.md +++ b/docs/intro/plugins.md @@ -1,23 +1,19 @@ # Plugins -Whim is build around plugins. Plugins are referenced using `#r` and `using` statements at the top of the config file. Each plugin generally has a `Config` class, and a `Plugin` class, and needs to be added to the . For example: +Whim is built around plugins. They provide additional functionality to Whim, such as a bar, floating windows, or a command palette. -```csharp -BarConfig barConfig = new(leftComponents, centerComponents, rightComponents); -BarPlugin barPlugin = new(context, barConfig); -context.PluginManager.AddPlugin(barPlugin); -``` +Plugins can be customized via both YAML/JSON configuration and C# scripting. Plugins are loaded as required by Whim based on the configuration. If a plugin was loaded by the YAML/JSON configuration, it will be loaded automatically and does not need to be added to the `PluginManager` - see [YAML/JSON and C# Integration](../script/snippets.md#yamljson-and-c-integration). -| Plugin | TL;DR | YAML JSON Docs | Docs | -| --------------------------- | ----------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | -| Bar | Adds a configurable bar to the top of each screen | [`plugins.bar`](../configure/plugins/bar.md) | [`Whim.Bar`](../script/plugins/bar.md) | -| Command Palette | Fuzzy command palette filled with [commands](../configure/core/commands.md) | [`plugins.command_palette`](../configure/plugins/command-palette.md) | [`Whim.CommandPalette`](../script/plugins/command-palette.md) | -| Floating Window | Lets windows float outside other layout engines | [`plugins.floating_window`](../configure/plugins/floating-window.md) | [`Whim.FloatingWindow`](../script/plugins/floating-window.md) | -| Focus | Adds a border around the current window | [`plugins.focus_indicator`](../configure/plugins/focus-indicator.md) | [`Whim.FocusIndicator`](../script/plugins/focus-indicator.md) | -| Gaps | Adds gaps between windows | [`plugins.gaps`](../configure/plugins/gaps.md) | [`Whim.Gaps`](../script/plugins/gaps.md) | -| Layout Preview | Shows a preview when dragging windows | [`plugins.layout_preview`](../configure/plugins/layout-preview.md) | [`Whim.LayoutPreview`](../script/plugins/layout-preview.md) | -| Slice Layout | Plugin for the [`SliceLayoutEngine`](../configure/core/layout-engines.md#slice) | [`plugins.slice_layout`](../configure/plugins/slice-layout.md) | [`Whim.SliceLayout`](../script/plugins/slice-layout.md) | -| Tree Layout | Plugin for the [`TreeLayoutEngine`](../configure/core/layout-engines.md#tree) | [`plugins.tree_layout`](../configure/plugins/tree-layout.md) | [`Whim.TreeLayout`](../script/plugins/tree-layout.md) | -| Tree Layout Bar | Provides a widget for the [Bar](../configure/plugins/bar.md), for the `TreeLayoutEngine` | [`plugins.bar`](../configure/plugins/bar.md#tree-layout-widget) | [`Whim.TreeLayoutBar`](../script/plugins/tree-layout-bar.md) | -| Tree Layout Command Palette | Adds `TreeLayoutEngine`-specific commands to the [Command Palette](../configure/plugins/command-palette.md) | [`plugins.command_palette`](../configure/plugins/command-palette.md#tree-layout) | [`Whim.TreeLayoutCommandPalette`](../script/plugins/tree-layout-command-palette.md) | -| Updater | Plugin to automatically update Whim | [`plugins.updater`](../configure/plugins/updater.md) | [`Whim.Updater`](../script/plugins/updater.md) | +| Plugin | TL;DR | YAML JSON Docs | Docs | +| --------------------------- | ----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | +| Bar | Adds a configurable bar to the top of each screen | [`plugins.bar`](../configure/plugins/bar.md) | [`Whim.Bar`](../script/plugins/bar.md) | +| Command Palette | Fuzzy command palette filled with [commands](../configure/core/commands.md) | [`plugins.command_palette`](../configure/plugins/command-palette.md) | [`Whim.CommandPalette`](../script/plugins/command-palette.md) | +| Floating Window | Lets windows float outside other layout engines | [`plugins.floating_window`](../configure/plugins/floating-window.md) | [`Whim.FloatingWindow`](../script/plugins/floating-window.md) | +| Focus | Adds a border around the current window | [`plugins.focus_indicator`](../configure/plugins/focus-indicator.md) | [`Whim.FocusIndicator`](../script/plugins/focus-indicator.md) | +| Gaps | Adds gaps between windows | [`plugins.gaps`](../configure/plugins/gaps.md) | [`Whim.Gaps`](../script/plugins/gaps.md) | +| Layout Preview | Shows a preview when dragging windows | [`plugins.layout_preview`](../configure/plugins/layout-preview.md) | [`Whim.LayoutPreview`](../script/plugins/layout-preview.md) | +| Slice Layout | Plugin for the [`SliceLayoutEngine`](../configure/core/layout-engines.md#slice) | [`plugins.slice_layout`](../configure/plugins/slice-layout.md) | [`Whim.SliceLayout`](../script/plugins/slice-layout.md) | +| Tree Layout | Plugin for the [`TreeLayoutEngine`](../configure/core/layout-engines.md#tree) | [`plugins.tree_layout`](../configure/plugins/tree-layout.md) | [`Whim.TreeLayout`](../script/plugins/tree-layout.md) | +| Tree Layout Bar | Provides a widget for the [Bar](../configure/plugins/bar.md), for the `TreeLayoutEngine` | [`plugins.bar`](../configure/plugins/bar.md#tree-layout-widget) | [`Whim.TreeLayoutBar`](../script/plugins/tree-layout-bar.md) | +| Tree Layout Command Palette | Adds `TreeLayoutEngine`-specific commands to the [Command Palette](../configure/plugins/command-palette.md) | [`plugins.command_palette`](../configure/plugins/command-palette.md#tree-layout-commands) | [`Whim.TreeLayoutCommandPalette`](../script/plugins/tree-layout-command-palette.md) | +| Updater | Plugin to automatically check for updates | [`plugins.updater`](../configure/plugins/updater.md) | [`Whim.Updater`](../script/plugins/updater.md) | diff --git a/docs/intro/toc.yml b/docs/intro/toc.yml index 98a3571fc..4dc6ca188 100644 --- a/docs/intro/toc.yml +++ b/docs/intro/toc.yml @@ -1,7 +1,7 @@ items: - href: ../index.md - - href: comparison.md - href: customize.md - href: plugins.md - href: inspiration.md - href: troubleshooting.md + - href: comparison.md diff --git a/docs/script/core/layout-engines.md b/docs/script/core/layout-engines.md index f626e0b9b..ce4f3934a 100644 --- a/docs/script/core/layout-engines.md +++ b/docs/script/core/layout-engines.md @@ -2,11 +2,12 @@ ## Available layout engines -| Engine | TL;DR | -| ----------------------------------------- | ------------------------------------------------------------------------ | -| [`FocusLayoutEngine`](#focuslayoutengine) | One window at a time | -| [`SliceLayoutEngine`](#slicelayoutengine) | `Awesome`/`dwm`-style dynamic tiling (primary/stack, multi-column, etc.) | -| [`TreeLayoutEngine`](#treelayoutengine) | `i3`-style dynamic tiling (arbitrary grids) | +| Engine | TL;DR | +| ----------------------------------------------- | ------------------------------------------------------------------------ | +| [`FocusLayoutEngine`](#focuslayoutengine) | One window at a time | +| [`SliceLayoutEngine`](#slicelayoutengine) | `Awesome`/`dwm`-style dynamic tiling (primary/stack, multi-column, etc.) | +| [`TreeLayoutEngine`](#treelayoutengine) | `i3`-style dynamic tiling (arbitrary grids) | +| [`FloatingLayoutEngine`](#floatinglayoutengine) | All windows are free-floating | ### `FocusLayoutEngine` @@ -18,7 +19,7 @@ To reorder windows, calling s. Each `IAr The static class contains methods to create a few common layouts: - primary/stack (master/stack) -- multi-column layout +- column layout +- row layout +- multi-column layout, with arbitrary numbers of windows in each column - three-column layout, with the middle column being the primary ```csharp @@ -83,8 +86,6 @@ SliceLayoutPlugin sliceLayoutPlugin = new(context); context.PluginManager.AddPlugin(sliceLayoutPlugin); ``` -![SliceLayoutEngine demo](../../images/slice-layout-demo.gif) - ### `TreeLayoutEngine` is a layout that allows users to create arbitrary grid layouts, similar to `i3`. Unlike [`SliceLayoutEngine`](#slicelayoutengine), windows can can be added in any location at runtime. @@ -96,10 +97,10 @@ TreeLayoutPlugin treeLayoutPlugin = new(context); context.PluginManager.AddPlugin(treeLayoutPlugin); ``` -![TreeLayoutEngine demo](../../images/tree-layout-demo.gif) +![TreeLayoutEngine demo](../../images/layout-engines/tree.gif) ### `FloatingLayoutEngine` is a layout that has all windows being free-floating. To have specific windows float within a different layout, see the [Floating Window Plugin](../plugins/floating-window.md). -![FloatingLayoutEngine demo](../../images/floating-layout-demo.gif) +![FloatingLayoutEngine demo](../../images/layout-engines/floating.gif) diff --git a/docs/script/core/store.md b/docs/script/core/store.md index 435592039..745736cd3 100644 --- a/docs/script/core/store.md +++ b/docs/script/core/store.md @@ -39,7 +39,7 @@ context.CommandManager.Add( ); ``` -For examples on how to interact with the store, see the [Snippets](snippets.md) page. +For examples on how to interact with the store, see the [Snippets](../snippets.md) page. ## Handles and IDs diff --git a/docs/script/core/styling.md b/docs/script/core/styling.md index 39d3ae848..707ca558c 100644 --- a/docs/script/core/styling.md +++ b/docs/script/core/styling.md @@ -1,3 +1,3 @@ # Styling -[!INCLUDE [Styling](../../_includes/core/styling.md)] +[!INCLUDE [Styling](../../_includes/core/styling.md)] diff --git a/docs/script/plugins/overview.md b/docs/script/plugins/overview.md index 74bfd5bdc..9218befab 100644 --- a/docs/script/plugins/overview.md +++ b/docs/script/plugins/overview.md @@ -1,6 +1,6 @@ # Plugins Overview -Whim is build around plugins. Plugins are referenced using `#r` and `using` statements at the top of the config file. Each plugin generally has a `Config` class, and a `Plugin` class, and needs to be added to the . For example: +Whim is built around plugins. Plugins are referenced using `#r` and `using` statements at the top of the config file. Each plugin generally has a `Config` class, and a `Plugin` class, and needs to be added to the . For example: ```csharp BarConfig barConfig = new(leftComponents, centerComponents, rightComponents); @@ -28,4 +28,4 @@ BarPlugin barPlugin = (BarPlugin)context.PluginManager.LoadedPlugins.First(p => | Tree Layout | Plugin for the [`TreeLayoutEngine`](../core/layout-engines.md#treelayoutengine) | [`Whim.TreeLayout`](tree-layout.md) | | Tree Layout Bar | Provides a widget for the [Bar](bar.md), for the `TreeLayoutEngine` | [`Whim.TreeLayoutBar`](tree-layout-bar.md) | | Tree Layout Command Palette | Adds `TreeLayoutEngine`-specific commands to the [Command Palette](command-palette.md) | [`Whim.TreeLayoutCommandPalette`](tree-layout-command-palette.md) | -| Updater | Plugin to automatically update Whim | [`Whim.Updater`](updater.md) | +| Updater | Plugin to automatically check for updates | [`Whim.Updater`](updater.md) | diff --git a/docs/script/scripting.md b/docs/script/scripting.md index e20a38095..23be55ff6 100644 --- a/docs/script/scripting.md +++ b/docs/script/scripting.md @@ -2,7 +2,19 @@ Whim uses the [Microsoft.CodeAnalysis.CSharp](https://learn.microsoft.com/en-us/dotnet/api/microsoft.codeanalysis.csharp) scripting engine to run your `.whim/whim.config.csx` file. -Various snippets can be found on the [Snippets](core/snippets.md) page. +Various snippets can be found on the [Snippets](snippets.md) page. + +## Tooling + +If you plan to customize your Whim configuration using C#, it's recommended to install dedicated C# tooling. + +To get code completion, it's recommended to install the [.NET 8 SDK](https://dotnet.microsoft.com/download/dotnet/8.0) for Windows. Whim will install a self-contained .NET 8 instance as part of the installation process, but installing the SDK will give you access to the full .NET ecosystem. + +The following editors can be used to write C# scripts: + +- [Visual Studio Code](https://code.visualstudio.com/download) with the [C# Dev Kit](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csdevkit) extension +- [Visual Studio](https://visualstudio.microsoft.com/downloads/) +- [Rider](https://www.jetbrains.com/rider/) ## Directives @@ -41,7 +53,3 @@ return DoConfig; `DoConfig` is the entry point for your config. Prior to calling this function, Whim will set up the and its constituent parts. After `DoConfig` is called, Whim will initialize the various managers and plugins and start the main loop. The `DoConfig` function is returned at the end of the script so Whim can call it when it loads. - -### Examples - -The rest of this _Customize_ section documents popular configuration options. A few more elaborate examples can be found in [Snippets](core/snippets.md). diff --git a/docs/script/core/snippets.md b/docs/script/snippets.md similarity index 77% rename from docs/script/core/snippets.md rename to docs/script/snippets.md index 9c1bc2e7a..c02da2a15 100644 --- a/docs/script/core/snippets.md +++ b/docs/script/snippets.md @@ -4,6 +4,39 @@ Potentially useful code snippets. Each of these snippets (apart from the `using` statements) should be added inside the `DoConfig` function in your `whim.config.csx` file. +## YAML/JSON and C# integration + +Add to your `whim.config.csx`: + +```csharp +// ...previous references + +// NOTE: Replace WHIM_PATH with the path to your Whim installation +#r "WHIM_PATH\plugins\Whim.Yaml\Whim.Yaml.dll" + +using System; +using System.Linq; +// ...usings... +using Whim.Yaml; + +// ... + +void DoConfig(IContext context) +{ + // Make sure to place this at the top of your config + YamlLoader.Load(context, showErrorWindow: false); + + // Get the loaded plugins. + CommandPalettePlugin commandPalettePlugin = (CommandPalettePlugin)context.PluginManager.LoadedPlugins.First(p => p.Name == "whim.command_palette"); + TreeLayoutPlugin treeLayoutPlugin = (TreeLayoutPlugin)context.PluginManager.LoadedPlugins.First(p => p.Name == "whim.tree_layout"); + FloatingWindowPlugin floatingWindowPlugin = (FloatingWindowPlugin)context.PluginManager.LoadedPlugins.First(p => p.Name == "whim.floating_window"); +} +``` + +Whim will then look for a `whim.config.yaml` or `whim.config.json` file in the root of your `.whim` directory. If it finds one, it will use that file to configure Whim. + +The names of each plugin can be found in the API documentation. For example, `whim.command_palette` is the of the Command Palette plugin. + ## Minimize a specific window ```csharp diff --git a/docs/script/toc.yml b/docs/script/toc.yml index 25aab8579..a71670269 100644 --- a/docs/script/toc.yml +++ b/docs/script/toc.yml @@ -1,5 +1,6 @@ items: - href: scripting.md + - href: snippets.md - name: Core - href: core/store.md @@ -12,7 +13,6 @@ items: - href: core/filtering.md - href: core/styling.md - href: core/logging.md - - href: core/snippets.md - name: Plugins - href: plugins/overview.md diff --git a/src/Whim/ConfigLoader/ConfigLoader.cs b/src/Whim/ConfigLoader/ConfigLoader.cs index 206962f7f..4168dfda0 100644 --- a/src/Whim/ConfigLoader/ConfigLoader.cs +++ b/src/Whim/ConfigLoader/ConfigLoader.cs @@ -13,16 +13,12 @@ namespace Whim; /// The to operate on. public delegate void DoConfig(IContext context); -internal class ConfigLoader +internal class ConfigLoader(IFileManager fileManager) { - private readonly IFileManager _fileManager; - private readonly string _configFilePath; + private readonly IFileManager _fileManager = fileManager; - public ConfigLoader(IFileManager fileManager) - { - _fileManager = fileManager; - _configFilePath = _fileManager.GetWhimFileDir("whim.config.csx"); - } + private const string _scriptConfigFileName = "whim.config.csx"; + private const string _yamlConfigFileName = "whim.config.yaml"; /// /// Read the given from the assembly's resources and return it as a string. @@ -64,17 +60,20 @@ private static string ReplaceAssemblyPath(string rawConfig, Assembly assembly) /// Creates a config based on the Whim template and saves it to the config file. /// This will throw if any null values are encountered. /// + /// + /// /// - private void CreateConfig(Assembly assembly) + private void CreateConfigFileIfNotExists(Assembly assembly, string filename) { - // Read the template. - string template = ReadFile(assembly, "whim.config.csx"); + string filePath = _fileManager.GetWhimFileDir(filename); + if (_fileManager.FileExists(filePath)) + { + return; + } - // Replace WHIM_PATH with the assembly's path. + string template = ReadFile(assembly, filename); template = ReplaceAssemblyPath(template, assembly); - - // Save the files. - _fileManager.WriteAllText(_configFilePath, template); + _fileManager.WriteAllText(filePath, template); } /// @@ -92,15 +91,12 @@ internal DoConfig LoadConfig() Assembly.GetAssembly(typeof(ConfigLoader)) ?? throw new ConfigLoaderException("Could not find assembly for ConfigLoader"); - // Acquire the Whim config. - if (!_fileManager.FileExists(_configFilePath)) - { - CreateConfig(assembly); - } - - string rawConfig = _fileManager.ReadAllText(_configFilePath); + // Create the config files if they don't exist. + CreateConfigFileIfNotExists(assembly, _scriptConfigFileName); + CreateConfigFileIfNotExists(assembly, _yamlConfigFileName); - // Replace WHIM_CONFIG with assembly's path. + // Read the raw config file. + string rawConfig = _fileManager.ReadAllText(_fileManager.GetWhimFileDir(_scriptConfigFileName)); rawConfig = ReplaceAssemblyPath(rawConfig, assembly); // Evaluate the Whim config. diff --git a/src/Whim/Template/whim.config.csx b/src/Whim/Template/whim.config.csx index 379cc5376..68c0df51c 100644 --- a/src/Whim/Template/whim.config.csx +++ b/src/Whim/Template/whim.config.csx @@ -11,9 +11,12 @@ #r "WHIM_PATH\plugins\Whim.TreeLayout.Bar\Whim.TreeLayout.Bar.dll" #r "WHIM_PATH\plugins\Whim.TreeLayout.CommandPalette\Whim.TreeLayout.CommandPalette.dll" #r "WHIM_PATH\plugins\Whim.Updater\Whim.Updater.dll" +#r "WHIM_PATH\plugins\Whim.Yaml\Whim.Yaml.dll" using System; using System.Collections.Generic; +using System.IO; +using System.Linq; using Microsoft.UI; using Microsoft.UI.Xaml.Markup; using Microsoft.UI.Xaml.Media; @@ -29,6 +32,7 @@ using Whim.TreeLayout; using Whim.TreeLayout.Bar; using Whim.TreeLayout.CommandPalette; using Whim.Updater; +using Whim.Yaml; using Windows.Win32.UI.Input.KeyboardAndMouse; /// @@ -39,88 +43,12 @@ void DoConfig(IContext context) { context.Logger.Config = new LoggerConfig(); - // Bar plugin. - List leftComponents = new() { WorkspaceWidget.CreateComponent() }; - List centerComponents = new() { FocusedWindowWidget.CreateComponent() }; - List rightComponents = - new() - { - BatteryWidget.CreateComponent(), - ActiveLayoutWidget.CreateComponent(), - DateTimeWidget.CreateComponent(), - }; + // YAML config. It's best to load this first so that you can use it in your C# config. + YamlLoader.Load(context); - BarConfig barConfig = new(leftComponents, centerComponents, rightComponents); - BarPlugin barPlugin = new(context, barConfig); - context.PluginManager.AddPlugin(barPlugin); - - // Gap plugin. - GapsConfig gapsConfig = new() { OuterGap = 0, InnerGap = 10 }; - GapsPlugin gapsPlugin = new(context, gapsConfig); - context.PluginManager.AddPlugin(gapsPlugin); - - // Floating window plugin. - FloatingWindowPlugin floatingWindowPlugin = new(context); - context.PluginManager.AddPlugin(floatingWindowPlugin); - - // Focus indicator. - FocusIndicatorConfig focusIndicatorConfig = new() { Color = new SolidColorBrush(Colors.Red), FadeEnabled = true }; - FocusIndicatorPlugin focusIndicatorPlugin = new(context, focusIndicatorConfig); - context.PluginManager.AddPlugin(focusIndicatorPlugin); - - // Command palette. - CommandPaletteConfig commandPaletteConfig = new(context); - CommandPalettePlugin commandPalettePlugin = new(context, commandPaletteConfig); - context.PluginManager.AddPlugin(commandPalettePlugin); - - // Slice layout. - SliceLayoutPlugin sliceLayoutPlugin = new(context); - context.PluginManager.AddPlugin(sliceLayoutPlugin); - - // Tree layout. - TreeLayoutPlugin treeLayoutPlugin = new(context); - context.PluginManager.AddPlugin(treeLayoutPlugin); - - // Tree layout bar. - TreeLayoutBarPlugin treeLayoutBarPlugin = new(treeLayoutPlugin); - context.PluginManager.AddPlugin(treeLayoutBarPlugin); - rightComponents.Add(treeLayoutBarPlugin.CreateComponent()); - - // Tree layout command palette. - TreeLayoutCommandPalettePlugin treeLayoutCommandPalettePlugin = - new(context, treeLayoutPlugin, commandPalettePlugin); - context.PluginManager.AddPlugin(treeLayoutCommandPalettePlugin); - - // Layout preview. - LayoutPreviewPlugin layoutPreviewPlugin = new(context); - context.PluginManager.AddPlugin(layoutPreviewPlugin); - - // Updater. - UpdaterConfig updaterConfig = new() { ReleaseChannel = ReleaseChannel.Alpha }; - UpdaterPlugin updaterPlugin = new(context, updaterConfig); - context.PluginManager.AddPlugin(updaterPlugin); - - // Set up workspaces. - Guid firstWorkspace = context.Store.Dispatch(new AddWorkspaceTransform("1")).Value; - Guid secondWorkspace = context.Store.Dispatch(new AddWorkspaceTransform("2")).Value; - Guid thirdWorkspace = context.Store.Dispatch(new AddWorkspaceTransform("3")).Value; - Guid fourthWorkspace = context.Store.Dispatch(new AddWorkspaceTransform("4")).Value; - - // Set up layout engines. - context.Store.Dispatch( - new SetCreateLayoutEnginesTransform( - () => - new CreateLeafLayoutEngine[] - { - (id) => SliceLayouts.CreateMultiColumnLayout(context, sliceLayoutPlugin, id, 1, 2, 0), - (id) => SliceLayouts.CreatePrimaryStackLayout(context, sliceLayoutPlugin, id), - (id) => SliceLayouts.CreateSecondaryPrimaryLayout(context, sliceLayoutPlugin, id), - (id) => new FocusLayoutEngine(id), - (id) => new TreeLayoutEngine(context, treeLayoutPlugin, id), - (id) => new FloatingLayoutEngine(context, id), - } - ) - ); + // Customize your config in C# here. + // For more, see https://dalyisaac.github.io/Whim/script/scripting.html + // ... } // We return doConfig here so that Whim can call it when it loads. diff --git a/src/Whim/Template/whim.config.yaml b/src/Whim/Template/whim.config.yaml new file mode 100644 index 000000000..d06404ef2 --- /dev/null +++ b/src/Whim/Template/whim.config.yaml @@ -0,0 +1,110 @@ +# yaml-language-server: $schema=WHIM_PATH\plugins\Whim.Yaml\schema.json +workspaces: + entries: + - name: Workspace 1 + - name: Workspace 2 + - name: Workspace 3 + - name: Workspace 4 + +layout_engines: + entries: + - type: tree + initial_direction: right + + - type: slice + variant: + type: row + + - type: slice + variant: + type: column + + - type: slice + variant: + type: primary_stack + + - type: slice + variant: + type: secondary_primary_stack + + - type: slice + variant: + type: multi_column_stack + columns: [2, 1, 0] + + - type: slice + variant: + type: secondary_primary_stack + primary_capacity: 1 + secondary_capacity: 2 + + - type: focus + maximize: false + + - type: floating + +keybinds: + entries: + - command: whim.core.focus_next_monitor + keybind: LCtrl+LShift+LAlt+K + + - command: whim.core.focus_previous_monitor + keybind: LCtrl+LShift+LAlt+J + + unify_key_modifiers: true + +filters: + entries: [] + +routers: + routing_behavior: route_to_launched_workspace + +plugins: + bar: + left_components: + entries: + - type: workspace_widget + + center_components: + entries: + - type: focused_window_widget + shorten_title: true + + right_components: + entries: + - type: battery_widget + - type: active_layout_widget + - type: date_time_widget + format: HH:mm:ss, dd MMM yyyy + - type: tree_layout_widget + + floating_window: + is_enabled: true + + gaps: + is_enabled: true + outer_gap: 10 + inner_gap: 10 + default_outer_delta: 2 + default_inner_delta: 2 + + command_palette: + is_enabled: true + max_height_percent: 40 + max_width_pixels: 800 + y_position_percent: 20 + + focus_indicator: + is_enabled: true + border_size: 2 + is_fade_enabled: true + fade_timeout: 2 + color: red + + layout_preview: + is_enabled: true + + updater: + is_enabled: true + release_channel: alpha + update_frequency: monthly diff --git a/src/Whim/Whim.csproj b/src/Whim/Whim.csproj index 7d6d14b6e..106cd0c25 100644 --- a/src/Whim/Whim.csproj +++ b/src/Whim/Whim.csproj @@ -63,6 +63,7 @@ +