Merge branch 'Alexays:master' into master

This commit is contained in:
Sonter 2024-09-19 14:45:33 +00:00 committed by GitHub
commit 3462769fc1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 52 additions and 43 deletions

View File

@ -55,8 +55,8 @@ Addressed by *custom/<name>*
*format*: ++ *format*: ++
typeof: string ++ typeof: string ++
default: {} ++ default: {text} ++
The format, how information should be displayed. On {} data gets inserted. The format, how information should be displayed. On {text} data gets inserted.
*format-icons*: ++ *format-icons*: ++
typeof: array ++ typeof: array ++
@ -160,7 +160,7 @@ $text\\n$tooltip\\n$class*
# FORMAT REPLACEMENTS # FORMAT REPLACEMENTS
*{}*: Output of the script. *{text}*: Output of the script.
*{percentage}* Percentage which can be set via a json return type. *{percentage}* Percentage which can be set via a json return type.
@ -172,7 +172,7 @@ $text\\n$tooltip\\n$class*
``` ```
"custom/spotify": { "custom/spotify": {
"format": " {}", "format": " {text}",
"max-length": 40, "max-length": 40,
"interval": 30, // Remove this if your script is endless and write in loop "interval": 30, // Remove this if your script is endless and write in loop
"exec": "$HOME/.config/waybar/mediaplayer.sh 2> /dev/null", // Script in resources folder "exec": "$HOME/.config/waybar/mediaplayer.sh 2> /dev/null", // Script in resources folder
@ -185,7 +185,7 @@ $text\\n$tooltip\\n$class*
``` ```
"custom/mpd": { "custom/mpd": {
"format": "♪ {}", "format": "♪ {text}",
//"max-length": 15, //"max-length": 15,
"interval": 10, "interval": 10,
"exec": "mpc current", "exec": "mpc current",
@ -199,7 +199,7 @@ $text\\n$tooltip\\n$class*
``` ```
"custom/cmus": { "custom/cmus": {
"format": "♪ {}", "format": "♪ {text}",
//"max-length": 15, //"max-length": 15,
"interval": 10, "interval": 10,
"exec": "cmus-remote -C \"format_print '%a - %t'\"", // artist - title "exec": "cmus-remote -C \"format_print '%a - %t'\"", // artist - title
@ -214,7 +214,7 @@ $text\\n$tooltip\\n$class*
``` ```
"custom/pacman": { "custom/pacman": {
"format": "{} ", "format": "{text} ",
"interval": "once", "interval": "once",
"exec": "pacman_packages", "exec": "pacman_packages",
"on-click": "update-system", "on-click": "update-system",
@ -226,7 +226,7 @@ $text\\n$tooltip\\n$class*
``` ```
"custom/pacman": { "custom/pacman": {
"format": "{} ", "format": "{text} ",
"interval": 3600, // every hour "interval": 3600, // every hour
"exec": "checkupdates | wc -l", // # of updates "exec": "checkupdates | wc -l", // # of updates
"exec-if": "exit 0", // always run; consider advanced run conditions "exec-if": "exit 0", // always run; consider advanced run conditions

View File

@ -189,7 +189,7 @@
"on-click": "pavucontrol" "on-click": "pavucontrol"
}, },
"custom/media": { "custom/media": {
"format": "{icon} {}", "format": "{icon} {text}",
"return-type": "json", "return-type": "json",
"max-length": 40, "max-length": 40,
"format-icons": { "format-icons": {

View File

@ -159,7 +159,8 @@ auto waybar::modules::Custom::update() -> void {
parseOutputRaw(); parseOutputRaw();
} }
auto str = fmt::format(fmt::runtime(format_), text_, fmt::arg("alt", alt_), try {
auto str = fmt::format(fmt::runtime(format_), fmt::arg("text", text_), fmt::arg("alt", alt_),
fmt::arg("icon", getIcon(percentage_, alt_)), fmt::arg("icon", getIcon(percentage_, alt_)),
fmt::arg("percentage", percentage_)); fmt::arg("percentage", percentage_));
if ((config_["hide-empty-text"].asBool() && text_.empty()) || str.empty()) { if ((config_["hide-empty-text"].asBool() && text_.empty()) || str.empty()) {
@ -169,9 +170,9 @@ auto waybar::modules::Custom::update() -> void {
if (tooltipEnabled()) { if (tooltipEnabled()) {
if (tooltip_format_enabled_) { if (tooltip_format_enabled_) {
auto tooltip = config_["tooltip-format"].asString(); auto tooltip = config_["tooltip-format"].asString();
tooltip = fmt::format(fmt::runtime(tooltip), text_, fmt::arg("alt", alt_), tooltip = fmt::format(
fmt::arg("icon", getIcon(percentage_, alt_)), fmt::runtime(tooltip), fmt::arg("text", text_), fmt::arg("alt", alt_),
fmt::arg("percentage", percentage_)); fmt::arg("icon", getIcon(percentage_, alt_)), fmt::arg("percentage", percentage_));
label_.set_tooltip_markup(tooltip); label_.set_tooltip_markup(tooltip);
} else if (text_ == tooltip_) { } else if (text_ == tooltip_) {
if (label_.get_tooltip_markup() != str) { if (label_.get_tooltip_markup() != str) {
@ -197,6 +198,14 @@ auto waybar::modules::Custom::update() -> void {
style->add_class(MODULE_CLASS); style->add_class(MODULE_CLASS);
event_box_.show(); event_box_.show();
} }
} catch (const fmt::format_error& e) {
if (std::strcmp(e.what(), "cannot switch from manual to automatic argument indexing") != 0)
throw;
throw fmt::format_error(
"mixing manual and automatic argument indexing is no longer supported; "
"try replacing \"{}\" with \"{text}\" in your format specifier");
}
} }
// Call parent update // Call parent update
ALabel::update(); ALabel::update();