fix(ipc): Replace all %pid% tokens

Fixes #2500
This commit is contained in:
patrick96 2021-09-13 14:06:08 +02:00 committed by Patrick Ziegler
parent 6136c08d42
commit a8cba9c43c
2 changed files with 6 additions and 7 deletions

View File

@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- The tray mistakenly removed tray icons that did not support XEMBED
([`#2479`](https://github.com/polybar/polybar/issues/2479),
[`#2442`](https://github.com/polybar/polybar/issues/2442))
- `custom/ipc`: Only the first appearance of the `%pid%` token was replaced
([`#2500`](https://github.com/polybar/polybar/issues/2500))
## [3.5.6] - 2021-05-24
### Build

View File

@ -38,18 +38,15 @@ namespace modules {
m_actions.emplace(make_pair<mousebtn, string>(mousebtn::DOUBLE_RIGHT, m_conf.get(name(), "double-click-right", ""s)));
// clang-format on
const auto pid_token = [](string& s) {
string::size_type p = s.find("%pid%");
if (p != string::npos) {
s.replace(p, 5, to_string(getpid()));
}
const auto pid_token = [](const string& s) {
return string_util::replace_all(s, "%pid%", to_string(getpid()));
};
for (auto& action : m_actions) {
pid_token(action.second);
action.second = pid_token(action.second);
}
for (auto& hook : m_hooks) {
pid_token(hook->command);
hook->command = pid_token(hook->command);
}
m_formatter->add(DEFAULT_FORMAT, TAG_OUTPUT, {TAG_OUTPUT});