Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compositor Configuration: AvConfig macro #46

Closed
Sammy99jsp opened this issue Sep 6, 2022 · 0 comments · Fixed by #53
Closed

Compositor Configuration: AvConfig macro #46

Sammy99jsp opened this issue Sep 6, 2022 · 0 comments · Fixed by #53
Assignees
Labels
configuration enhancement New feature or request

Comments

@Sammy99jsp
Copy link
Member

Sammy99jsp commented Sep 6, 2022

Use a macro to declare Configuration entries:

#[AvConfig({
    // Example config macro from #23 
    "Change focus to the nth window in the taskbar."
    window(d)       => (Super+{d}),
})]
pub struct Keybinds;

This would automatically generate a struct to represent the raw values of this section,
which serde-json can then parse.

Additionally, it could add some additional parsing unitl we reach the section's final struct.

impl ConfigurationSection for Keybinds {
    type Raw = HashMap<String, Any>;
    
    fn parse(...) {
        /* .  .  . */
    }
}

This macro would then generate a default config file (from the source itself).

Additionally, this macro could also export a JSON Schema upon compile, which can then be linked with CI to be put somewhere (e.g. https://files.avdanos.org/compositor/schema.json).

Proposed Syntax

The first parameter in the macro contains the config item declarations.

A single item

Each item declaration contains:

  • a description
  • an identifier
  • a default value
{
    "An example item"
    identifier() => "Hello World"
}

Support for config 'macros'

Custom key shortcut syntax:

{
    "Close active window"
    closeWindow() => (Alt+F4),

    "Switch to workspace `d`"
    workspace(d) => (Ctrl+Logo+{d}),
}
@Sammy99jsp Sammy99jsp added enhancement New feature or request configuration labels Sep 6, 2022
@Sammy99jsp Sammy99jsp self-assigned this Sep 6, 2022
@Sammy99jsp Sammy99jsp linked a pull request Sep 10, 2022 that will close this issue
@ghost ghost closed this as completed in #53 Sep 10, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
configuration enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant