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

feat(volume): Optional event handling #84

This commit is contained in:
Michael Carlberg 2017-04-02 18:12:07 +02:00
parent 68beb8d744
commit 02833b7871
3 changed files with 13 additions and 8 deletions

View file

@ -154,6 +154,8 @@ namespace modules {
vector<thread> m_threads; vector<thread> m_threads;
thread m_mainthread; thread m_mainthread;
bool m_handle_events{true};
private: private:
atomic<bool> m_enabled{true}; atomic<bool> m_enabled{true};
atomic<bool> m_changed{true}; atomic<bool> m_changed{true};

View file

@ -17,7 +17,8 @@ namespace modules {
, m_conf(config::make()) , m_conf(config::make())
, m_name("module/" + name) , m_name("module/" + name)
, m_builder(make_unique<builder>(bar)) , m_builder(make_unique<builder>(bar))
, m_formatter(make_unique<module_formatter>(m_conf, m_name)) {} , m_formatter(make_unique<module_formatter>(m_conf, m_name))
, m_handle_events(m_conf.get(m_name, "handle-events", true)) {}
template <typename Impl> template <typename Impl>
module<Impl>::~module() noexcept { module<Impl>::~module() noexcept {

View file

@ -189,9 +189,11 @@ namespace modules {
// with the cmd handlers // with the cmd handlers
string output{module::get_output()}; string output{module::get_output()};
if (m_handle_events) {
m_builder->cmd(mousebtn::LEFT, EVENT_TOGGLE_MUTE); m_builder->cmd(mousebtn::LEFT, EVENT_TOGGLE_MUTE);
m_builder->cmd(mousebtn::SCROLL_UP, EVENT_VOLUME_UP); m_builder->cmd(mousebtn::SCROLL_UP, EVENT_VOLUME_UP);
m_builder->cmd(mousebtn::SCROLL_DOWN, EVENT_VOLUME_DOWN); m_builder->cmd(mousebtn::SCROLL_DOWN, EVENT_VOLUME_DOWN);
}
m_builder->append(output); m_builder->append(output);
@ -216,11 +218,11 @@ namespace modules {
} }
bool volume_module::input(string&& cmd) { bool volume_module::input(string&& cmd) {
if (cmd.compare(0, 3, EVENT_PREFIX) != 0) { if (!m_handle_events) {
return false; return false;
} } else if (cmd.compare(0, 3, EVENT_PREFIX) != 0) {
return false;
if (!m_mixer[mixer::MASTER]) { } else if (!m_mixer[mixer::MASTER]) {
return false; return false;
} }