2016-05-30 23:58:58 -04:00
|
|
|
#pragma once
|
2016-05-19 10:41:06 -04:00
|
|
|
|
2016-06-14 23:32:35 -04:00
|
|
|
#include "adapters/alsa.hpp"
|
2016-10-15 20:21:12 -04:00
|
|
|
#include "components/config.hpp"
|
2016-06-14 23:32:35 -04:00
|
|
|
#include "config.hpp"
|
2016-11-20 17:04:31 -05:00
|
|
|
#include "modules/meta/event_module.hpp"
|
2016-05-19 10:41:06 -04:00
|
|
|
|
2016-11-19 00:22:44 -05:00
|
|
|
POLYBAR_NS
|
2016-06-14 23:32:35 -04:00
|
|
|
|
|
|
|
namespace modules {
|
2016-10-15 20:21:12 -04:00
|
|
|
enum class mixer { NONE = 0, MASTER, SPEAKER, HEADPHONE };
|
|
|
|
enum class control { NONE = 0, HEADPHONE };
|
|
|
|
|
|
|
|
using mixer_t = shared_ptr<alsa_mixer>;
|
|
|
|
using control_t = shared_ptr<alsa_ctl_interface>;
|
|
|
|
|
2016-06-14 23:32:35 -04:00
|
|
|
class volume_module : public event_module<volume_module> {
|
|
|
|
public:
|
|
|
|
using event_module::event_module;
|
|
|
|
|
2016-11-02 15:22:45 -04:00
|
|
|
void setup();
|
|
|
|
void teardown();
|
|
|
|
bool has_event();
|
|
|
|
bool update();
|
|
|
|
string get_format() const;
|
|
|
|
string get_output();
|
2016-11-25 07:55:15 -05:00
|
|
|
bool build(builder* builder, const string& tag) const;
|
2016-11-02 15:22:45 -04:00
|
|
|
bool handle_event(string cmd);
|
|
|
|
bool receive_events() const;
|
2016-06-14 23:32:35 -04:00
|
|
|
|
|
|
|
private:
|
2016-05-25 20:14:56 -04:00
|
|
|
static constexpr auto FORMAT_VOLUME = "format-volume";
|
|
|
|
static constexpr auto FORMAT_MUTED = "format-muted";
|
2016-05-19 10:41:06 -04:00
|
|
|
|
2016-05-25 20:14:56 -04:00
|
|
|
static constexpr auto TAG_RAMP_VOLUME = "<ramp-volume>";
|
2016-06-14 23:32:35 -04:00
|
|
|
static constexpr auto TAG_RAMP_HEADPHONES = "<ramp-headphones>";
|
2016-05-25 20:14:56 -04: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 10:41:06 -04:00
|
|
|
|
2016-06-09 19:09:54 -04:00
|
|
|
static constexpr auto EVENT_PREFIX = "vol";
|
2016-05-30 23:58:58 -04:00
|
|
|
static constexpr auto EVENT_VOLUME_UP = "volup";
|
|
|
|
static constexpr auto EVENT_VOLUME_DOWN = "voldown";
|
|
|
|
static constexpr auto EVENT_TOGGLE_MUTE = "volmute";
|
2016-05-19 10:41:06 -04:00
|
|
|
|
2016-06-14 23:32:35 -04: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-09 19:09:54 -04:00
|
|
|
|
2016-11-25 07:55:15 -05:00
|
|
|
map<mixer, mixer_t> m_mixer;
|
|
|
|
map<control, control_t> m_ctrl;
|
2016-11-20 17:04:31 -05:00
|
|
|
int m_headphoneid{0};
|
|
|
|
bool m_mapped{false};
|
2016-10-11 00:00:33 -04:00
|
|
|
stateflag m_muted{false};
|
|
|
|
stateflag m_headphones{false};
|
2016-10-25 02:53:55 -04:00
|
|
|
std::atomic<int> m_volume{0};
|
2016-05-19 10:41:06 -04:00
|
|
|
};
|
|
|
|
}
|
2016-06-14 23:32:35 -04:00
|
|
|
|
2016-11-19 00:22:44 -05:00
|
|
|
POLYBAR_NS_END
|