feat: toggle function#452
Conversation
Thanks @e-Zephyr and danny more oopsies
|
ah nvm misclick |
| local is_a_match = true | ||
|
|
||
| for key, expected_value in pairs(rule) do | ||
| local actual_value = window[key] |
There was a problem hiding this comment.
This doesn't work for the workspace match since client.workspace is an object not a string
There was a problem hiding this comment.
im blind nvm
| if user_file then | ||
| local content = user_file:read("*a") | ||
| user_file:close() | ||
| local recognized, user_conf = pcall(json.decode, content) | ||
| if not recognized or type(user_conf) ~= "table" then | ||
| hl.exec_cmd("caelestia shell toaster error 'Error' 'check your cli.json again BAKA BAKA' info") | ||
| end | ||
| local user_config = (recognized and type(user_conf) == "table") and user_conf.toggles or {} | ||
| merge(default_config, user_config) | ||
| end |
There was a problem hiding this comment.
The config is read once and not reloaded per toggle, compared to the CLI. If we could get a file watcher in here or something it would work better, but I don't think we can, so just reload it per call would be better ig
| music = { | ||
| spotify = { | ||
| enable = true, | ||
| match = { { class = "Spotify" }, { initial_title = "Spotify" }, { initial_title = "Spotify Free" } }, |
There was a problem hiding this comment.
This breaks legacy configs. We want to keep backward compat, so it should still be camelCase
|
|
||
| if | ||
| not actual_value | ||
| or not string.find(tostring(actual_value):lower(), tostring(expected_value):lower(), 1, true) |
There was a problem hiding this comment.
This should match exactly, not case insensitive
There was a problem hiding this comment.
Or we should make this a regex match if lua has native regex support
edit: it doesn't. case sensitive substring match is fine
| sysmon = { | ||
| btop = { | ||
| enable = true, | ||
| match = { { class = "btop", title = "btop", workspace = "special:sysmon" } }, |
There was a problem hiding this comment.
The workspace rule only works cause the workspace object tostring converts to its name so the substring matches. ig this works, but kinda unclear imo. Also if hyprland changes it when we are screwed


adding cli's toggle in lua config