mirror of
https://github.com/JakeStanger/ironbar.git
synced 2026-07-11 08:15:21 +01:00
[GH-ISSUE #1381] proposal: format filters #4627
Labels
No labels
A:Build
A:CI
A:Client
A:Config
A:Core
A:Documentation
A:Documentation
A:IPC
A:Testing
A:UX/UI
blocked
BREAKING CHANGE
duplicate
good first issue
GTK4
help wanted
invalid
M:Battery
M:Battery
M:Bindmode
M:Bluetooth
M:Brightness
M:Cairo
M:Clipboard
M:Clock
M:Clock
M:Custom
M:Focused
M:Keyboard
M:Launcher
M:Menu
M:Music
M:Music
M:Music
M:Network Manager
M:Notifications
M:SysInfo
M:Tray
M:Volume
M:Workspaces
partially resolved
P:Critical
P:High
P:Low
P:Medium
pull-request
T:Bug
T:Bug
T:Core Enhancement
T:Module Enhancement
T:New Module
T:Question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
JakeStanger/ironbar#4627
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @lypwig on GitHub (Feb 17, 2026).
Original GitHub issue: https://github.com/JakeStanger/ironbar/issues/1381
It could be interesting to be able to transform the values provided by some modules in formatting tokens.
For instance, let's suppose I want to show percents with unicode bars (" ▁▂▃▄▅▆▇██").
Percent values are used in several modules, so it will be tedious to write new modules from scratch just to display pretty bars.
I think this problem could be solved by what is called a filter by template engines.
First we define some filters:
... then we use them everywhere we want:
Here, the lua code returns a function that takes a percent value in parameter (ie.
42), and return the formatted value (ie.▅).Some filters could also take a value in parameter, which is sometimes useful (for instance:
{memory_percent|round(2)}), in this case the lua function takes 2 parameters.Built-in filters could be provided for convenience (upper, round, etc).
Since a filter could also return nerd-font icons chars, I think this concept could allow many nice UI customization.
Built-in filters in the Twig template engine for reference: https://twig.symfony.com/doc/3.x/filters/index.html
Edit: Concerning the provided example, if the
rangefilter described in #1388 is builtin, the format value could be{percentage|range(▁,▂,▃,▄,▅,▆,▇,█,█)}, without having to create a custom filter, but this one is still a good example.Edit 2: It might be challenging but it could also be useful to allow to use cairo inside custom filters. For instance in the example above,
barcould be a lua function that takes a percent number in input, and draws a custom gauge inline instead of text.Edit 3: I found Askama, a light template engine written in rust that support filters, which could help here. I actually think that using a template engine for format strings might be a good idea.
@lypwig commented on GitHub (Feb 19, 2026):
I think all this stuff represents a considerable amount of work and might be out of scope of this project, sorry for the inconvenience. Feel free to reopen if necessary.
@JakeStanger commented on GitHub (Feb 19, 2026):
I don't think this needs any external deps, or that this should support cairo (or anything other than
String -> Stringbut I think this does present a very powerful idea that could be used for formatting tokens.@lypwig commented on GitHub (Feb 25, 2026):
Some filters potentially useful could be the Pango filters, which put the text in tags or in a span element with properties used in the chained filters: