#pragma once #include "settings.hpp" #include "modules/meta/event_module.hpp" #include "modules/meta/input_handler.hpp" POLYBAR_NS // fwd #if ENABLE_ALSA namespace alsa { class mixer; class control; } #elif ENABLE_PULSEAUDIO class pulseaudio; #endif namespace modules { enum class mixer { NONE = 0, MASTER, SPEAKER, HEADPHONE }; enum class control { NONE = 0, HEADPHONE }; #if ENABLE_ALSA using mixer_t = shared_ptr; using control_t = shared_ptr; #elif ENABLE_PULSEAUDIO using pulseaudio_t = shared_ptr; #endif class volume_module : public event_module, public input_handler { public: explicit volume_module(const bar_settings&, string); void teardown(); bool has_event(); bool update(); string get_format() const; string get_output(); bool build(builder* builder, const string& tag) const; protected: bool input(string&& cmd); private: static constexpr auto FORMAT_VOLUME = "format-volume"; static constexpr auto FORMAT_MUTED = "format-muted"; static constexpr auto TAG_RAMP_VOLUME = ""; static constexpr auto TAG_RAMP_HEADPHONES = ""; static constexpr auto TAG_BAR_VOLUME = ""; static constexpr auto TAG_LABEL_VOLUME = ""; static constexpr auto TAG_LABEL_MUTED = ""; static constexpr auto EVENT_PREFIX = "vol"; static constexpr auto EVENT_VOLUME_UP = "volup"; static constexpr auto EVENT_VOLUME_DOWN = "voldown"; static constexpr auto EVENT_TOGGLE_MUTE = "volmute"; 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; #if ENABLE_PULSEAUDIO pulseaudio_t m_pulseaudio; #elif ENABLE_ALSA map m_mixer; map m_ctrl; int m_headphoneid{0}; bool m_mapped{false}; #endif atomic m_muted{false}; atomic m_headphones{false}; atomic m_volume{0}; }; } POLYBAR_NS_END