1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-04-19 19:34:24 +02:00

fix(sys-info): tokens not replaced if more than one in string

This commit is contained in:
Jake Stanger 2022-10-16 01:00:43 +01:00
parent 91c57edc73
commit 9e6dbbd131
No known key found for this signature in database
GPG key ID: C51FC8F9CB0BEA61

View file

@ -238,7 +238,7 @@ impl Module<gtk::Box> for SysInfoModule {
context: WidgetContext<Self::SendMessage, Self::ReceiveMessage>,
info: &ModuleInfo,
) -> Result<ModuleWidget<gtk::Box>> {
let re = Regex::new(r"\{([\w-]+)}")?;
let re = Regex::new(r"\{([^}]+)}")?;
let container = gtk::Box::new(info.bar_position.get_orientation(), 10);
@ -259,7 +259,7 @@ impl Module<gtk::Box> for SysInfoModule {
let formats = self.format;
context.widget_rx.attach(None, move |info| {
for (format, label) in formats.iter().zip(labels.clone()) {
let format_compiled = re.replace(format, |caps: &Captures| {
let format_compiled = re.replace_all(format, |caps: &Captures| {
info.get(&caps[1])
.unwrap_or(&caps[0].to_string())
.to_string()