1
0
Fork 0
mirror of https://github.com/polybar/polybar.git synced 2024-10-27 05:23:39 -04:00

feat(alsa): Add unmute on scroll option (polybar#3067)

This will allow users to specify in their config if they want the mixers
to unmute if they use the scroll wheel on the module.
This commit is contained in:
Roddy Rappaport 2024-01-13 01:37:02 +02:00 committed by Patrick Ziegler
parent 174ce34285
commit c2dd279bf7
2 changed files with 5 additions and 0 deletions

View file

@ -67,6 +67,7 @@ namespace modules {
map<control, control_t> m_ctrl; map<control, control_t> m_ctrl;
int m_headphoneid{0}; int m_headphoneid{0};
bool m_mapped{false}; bool m_mapped{false};
bool m_unmute_on_scroll{false};
int m_interval{5}; int m_interval{5};
atomic<bool> m_muted{false}; atomic<bool> m_muted{false};
atomic<bool> m_headphones{false}; atomic<bool> m_headphones{false};

View file

@ -28,6 +28,7 @@ namespace modules {
// Load configuration values // Load configuration values
m_mapped = m_conf.get(name(), "mapped", m_mapped); m_mapped = m_conf.get(name(), "mapped", m_mapped);
m_interval = m_conf.get(name(), "interval", m_interval); m_interval = m_conf.get(name(), "interval", m_interval);
m_unmute_on_scroll = m_conf.get(name(), "unmute-on-scroll", m_unmute_on_scroll);
auto master_mixer_name = m_conf.get(name(), "master-mixer", "Master"s); auto master_mixer_name = m_conf.get(name(), "master-mixer", "Master"s);
auto speaker_mixer_name = m_conf.get(name(), "speaker-mixer", ""s); auto speaker_mixer_name = m_conf.get(name(), "speaker-mixer", ""s);
@ -261,6 +262,9 @@ namespace modules {
} }
const auto& mixers = get_mixers(); const auto& mixers = get_mixers();
for (auto&& mixer : mixers) { for (auto&& mixer : mixers) {
if (m_unmute_on_scroll) {
mixer->set_mute(true);
}
m_mapped ? mixer->set_normalized_volume(math_util::cap<float>(mixer->get_normalized_volume() + interval, 0, 100)) m_mapped ? mixer->set_normalized_volume(math_util::cap<float>(mixer->get_normalized_volume() + interval, 0, 100))
: mixer->set_volume(math_util::cap<float>(mixer->get_volume() + interval, 0, 100)); : mixer->set_volume(math_util::cap<float>(mixer->get_volume() + interval, 0, 100));
} }