Skip to content

Add set_remaps function #10

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

Merged
merged 6 commits into from
Jul 14, 2025
Merged

Conversation

char3210
Copy link
Contributor

@char3210 char3210 commented Jul 8, 2025

This allows changing the remaps without fully reloading the config, which for example allows remaps to be toggled:

local remaps = { -- anything
    ["B"] = "N",
    ["N"] = "M",
    ["M"] = "B",
}

local config = {
    input = {
        remaps = remaps,
        ...
    }
    ...
}

remaps_toggled = true

local toggle_remaps = function()
    remaps_toggled = not remaps_toggled
    if remaps_toggled then
        waywall.set_remaps(remaps)
    else
        waywall.set_remaps({})
    end
    return false
end

config.actions = {
    ["U"] = toggle_remaps,
}

return config

This is probably not the best way to structure the code, I'm open to suggestions.

@char3210
Copy link
Contributor Author

char3210 commented Jul 10, 2025

another interesting option is some sort of apply_config(config) function that reloads the config table. this lets you modify anything you'd want during runtime except maybe experimental.jit

Copy link
Owner

@tesselslate tesselslate left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as expected for me, with some small tweaks (leak fix + style nit) it'll be fine

@@ -101,5 +101,7 @@ struct config *config_create();
void config_destroy(struct config *cfg);
ssize_t config_find_action(struct config *cfg, const struct config_action *action);
int config_load(struct config *cfg, const char *profile);
int parse_remap(const char *src, const char *dst, struct config_remap *remap);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer if these functions are prefixed with config_ if they're public

@tesselslate
Copy link
Owner

another interesting option is some sort of apply_config(config) function that reloads the config table. this lets you modify anything you'd want during runtime except maybe experimental.jit

I think this function probably covers the last of the config options which people would realistically want to change at runtime since most of the other options were already covered but I'm not totally sure. Disabling and enabling the JIT is fine; the config loading code already does it since it has to first execute init.lua before knowing the option's value.

@char3210 char3210 requested a review from tesselslate July 13, 2025 13:39
@tesselslate tesselslate merged commit 7b7f3cd into tesselslate:main Jul 14, 2025
@tesselslate
Copy link
Owner

Thanks for the PR!

@char3210 char3210 deleted the set_remaps branch July 14, 2025 00:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants