1
0
Fork 0
mirror of https://github.com/polybar/polybar.git synced 2024-11-25 13:55:47 -05:00

refactor(ipc): Cleanup

This commit is contained in:
Michael Carlberg 2017-01-14 00:27:29 +01:00
parent ed87a8924f
commit dacf36b981
3 changed files with 13 additions and 13 deletions

View file

@ -35,11 +35,11 @@ namespace modules {
void on_message(const string& message);
private:
static constexpr auto TAG_OUTPUT = "<output>";
static constexpr const char* TAG_OUTPUT{"<output>"};
vector<unique_ptr<hook>> m_hooks;
string m_output;
size_t m_initial{0_z};
map<mousebtn, string> m_actions;
string m_output;
size_t m_initial;
};
}

View file

@ -115,7 +115,7 @@ int main(int argc, char** argv) {
} else if (!pid || pid == handle_pid) {
string payload{ipc_type + ':' + ipc_payload};
file_descriptor fd(handle, O_WRONLY);
if (write(fd, payload.c_str(), payload.size()) == -1) {
if (write(fd, payload.c_str(), payload.size()) != -1) {
log("Successfully wrote \"" + payload + "\" to \"" + handle + "\"");
} else {
log(E_WRITE, "Failed to write \"" + payload + "\" to \"" + handle + "\" (err: " + std::strerror(errno) + ")");

View file

@ -23,18 +23,18 @@ namespace modules {
throw module_error("No hooks defined");
}
if ((m_initial = m_conf.get(name(), "initial", m_initial)) && m_initial > m_hooks.size()) {
if ((m_initial = m_conf.get(name(), "initial", 0_z)) && m_initial > m_hooks.size()) {
throw module_error("Initial hook out of bounds (defined: " + to_string(m_hooks.size()) + ")");
}
m_actions[mousebtn::LEFT] = m_conf.get(name(), "click-left", ""s);
m_actions[mousebtn::MIDDLE] = m_conf.get(name(), "click-middle", ""s);
m_actions[mousebtn::RIGHT] = m_conf.get(name(), "click-right", ""s);
m_actions[mousebtn::SCROLL_UP] = m_conf.get(name(), "scroll-up", ""s);
m_actions[mousebtn::SCROLL_DOWN] = m_conf.get(name(), "scroll-down", ""s);
m_actions[mousebtn::DOUBLE_LEFT] = m_conf.get(name(), "double-click-left", ""s);
m_actions[mousebtn::DOUBLE_MIDDLE] = m_conf.get(name(), "double-click-middle", ""s);
m_actions[mousebtn::DOUBLE_RIGHT] = m_conf.get(name(), "double-click-right", ""s);
m_actions.emplace(make_pair<mousebtn, string>(mousebtn::LEFT, m_conf.get(name(), "click-left", ""s)));
m_actions.emplace(make_pair<mousebtn, string>(mousebtn::MIDDLE, m_conf.get(name(), "click-middle", ""s)));
m_actions.emplace(make_pair<mousebtn, string>(mousebtn::RIGHT, m_conf.get(name(), "click-right", ""s)));
m_actions.emplace(make_pair<mousebtn, string>(mousebtn::SCROLL_UP, m_conf.get(name(), "scroll-up", ""s)));
m_actions.emplace(make_pair<mousebtn, string>(mousebtn::SCROLL_DOWN, m_conf.get(name(), "scroll-down", ""s)));
m_actions.emplace(make_pair<mousebtn, string>(mousebtn::DOUBLE_LEFT, m_conf.get(name(), "double-click-left", ""s)));
m_actions.emplace(make_pair<mousebtn, string>(mousebtn::DOUBLE_MIDDLE, m_conf.get(name(), "double-click-middle", ""s)));
m_actions.emplace(make_pair<mousebtn, string>(mousebtn::DOUBLE_RIGHT, m_conf.get(name(), "double-click-right", ""s)));
m_formatter->add(DEFAULT_FORMAT, TAG_OUTPUT, {TAG_OUTPUT});
}