2020-09-06 17:44:13 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <sndio.h>
|
2022-04-06 06:37:19 +00:00
|
|
|
|
2020-09-06 17:44:13 +00:00
|
|
|
#include <vector>
|
2022-04-06 06:37:19 +00:00
|
|
|
|
2021-05-27 13:40:54 +00:00
|
|
|
#include "AButton.hpp"
|
2020-09-06 17:44:13 +00:00
|
|
|
#include "util/sleeper_thread.hpp"
|
|
|
|
|
|
|
|
namespace waybar::modules {
|
|
|
|
|
2021-05-27 13:40:54 +00:00
|
|
|
class Sndio : public AButton {
|
2020-09-06 17:44:13 +00:00
|
|
|
public:
|
2022-04-06 06:37:19 +00:00
|
|
|
Sndio(const std::string &, const Json::Value &);
|
2020-09-06 17:44:13 +00:00
|
|
|
~Sndio();
|
|
|
|
auto update() -> void;
|
|
|
|
auto set_desc(struct sioctl_desc *, unsigned int) -> void;
|
|
|
|
auto put_val(unsigned int, unsigned int) -> void;
|
|
|
|
bool handleScroll(GdkEventScroll *);
|
2022-04-06 06:37:19 +00:00
|
|
|
bool handleToggle(GdkEventButton *const &);
|
2020-09-06 17:44:13 +00:00
|
|
|
|
|
|
|
private:
|
2020-10-04 05:53:21 +00:00
|
|
|
auto connect_to_sndio() -> void;
|
2020-09-06 17:44:13 +00:00
|
|
|
util::SleeperThread thread_;
|
|
|
|
struct sioctl_hdl *hdl_;
|
|
|
|
std::vector<struct pollfd> pfds_;
|
|
|
|
unsigned int addr_;
|
|
|
|
unsigned int volume_, old_volume_, maxval_;
|
|
|
|
bool muted_;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace waybar::modules
|