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