mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
feat: Add basic support for MPD
This commit is contained in:
@ -23,6 +23,9 @@
|
||||
#ifdef HAVE_LIBPULSE
|
||||
#include "modules/pulseaudio.hpp"
|
||||
#endif
|
||||
#ifdef HAVE_LIBMPDCLIENT
|
||||
#include "modules/mpd.hpp"
|
||||
#endif
|
||||
#include "modules/temperature.hpp"
|
||||
#include "modules/custom.hpp"
|
||||
|
||||
|
39
include/modules/mpd.hpp
Normal file
39
include/modules/mpd.hpp
Normal file
@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
|
||||
#include <thread>
|
||||
#include <fmt/format.h>
|
||||
#include <mpd/client.h>
|
||||
#include "ALabel.hpp"
|
||||
|
||||
namespace waybar::modules {
|
||||
|
||||
class MPD : public ALabel {
|
||||
public:
|
||||
MPD(const std::string&, const Json::Value&);
|
||||
auto update() -> void;
|
||||
private:
|
||||
std::thread worker();
|
||||
void setLabel();
|
||||
void tryConnect();
|
||||
void checkErrors();
|
||||
void fetchState();
|
||||
void waitForEvent();
|
||||
|
||||
std::thread worker_;
|
||||
|
||||
using unique_connection = std::unique_ptr<mpd_connection, decltype(&mpd_connection_free)>;
|
||||
using unique_status = std::unique_ptr<mpd_status, decltype(&mpd_status_free)>;
|
||||
using unique_song = std::unique_ptr<mpd_song, decltype(&mpd_song_free)>;
|
||||
|
||||
// Not using unique_ptr since we don't manage the pointer
|
||||
// (It's either nullptr, or from the config)
|
||||
const char* server;
|
||||
|
||||
unique_connection connection_;
|
||||
unique_status status_;
|
||||
unique_song song_;
|
||||
|
||||
bool stopped_;
|
||||
};
|
||||
|
||||
} // namespace waybar::modules
|
Reference in New Issue
Block a user