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

feat(pulseaudio): add volume interval option

This commit is contained in:
NBonaparte 2018-08-06 13:47:12 -07:00 committed by Patrick Ziegler
parent 83784fde14
commit fba87227c7
2 changed files with 5 additions and 2 deletions

View file

@ -47,6 +47,7 @@ namespace modules {
pulseaudio_t m_pulseaudio; pulseaudio_t m_pulseaudio;
int m_interval{5};
atomic<bool> m_muted{false}; atomic<bool> m_muted{false};
atomic<int> m_volume{0}; atomic<int> m_volume{0};
}; };

View file

@ -16,6 +16,8 @@ namespace modules {
pulseaudio_module::pulseaudio_module(const bar_settings& bar, string name_) : event_module<pulseaudio_module>(bar, move(name_)) { pulseaudio_module::pulseaudio_module(const bar_settings& bar, string name_) : event_module<pulseaudio_module>(bar, move(name_)) {
// Load configuration values // Load configuration values
m_interval = m_conf.get(name(), "interval", m_interval);
auto sink_name = m_conf.get(name(), "sink", ""s); auto sink_name = m_conf.get(name(), "sink", ""s);
bool m_max_volume = m_conf.get(name(), "use-ui-max", true); bool m_max_volume = m_conf.get(name(), "use-ui-max", true);
@ -138,9 +140,9 @@ namespace modules {
m_pulseaudio->toggle_mute(); m_pulseaudio->toggle_mute();
} else if (cmd.compare(0, strlen(EVENT_VOLUME_UP), EVENT_VOLUME_UP) == 0) { } else if (cmd.compare(0, strlen(EVENT_VOLUME_UP), EVENT_VOLUME_UP) == 0) {
// cap above 100 (~150)? // cap above 100 (~150)?
m_pulseaudio->inc_volume(5); m_pulseaudio->inc_volume(m_interval);
} else if (cmd.compare(0, strlen(EVENT_VOLUME_DOWN), EVENT_VOLUME_DOWN) == 0) { } else if (cmd.compare(0, strlen(EVENT_VOLUME_DOWN), EVENT_VOLUME_DOWN) == 0) {
m_pulseaudio->inc_volume(-5); m_pulseaudio->inc_volume(-m_interval);
} else { } else {
return false; return false;
} }