2016-05-31 05:58:58 +02:00
|
|
|
#pragma once
|
2016-05-19 16:41:06 +02:00
|
|
|
|
2016-11-20 23:04:31 +01:00
|
|
|
#include "modules/meta/event_module.hpp"
|
2020-05-15 19:59:08 +02:00
|
|
|
#include "settings.hpp"
|
2016-05-19 16:41:06 +02:00
|
|
|
|
2016-11-19 06:22:44 +01:00
|
|
|
POLYBAR_NS
|
2016-06-15 05:32:35 +02:00
|
|
|
|
2016-12-13 14:26:09 +01:00
|
|
|
// fwd
|
|
|
|
namespace alsa {
|
|
|
|
class mixer;
|
|
|
|
class control;
|
2020-05-15 19:59:08 +02:00
|
|
|
} // namespace alsa
|
2016-12-13 14:26:09 +01:00
|
|
|
|
2016-06-15 05:32:35 +02:00
|
|
|
namespace modules {
|
2016-10-16 02:21:12 +02:00
|
|
|
enum class mixer { NONE = 0, MASTER, SPEAKER, HEADPHONE };
|
|
|
|
enum class control { NONE = 0, HEADPHONE };
|
|
|
|
|
2016-12-13 14:26:09 +01:00
|
|
|
using mixer_t = shared_ptr<alsa::mixer>;
|
|
|
|
using control_t = shared_ptr<alsa::control>;
|
2016-10-16 02:21:12 +02:00
|
|
|
|
2019-12-02 19:14:26 +01:00
|
|
|
class alsa_module : public event_module<alsa_module> {
|
2016-06-15 05:32:35 +02:00
|
|
|
public:
|
2018-01-20 12:50:48 -08:00
|
|
|
explicit alsa_module(const bar_settings&, string);
|
2016-06-15 05:32:35 +02:00
|
|
|
|
2016-11-02 20:22:45 +01:00
|
|
|
void teardown();
|
|
|
|
bool has_event();
|
|
|
|
bool update();
|
|
|
|
string get_format() const;
|
|
|
|
string get_output();
|
2016-11-25 13:55:15 +01:00
|
|
|
bool build(builder* builder, const string& tag) const;
|
2016-12-21 08:38:44 +01:00
|
|
|
|
2020-05-15 19:59:08 +02:00
|
|
|
static constexpr auto TYPE = "internal/alsa";
|
|
|
|
|
2020-05-24 18:35:12 +02:00
|
|
|
static constexpr auto EVENT_INC = "inc";
|
|
|
|
static constexpr auto EVENT_DEC = "dec";
|
|
|
|
static constexpr auto EVENT_TOGGLE = "toggle";
|
|
|
|
|
2016-12-21 08:38:44 +01:00
|
|
|
protected:
|
2021-01-04 10:25:52 +01:00
|
|
|
void action_inc();
|
|
|
|
void action_dec();
|
|
|
|
void action_toggle();
|
|
|
|
|
|
|
|
void change_volume(int interval);
|
|
|
|
|
|
|
|
void action_epilogue(const vector<mixer_t>& mixers);
|
|
|
|
|
|
|
|
vector<mixer_t> get_mixers();
|
2016-06-15 05:32:35 +02:00
|
|
|
|
|
|
|
private:
|
2016-05-26 02:14:56 +02:00
|
|
|
static constexpr auto FORMAT_VOLUME = "format-volume";
|
|
|
|
static constexpr auto FORMAT_MUTED = "format-muted";
|
2016-05-19 16:41:06 +02:00
|
|
|
|
2016-05-26 02:14:56 +02:00
|
|
|
static constexpr auto TAG_RAMP_VOLUME = "<ramp-volume>";
|
2016-06-15 05:32:35 +02:00
|
|
|
static constexpr auto TAG_RAMP_HEADPHONES = "<ramp-headphones>";
|
2016-05-26 02:14:56 +02:00
|
|
|
static constexpr auto TAG_BAR_VOLUME = "<bar-volume>";
|
|
|
|
static constexpr auto TAG_LABEL_VOLUME = "<label-volume>";
|
|
|
|
static constexpr auto TAG_LABEL_MUTED = "<label-muted>";
|
2016-05-19 16:41:06 +02:00
|
|
|
|
2016-06-15 05:32:35 +02:00
|
|
|
progressbar_t m_bar_volume;
|
|
|
|
ramp_t m_ramp_volume;
|
|
|
|
ramp_t m_ramp_headphones;
|
|
|
|
label_t m_label_volume;
|
|
|
|
label_t m_label_muted;
|
2016-06-10 01:09:54 +02:00
|
|
|
|
2016-11-25 13:55:15 +01:00
|
|
|
map<mixer, mixer_t> m_mixer;
|
|
|
|
map<control, control_t> m_ctrl;
|
2017-09-15 20:51:22 -07:00
|
|
|
int m_headphoneid{0};
|
|
|
|
bool m_mapped{false};
|
2018-08-06 13:45:03 -07:00
|
|
|
int m_interval{5};
|
2016-12-23 05:18:58 +01:00
|
|
|
atomic<bool> m_muted{false};
|
|
|
|
atomic<bool> m_headphones{false};
|
|
|
|
atomic<int> m_volume{0};
|
2016-05-19 16:41:06 +02:00
|
|
|
};
|
2020-05-15 19:59:08 +02:00
|
|
|
} // namespace modules
|
2016-06-15 05:32:35 +02:00
|
|
|
|
2016-11-19 06:22:44 +01:00
|
|
|
POLYBAR_NS_END
|