Skip to content

feat: toggle function#452

Open
sufficientpast wants to merge 10 commits into
caelestia-dots:mainfrom
sufficientpast:feat/toggles
Open

feat: toggle function#452
sufficientpast wants to merge 10 commits into
caelestia-dots:mainfrom
sufficientpast:feat/toggles

Conversation

@sufficientpast

Copy link
Copy Markdown
Contributor

adding cli's toggle in lua config

adding licensed json.lua from rxi/json.lua
Comment thread hypr/utils/json.lua
Comment thread hypr/utils/functions.lua
@sufficientpast sufficientpast requested a review from soramanew June 23, 2026 06:46
@sufficientpast

Copy link
Copy Markdown
Contributor Author

ah nvm misclick

@soramanew

Copy link
Copy Markdown
Collaborator

ah nvm misclick

adodead

Comment thread hypr/utils/functions.lua
local is_a_match = true

for key, expected_value in pairs(rule) do
local actual_value = window[key]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This doesn't work for the workspace match since client.workspace is an object not a string

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

image it does and worked for btop how it used to work originally

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

im blind nvm

Comment thread hypr/utils/functions.lua Outdated
Comment thread hypr/utils/functions.lua Outdated
Comment thread hypr/utils/functions.lua Outdated
Comment thread hypr/utils/functions.lua Outdated
Comment thread hypr/utils/functions.lua
Comment thread hypr/utils/functions.lua
Comment on lines +130 to +139
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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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

Comment thread hypr/utils/functions.lua
music = {
spotify = {
enable = true,
match = { { class = "Spotify" }, { initial_title = "Spotify" }, { initial_title = "Spotify Free" } },

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This breaks legacy configs. We want to keep backward compat, so it should still be camelCase

Comment thread hypr/utils/functions.lua

if
not actual_value
or not string.find(tostring(actual_value):lower(), tostring(expected_value):lower(), 1, true)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This should match exactly, not case insensitive

@soramanew soramanew Jun 27, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Or we should make this a regex match if lua has native regex support

edit: it doesn't. case sensitive substring match is fine

Comment thread hypr/utils/functions.lua
sysmon = {
btop = {
enable = true,
match = { { class = "btop", title = "btop", workspace = "special:sysmon" } },

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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

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