1
0
Fork 0
mirror of https://github.com/polybar/polybar.git synced 2024-11-11 13:50:56 -05:00
polybar/include/modules/alsa.hpp

69 lines
1.8 KiB
C++
Raw Normal View History

#pragma once
2016-05-19 10:41:06 -04:00
2016-11-20 17:04:31 -05:00
#include "modules/meta/event_module.hpp"
#include "settings.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
// fwd
namespace alsa {
class mixer;
class control;
} // namespace alsa
2016-06-14 23:32:35 -04:00
namespace modules {
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::control>;
class alsa_module : public event_module<alsa_module> {
2016-06-14 23:32:35 -04:00
public:
explicit alsa_module(const bar_settings&, string);
2016-06-14 23:32:35 -04:00
2016-11-02 15:22:45 -04:00
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;
static constexpr auto TYPE = "internal/alsa";
static constexpr auto EVENT_INC = "inc";
static constexpr auto EVENT_DEC = "dec";
static constexpr auto EVENT_TOGGLE = "toggle";
protected:
2020-05-31 15:11:36 -04:00
bool input(const string& action, const string& data);
2016-06-14 23:32:35 -04:00
private:
static constexpr auto FORMAT_VOLUME = "format-volume";
static constexpr auto FORMAT_MUTED = "format-muted";
2016-05-19 10:41:06 -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>";
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-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-11-25 07:55:15 -05:00
map<mixer, mixer_t> m_mixer;
map<control, control_t> m_ctrl;
int m_headphoneid{0};
bool m_mapped{false};
2018-08-06 16:45:03 -04:00
int m_interval{5};
2016-12-22 23:18:58 -05:00
atomic<bool> m_muted{false};
atomic<bool> m_headphones{false};
atomic<int> m_volume{0};
2016-05-19 10:41:06 -04:00
};
} // namespace modules
2016-06-14 23:32:35 -04:00
2016-11-19 00:22:44 -05:00
POLYBAR_NS_END