refactor(alsa): rename and move volume -> alsa
This commit is contained in:
parent
818bcbd0b5
commit
e16227ca43
2
build.sh
2
build.sh
@ -40,7 +40,7 @@ function main
|
||||
|
||||
read -r -p "$(msg "Include support for \"internal/i3\" (requires i3) ------------------- [Y/n]: ")" -n 1 p && echo
|
||||
[[ "${p^^}" != "Y" ]] && enable_i3="OFF"
|
||||
read -r -p "$(msg "Include support for \"internal/volume\" (requires alsalib) ---------- [Y/n]: ")" -n 1 p && echo
|
||||
read -r -p "$(msg "Include support for \"internal/alsa\" (requires alsalib) ---------- [Y/n]: ")" -n 1 p && echo
|
||||
[[ "${p^^}" != "Y" ]] && enable_alsa="OFF"
|
||||
read -r -p "$(msg "Include support for \"internal/pulseaudio\" (requires libpulse) ----- [Y/n]: ")" -n 1 p && echo
|
||||
[[ "${p^^}" != "Y" ]] && enable_pulseaudio="OFF"
|
||||
|
@ -264,8 +264,8 @@ format-underline = #0a6cf5
|
||||
|
||||
label = %date% %time%
|
||||
|
||||
[module/volume]
|
||||
type = internal/volume
|
||||
[module/alsa]
|
||||
type = internal/alsa
|
||||
|
||||
format-volume = <label-volume> <bar-volume>
|
||||
label-volume = VOL
|
||||
|
@ -19,9 +19,9 @@ namespace modules {
|
||||
using mixer_t = shared_ptr<alsa::mixer>;
|
||||
using control_t = shared_ptr<alsa::control>;
|
||||
|
||||
class volume_module : public event_module<volume_module>, public input_handler {
|
||||
class alsa_module : public event_module<alsa_module>, public input_handler {
|
||||
public:
|
||||
explicit volume_module(const bar_settings&, string);
|
||||
explicit alsa_module(const bar_settings&, string);
|
||||
|
||||
void teardown();
|
||||
bool has_event();
|
@ -32,7 +32,7 @@
|
||||
#include "modules/network.hpp"
|
||||
#endif
|
||||
#if ENABLE_ALSA
|
||||
#include "modules/volume.hpp"
|
||||
#include "modules/alsa.hpp"
|
||||
#endif
|
||||
#if ENABLE_PULSEAUDIO
|
||||
#include "modules/pulseaudio.hpp"
|
||||
@ -78,7 +78,7 @@ namespace {
|
||||
} else if (name == "internal/volume") {
|
||||
throw application_error("internal/volume is deprecated, use internal/alsa instead");
|
||||
} else if (name == "internal/alsa") {
|
||||
return new volume_module(bar, move(module_name));
|
||||
return new alsa_module(bar, move(module_name));
|
||||
} else if (name == "internal/pulseaudio") {
|
||||
return new pulseaudio_module(bar, move(module_name));
|
||||
} else if (name == "internal/network") {
|
||||
|
@ -41,7 +41,7 @@ namespace modules {
|
||||
DEFINE_UNSUPPORTED_MODULE(network_module, "internal/network");
|
||||
#endif
|
||||
#if not ENABLE_ALSA
|
||||
DEFINE_UNSUPPORTED_MODULE(volume_module, "internal/volume");
|
||||
DEFINE_UNSUPPORTED_MODULE(alsa_module, "internal/alsa");
|
||||
#endif
|
||||
#if not ENABLE_PULSEAUDIO
|
||||
DEFINE_UNSUPPORTED_MODULE(pulseaudio_module, "internal/pulseaudio");
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "modules/volume.hpp"
|
||||
#include "modules/alsa.hpp"
|
||||
#include "adapters/alsa/control.hpp"
|
||||
#include "adapters/alsa/generic.hpp"
|
||||
#include "adapters/alsa/mixer.hpp"
|
||||
@ -16,9 +16,9 @@ POLYBAR_NS
|
||||
using namespace alsa;
|
||||
|
||||
namespace modules {
|
||||
template class module<volume_module>;
|
||||
template class module<alsa_module>;
|
||||
|
||||
volume_module::volume_module(const bar_settings& bar, string name_) : event_module<volume_module>(bar, move(name_)) {
|
||||
alsa_module::alsa_module(const bar_settings& bar, string name_) : event_module<alsa_module>(bar, move(name_)) {
|
||||
// Load configuration values
|
||||
m_mapped = m_conf.get(name(), "mapped", m_mapped);
|
||||
|
||||
@ -86,13 +86,13 @@ namespace modules {
|
||||
}
|
||||
}
|
||||
|
||||
void volume_module::teardown() {
|
||||
void alsa_module::teardown() {
|
||||
m_mixer.clear();
|
||||
m_ctrl.clear();
|
||||
snd_config_update_free_global();
|
||||
}
|
||||
|
||||
bool volume_module::has_event() {
|
||||
bool alsa_module::has_event() {
|
||||
// Poll for mixer and control events
|
||||
try {
|
||||
if (m_mixer[mixer::MASTER] && m_mixer[mixer::MASTER]->wait(25)) {
|
||||
@ -114,7 +114,7 @@ namespace modules {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool volume_module::update() {
|
||||
bool alsa_module::update() {
|
||||
// Consume pending events
|
||||
if (m_mixer[mixer::MASTER]) {
|
||||
m_mixer[mixer::MASTER]->process_events();
|
||||
@ -179,11 +179,11 @@ namespace modules {
|
||||
return true;
|
||||
}
|
||||
|
||||
string volume_module::get_format() const {
|
||||
string alsa_module::get_format() const {
|
||||
return m_muted ? FORMAT_MUTED : FORMAT_VOLUME;
|
||||
}
|
||||
|
||||
string volume_module::get_output() {
|
||||
string alsa_module::get_output() {
|
||||
// Get the module output early so that
|
||||
// the format prefix/suffix also gets wrapper
|
||||
// with the cmd handlers
|
||||
@ -200,7 +200,7 @@ namespace modules {
|
||||
return m_builder->flush();
|
||||
}
|
||||
|
||||
bool volume_module::build(builder* builder, const string& tag) const {
|
||||
bool alsa_module::build(builder* builder, const string& tag) const {
|
||||
if (tag == TAG_BAR_VOLUME) {
|
||||
builder->node(m_bar_volume->output(m_volume));
|
||||
} else if (tag == TAG_RAMP_VOLUME && (!m_headphones || !*m_ramp_headphones)) {
|
||||
@ -217,7 +217,7 @@ namespace modules {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool volume_module::input(string&& cmd) {
|
||||
bool alsa_module::input(string&& cmd) {
|
||||
if (!m_handle_events) {
|
||||
return false;
|
||||
} else if (cmd.compare(0, 3, EVENT_PREFIX) != 0) {
|
Loading…
Reference in New Issue
Block a user