2016-05-31 03:58:58 +00:00
|
|
|
#pragma once
|
2016-05-19 14:41:06 +00:00
|
|
|
|
2017-01-11 02:07:28 +00:00
|
|
|
#include "settings.hpp"
|
2016-11-20 22:04:31 +00:00
|
|
|
#include "modules/meta/event_module.hpp"
|
2016-12-21 07:38:44 +00:00
|
|
|
#include "modules/meta/input_handler.hpp"
|
2016-05-19 14:41:06 +00:00
|
|
|
|
2016-11-19 05:22:44 +00:00
|
|
|
POLYBAR_NS
|
2016-06-15 03:32:35 +00:00
|
|
|
|
2016-12-13 13:26:09 +00:00
|
|
|
// fwd
|
|
|
|
namespace alsa {
|
|
|
|
class mixer;
|
|
|
|
class control;
|
|
|
|
}
|
|
|
|
|
2016-06-15 03:32:35 +00:00
|
|
|
namespace modules {
|
2016-10-16 00:21:12 +00:00
|
|
|
enum class mixer { NONE = 0, MASTER, SPEAKER, HEADPHONE };
|
|
|
|
enum class control { NONE = 0, HEADPHONE };
|
|
|
|
|
2016-12-13 13:26:09 +00:00
|
|
|
using mixer_t = shared_ptr<alsa::mixer>;
|
|
|
|
using control_t = shared_ptr<alsa::control>;
|
2016-10-16 00:21:12 +00:00
|
|
|
|
2016-12-21 07:38:44 +00:00
|
|
|
class volume_module : public event_module<volume_module>, public input_handler {
|
2016-06-15 03:32:35 +00:00
|
|
|
public:
|
2016-12-21 07:00:09 +00:00
|
|
|
explicit volume_module(const bar_settings&, string);
|
2016-06-15 03:32:35 +00:00
|
|
|
|
2016-11-02 19:22:45 +00:00
|
|
|
void teardown();
|
|
|
|
bool has_event();
|
|
|
|
bool update();
|
|
|
|
string get_format() const;
|
|
|
|
string get_output();
|
2016-11-25 12:55:15 +00:00
|
|
|
bool build(builder* builder, const string& tag) const;
|
2016-12-21 07:38:44 +00:00
|
|
|
|
|
|
|
protected:
|
2016-12-23 19:43:52 +00:00
|
|
|
bool input(string&& cmd);
|
2016-06-15 03:32:35 +00:00
|
|
|
|
|
|
|
private:
|
2016-05-26 00:14:56 +00:00
|
|
|
static constexpr auto FORMAT_VOLUME = "format-volume";
|
|
|
|
static constexpr auto FORMAT_MUTED = "format-muted";
|
2016-05-19 14:41:06 +00:00
|
|
|
|
2016-05-26 00:14:56 +00:00
|
|
|
static constexpr auto TAG_RAMP_VOLUME = "<ramp-volume>";
|
2016-06-15 03:32:35 +00:00
|
|
|
static constexpr auto TAG_RAMP_HEADPHONES = "<ramp-headphones>";
|
2016-05-26 00:14:56 +00: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 14:41:06 +00:00
|
|
|
|
2016-06-09 23:09:54 +00:00
|
|
|
static constexpr auto EVENT_PREFIX = "vol";
|
2016-05-31 03:58:58 +00: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 14:41:06 +00:00
|
|
|
|
2016-06-15 03:32:35 +00: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 23:09:54 +00:00
|
|
|
|
2016-11-25 12:55:15 +00:00
|
|
|
map<mixer, mixer_t> m_mixer;
|
|
|
|
map<control, control_t> m_ctrl;
|
2016-11-20 22:04:31 +00:00
|
|
|
int m_headphoneid{0};
|
|
|
|
bool m_mapped{false};
|
2016-12-23 04:18:58 +00:00
|
|
|
atomic<bool> m_muted{false};
|
|
|
|
atomic<bool> m_headphones{false};
|
|
|
|
atomic<int> m_volume{0};
|
2016-05-19 14:41:06 +00:00
|
|
|
};
|
|
|
|
}
|
2016-06-15 03:32:35 +00:00
|
|
|
|
2016-11-19 05:22:44 +00:00
|
|
|
POLYBAR_NS_END
|