2018-08-09 21:55:38 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <pulse/pulseaudio.h>
|
|
|
|
#include <fmt/format.h>
|
2018-08-13 20:33:07 +00:00
|
|
|
#include <algorithm>
|
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 {
|
2018-08-16 12:29:41 +00:00
|
|
|
public:
|
2018-08-20 12:50:45 +00:00
|
|
|
Pulseaudio(const Json::Value&);
|
2018-08-19 11:39:57 +00:00
|
|
|
~Pulseaudio();
|
2018-08-16 12:29:41 +00:00
|
|
|
auto update() -> void;
|
|
|
|
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*);
|
|
|
|
static void serverInfoCb(pa_context*, const pa_server_info*, void*);
|
|
|
|
|
2018-08-29 21:50:41 +00:00
|
|
|
const std::string getPortIcon() const;
|
|
|
|
|
2018-08-16 12:29:41 +00:00
|
|
|
pa_threaded_mainloop* mainloop_;
|
|
|
|
pa_mainloop_api* mainloop_api_;
|
|
|
|
pa_context* context_;
|
|
|
|
uint32_t sink_idx_{0};
|
|
|
|
uint16_t volume_;
|
|
|
|
bool muted_;
|
2018-08-29 21:50:41 +00:00
|
|
|
std::string port_name_;
|
2018-08-16 12:29:41 +00:00
|
|
|
std::string desc_;
|
|
|
|
};
|
2018-08-09 21:55:38 +00:00
|
|
|
|
|
|
|
}
|