Add support for special theme for unfocused outputs#44
Add support for special theme for unfocused outputs#44bpeetz wants to merge 9 commits intoMaxVerevkin:masterfrom
Conversation
|
I guess another approach (more flexible) is to allow separate theming of unfocused outputs? I think I would prefer that. |
|
So a additional |
Probably a new function
Yep. In config this may look like [theme.pallet]
background = "#282828ff"
color = "#ffffffff"
separator = "#9a8a62ff"
tag_fg = "#d79921ff"
tag_bg = "#282828ff"
tag_focused_fg = "#1d2021ff"
tag_focused_bg = "#689d68ff"
tag_urgent_fg = "#282828ff"
tag_urgent_bg = "#cc241dff"
tag_inactive_fg = "#d79921ff"
tag_inactive_bg = "#282828ff"
[theme.unfocused_output]
tag_focused_fg = "..."
tag_focused_bg = "..."struct Config {
theme: Theme,
// ...
}
struct Theme {
pallet: Pallet,
unfocused_output: Pallet, // inherits from `pallet`
}
struct Pallet {
background: Option<String>,
color: Option<String>,
// ...
} |
semi_focused tags|
Do you see another way to implement inheriting without having to duplicate the |
I use multiple outputs, and as such often need to remember which output is currently focused. Fortunately, river tells us which output is currently in focus. Therefore, we can track this in river's info provider, and then use this value to decide which theme to use when drawing the bar. For users that do not need or want this extra differentiation, setting the `[theme.palette]` values, will result in the previous behaviour as the `[theme.unfocused_palette]` will inherit them if not set. By default, that is with `[theme.palette]` unset, we will use a darker white for the `unfocused_palette`'s foreground, to signify that this output is unfocused. I am not familiar enough with niri or hyprland to know if they can support something like this too. As such, both of their information providers do not override the default `is_output_focused` method. In the future moving even more values to the themes might be a viable approach (i.e., the font), but with the current values most workflows should be possible (e.g., hiding inactive tags on the unfocused output, whilst showing them on the focused one or simply setting darker colours).
The `Display` impl on anyhows's errors will just show the topmost error. But the user is probably interested in what exactly was wrong with their config, not only that it was wrong. So we now simply print the full error to stderr, which will include a nice description of what serde expected.
The current implementation looks good to me :) |
|
The readme needs to be updated. |
|
Also I would prefer to somehow keep the old configuration working for now and not break the existing configs. |
Previously, someone might be surprised at what the `pallet` actually themes. Naming them `focused` and `unfocused` makes their theming target clear.
If `i3bar-river` can read the old configuration, it should also be able to print the new config, to ease migrating to it.
Having the config in a separate file, facilitates copying and editing, and it can be used to directly run `i3bar-river` with that config (i.e., `--config ./contrib/default_config.toml`)
I'm not so sure, that `g_warning!` is the correct way to do this (other code simply uses a `eprintln!`, but that seemed to easy to overlook.)
|
As mentioned in the commit message, I'm not so sure that the (Oh, CI seems to be dead?) |
…focus change
This was previously removed, in favour of only re-drawing the bar, but
is actually needed, as otherwise the different colours for the tags
(`tag_{,focused,...}_{fg,bg}`) don't take effect at all.
I think, that a better option, would be to simply allow redrawing the
tags, but avoiding re-calculating them.
I use multiple outputs, and as such often need to remember which output is currently focused.
Fortunately, river tells us which output is currently in focus.
Therefore, we can track this in river's info provider, and then use this value to decide which theme to use when drawing the bar.
For users that do not need or want this extra differentiation, setting the
[theme.palette]values, will result in the previous behaviour as the[theme.unfocused_palette]will inherit them if not set.By default, that is with
[theme.palette]unset, we will use a darker white for theunfocused_palette's foreground, to signify that this output is unfocused.I am not familiar enough with niri or hyprland to know if they can support something like this too.
As such, both of their information providers do not override the default
is_output_focusedmethod.In the future moving even more values to the themes might be a viable approach (i.e., the font), but with the current values most workflows should be possible (e.g., hiding inactive tags on the unfocused output, whilst showing them on the focused one or simply setting darker colours).