waybar/include/modules/pulseaudio.hpp

41 lines
1.1 KiB
C++
Raw Normal View History

2018-08-09 23:55:38 +02:00
#pragma once
#include <fmt/format.h>
#include <pulse/pulseaudio.h>
#include <pulse/volume.h>
2018-08-13 22:33:07 +02:00
#include <algorithm>
#include "ALabel.hpp"
2018-08-09 23:55:38 +02:00
namespace waybar::modules {
class Pulseaudio : public ALabel {
2019-04-18 17:52:00 +02:00
public:
Pulseaudio(const std::string&, const Json::Value&);
~Pulseaudio();
auto update() -> void;
2018-08-16 14:29:41 +02:00
2019-04-18 17:52:00 +02: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*);
static void serverInfoCb(pa_context*, const pa_server_info*, void*);
static void volumeModifyCb(pa_context*, int, void*);
bool handleScroll(GdkEventScroll* e);
2018-08-29 23:50:41 +02:00
2019-04-18 17:52:00 +02:00
const std::string getPortIcon() const;
pa_threaded_mainloop* mainloop_;
pa_mainloop_api* mainloop_api_;
pa_context* context_;
uint32_t sink_idx_{0};
uint16_t volume_;
pa_cvolume pa_volume_;
bool muted_;
std::string port_name_;
std::string desc_;
std::string monitor_;
2019-04-18 17:52:00 +02:00
bool scrolling_;
2018-08-16 14:29:41 +02:00
};
2018-08-09 23:55:38 +02:00
} // namespace waybar::modules