2018-08-09 21:55:38 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <fmt/format.h>
|
2018-10-29 16:18:35 +00:00
|
|
|
#include <pulse/pulseaudio.h>
|
|
|
|
#include <pulse/volume.h>
|
2018-08-13 20:33:07 +00:00
|
|
|
#include <algorithm>
|
2019-08-09 09:05:34 +00:00
|
|
|
#include <array>
|
2018-08-18 09:43:48 +00:00
|
|
|
#include "ALabel.hpp"
|
2018-08-09 21:55:38 +00:00
|
|
|
|
|
|
|
namespace waybar::modules {
|
|
|
|
|
2018-08-18 09:43:48 +00:00
|
|
|
class Pulseaudio : public ALabel {
|
2019-04-18 15:52:00 +00:00
|
|
|
public:
|
|
|
|
Pulseaudio(const std::string&, const Json::Value&);
|
|
|
|
~Pulseaudio();
|
|
|
|
auto update() -> void;
|
2018-08-16 12:29:41 +00:00
|
|
|
|
2019-04-18 15:52:00 +00:00
|
|
|
private:
|
|
|
|
static void subscribeCb(pa_context*, pa_subscription_event_type_t, uint32_t, void*);
|
|
|
|
static void contextStateCb(pa_context*, void*);
|
|
|
|
static void sinkInfoCb(pa_context*, const pa_sink_info*, int, void*);
|
2019-05-21 12:53:31 +00:00
|
|
|
static void sourceInfoCb(pa_context*, const pa_source_info* i, int, void* data);
|
2019-04-18 15:52:00 +00:00
|
|
|
static void serverInfoCb(pa_context*, const pa_server_info*, void*);
|
|
|
|
static void volumeModifyCb(pa_context*, int, void*);
|
2018-08-29 21:50:41 +00:00
|
|
|
|
2019-06-16 13:07:50 +00:00
|
|
|
bool handleScroll(GdkEventScroll* e);
|
2021-07-15 06:52:02 +00:00
|
|
|
const std::vector<std::string> getPulseIcon() const;
|
2019-04-18 15:52:00 +00:00
|
|
|
|
|
|
|
pa_threaded_mainloop* mainloop_;
|
|
|
|
pa_mainloop_api* mainloop_api_;
|
|
|
|
pa_context* context_;
|
2019-05-21 12:53:31 +00:00
|
|
|
// SINK
|
|
|
|
uint32_t sink_idx_{0};
|
|
|
|
uint16_t volume_;
|
|
|
|
pa_cvolume pa_volume_;
|
|
|
|
bool muted_;
|
|
|
|
std::string port_name_;
|
2020-01-13 10:18:19 +00:00
|
|
|
std::string form_factor_;
|
2019-05-21 12:53:31 +00:00
|
|
|
std::string desc_;
|
|
|
|
std::string monitor_;
|
2020-02-24 10:30:35 +00:00
|
|
|
std::string default_sink_name_;
|
2019-05-21 12:53:31 +00:00
|
|
|
// SOURCE
|
|
|
|
uint32_t source_idx_{0};
|
|
|
|
uint16_t source_volume_;
|
|
|
|
bool source_muted_;
|
|
|
|
std::string source_port_name_;
|
|
|
|
std::string source_desc_;
|
2020-02-24 10:30:35 +00:00
|
|
|
std::string default_source_name_;
|
2018-08-16 12:29:41 +00:00
|
|
|
};
|
2018-08-09 21:55:38 +00:00
|
|
|
|
2018-10-29 16:18:35 +00:00
|
|
|
} // namespace waybar::modules
|