2016-05-31 03:58:58 +00:00
|
|
|
#pragma once
|
2016-05-19 14:41:06 +00:00
|
|
|
|
2016-11-20 22:04:31 +00:00
|
|
|
#include <chrono>
|
2016-10-29 04:52:48 +00:00
|
|
|
|
2016-06-15 03:32:35 +00:00
|
|
|
#include "adapters/mpd.hpp"
|
2016-11-20 22:04:31 +00:00
|
|
|
#include "modules/meta/event_module.hpp"
|
2016-12-21 07:38:44 +00:00
|
|
|
#include "modules/meta/input_handler.hpp"
|
2016-05-19 14:41:06 +00:00
|
|
|
|
2016-11-19 05:22:44 +00:00
|
|
|
POLYBAR_NS
|
2016-06-09 11:42:03 +00:00
|
|
|
|
2016-06-15 03:32:35 +00:00
|
|
|
using namespace mpd;
|
|
|
|
|
2016-11-20 22:04:31 +00:00
|
|
|
namespace chrono = std::chrono;
|
|
|
|
|
2016-06-15 03:32:35 +00:00
|
|
|
namespace modules {
|
2016-12-21 07:38:44 +00:00
|
|
|
class mpd_module : public event_module<mpd_module>, public input_handler {
|
2016-06-15 03:32:35 +00:00
|
|
|
public:
|
2016-12-21 07:00:09 +00:00
|
|
|
explicit mpd_module(const bar_settings&, string);
|
2016-06-15 03:32:35 +00:00
|
|
|
|
2016-11-02 19:22:45 +00:00
|
|
|
void teardown();
|
|
|
|
inline bool connected() const;
|
|
|
|
void idle();
|
|
|
|
bool has_event();
|
|
|
|
bool update();
|
|
|
|
string get_format() const;
|
2016-11-14 00:21:57 +00:00
|
|
|
string get_output();
|
2016-11-25 12:55:15 +00:00
|
|
|
bool build(builder* builder, const string& tag) const;
|
2016-12-21 07:38:44 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
bool on(const input_event_t& evt);
|
2016-06-15 03:32:35 +00:00
|
|
|
|
|
|
|
private:
|
2016-05-26 00:14:56 +00:00
|
|
|
static constexpr auto FORMAT_ONLINE = "format-online";
|
|
|
|
static constexpr auto TAG_BAR_PROGRESS = "<bar-progress>";
|
2016-05-31 03:58:58 +00:00
|
|
|
static constexpr auto TAG_TOGGLE = "<toggle>";
|
2016-11-25 03:33:58 +00:00
|
|
|
static constexpr auto TAG_TOGGLE_STOP = "<toggle-stop>";
|
2016-05-26 00:14:56 +00:00
|
|
|
static constexpr auto TAG_LABEL_SONG = "<label-song>";
|
|
|
|
static constexpr auto TAG_LABEL_TIME = "<label-time>";
|
|
|
|
static constexpr auto TAG_ICON_RANDOM = "<icon-random>";
|
|
|
|
static constexpr auto TAG_ICON_REPEAT = "<icon-repeat>";
|
|
|
|
static constexpr auto TAG_ICON_REPEAT_ONE = "<icon-repeatone>";
|
|
|
|
static constexpr auto TAG_ICON_PREV = "<icon-prev>";
|
|
|
|
static constexpr auto TAG_ICON_STOP = "<icon-stop>";
|
|
|
|
static constexpr auto TAG_ICON_PLAY = "<icon-play>";
|
|
|
|
static constexpr auto TAG_ICON_PAUSE = "<icon-pause>";
|
|
|
|
static constexpr auto TAG_ICON_NEXT = "<icon-next>";
|
2016-06-21 03:10:18 +00:00
|
|
|
static constexpr auto TAG_ICON_SEEKB = "<icon-seekb>";
|
|
|
|
static constexpr auto TAG_ICON_SEEKF = "<icon-seekf>";
|
2016-05-19 14:41:06 +00:00
|
|
|
|
2016-05-26 00:14:56 +00:00
|
|
|
static constexpr auto FORMAT_OFFLINE = "format-offline";
|
|
|
|
static constexpr auto TAG_LABEL_OFFLINE = "<label-offline>";
|
2016-05-19 14:41:06 +00:00
|
|
|
|
2016-05-31 03:58:58 +00:00
|
|
|
static constexpr auto EVENT_PLAY = "mpdplay";
|
|
|
|
static constexpr auto EVENT_PAUSE = "mpdpause";
|
|
|
|
static constexpr auto EVENT_STOP = "mpdstop";
|
|
|
|
static constexpr auto EVENT_PREV = "mpdprev";
|
|
|
|
static constexpr auto EVENT_NEXT = "mpdnext";
|
|
|
|
static constexpr auto EVENT_REPEAT = "mpdrepeat";
|
|
|
|
static constexpr auto EVENT_REPEAT_ONE = "mpdrepeatone";
|
|
|
|
static constexpr auto EVENT_RANDOM = "mpdrandom";
|
|
|
|
static constexpr auto EVENT_SEEK = "mpdseek";
|
2016-05-19 14:41:06 +00:00
|
|
|
|
2016-06-15 03:32:35 +00:00
|
|
|
progressbar_t m_bar_progress;
|
|
|
|
iconset_t m_icons;
|
|
|
|
label_t m_label_song;
|
|
|
|
label_t m_label_time;
|
|
|
|
label_t m_label_offline;
|
|
|
|
|
|
|
|
unique_ptr<mpdconnection> m_mpd;
|
|
|
|
unique_ptr<mpdstatus> m_status;
|
2016-05-19 14:41:06 +00:00
|
|
|
|
2016-06-15 03:32:35 +00:00
|
|
|
string m_host = "127.0.0.1";
|
|
|
|
string m_pass = "";
|
|
|
|
unsigned int m_port = 6600;
|
2016-05-19 14:41:06 +00:00
|
|
|
|
2016-06-15 03:32:35 +00:00
|
|
|
string m_toggle_on_color;
|
|
|
|
string m_toggle_off_color;
|
2016-05-19 14:41:06 +00:00
|
|
|
|
2016-06-15 03:32:35 +00:00
|
|
|
chrono::system_clock::time_point m_lastsync;
|
|
|
|
float m_synctime = 1.0f;
|
2016-05-19 14:41:06 +00:00
|
|
|
|
2016-06-27 20:22:33 +00:00
|
|
|
// This flag is used to let thru a broadcast once every time
|
|
|
|
// the connection state changes
|
2016-10-29 04:52:48 +00:00
|
|
|
mpd::connection_state m_statebroadcasted;
|
2016-05-19 14:41:06 +00:00
|
|
|
};
|
|
|
|
}
|
2016-06-15 03:32:35 +00:00
|
|
|
|
2016-11-19 05:22:44 +00:00
|
|
|
POLYBAR_NS_END
|