Skip to content

Conversation

@auregosu
Copy link

this adds support for the syntax @color / 50%; and #123456 / 50% to override the alpha of a given color.

  • extended grammar rules for t_property_element and t_property_color
  • added gboolean member to link union to differentiate modified links from normal links
  • added definition of rofi_theme_resolve_modified_link()
  • added implementation of modified link resolving in rofi_theme_parse_process_links_int()

#2200

| T_COLOR {
| T_COLOR t_property_color_opt_alpha_ws {
$$ = $1;
$$.alpha = $2;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This overrides the alpha that is (possibly) already set.

maybe a *= instead of =?

Copy link
Author

Choose a reason for hiding this comment

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

i made it analogous to the already existing behavior for named colors on line 1019:

| T_COLOR_NAME t_property_color_opt_alpha_ws {
    $$ = $1;
    $$.alpha = $2;
}

it's probably fine to leave it this way.

if (pv->value.link.ref == NULL) {
rofi_theme_resolve_modified_link(pv);
if (pv->value.link.ref) {
ThemeColor referenced_color = pv->value.link.ref->value.color;
Copy link
Collaborator

Choose a reason for hiding this comment

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

is it guaranteed that the 'link' points to a color?

Copy link
Author

Choose a reason for hiding this comment

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

i'll add a check for the type of pv->value.link.ref on line 1598. should there be a warning if it's otherwise?

Copy link
Collaborator

Choose a reason for hiding this comment

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

A g_debug should be fine and the color should not be set.
(I think this is normal behaviour if you try to set color to f.e. a boolean.. the color is not set, and 'Theme entry: ... unset" is printed in debug.)

@auregosu auregosu force-pushed the next branch 2 times, most recently from b0e758e to 81ab7f9 Compare September 24, 2025 17:46
this adds support for the syntax `@color / 50%;` and `#123456 / 50%` to
override the alpha of a given color.
- extended grammar rules for `t_property_element` and `t_property_color`
- added `gboolean` member to link `union` to differentiate modified
  links from normal links
- added definition of `rofi_theme_resolve_modified_link()`
- added implementation of modified link resolving in
  `rofi_theme_parse_process_links_int()`
@auregosu
Copy link
Author

sorry for force pushing yet again. i corrected the alpha overriding of hex colors so it only happens when t_property_color_opt_alpha_ws is set. i also fixed a naive mix-up of string assignment and copying that lead to other errors.

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