mirror of https://github.com/polybar/polybar.git
parent
4b0e648cb8
commit
04fac96d78
|
@ -139,6 +139,7 @@ namespace mpd {
|
|||
bool match_state(mpdstate state) const;
|
||||
|
||||
int get_songid() const;
|
||||
int get_queuelen() const;
|
||||
unsigned get_total_time() const;
|
||||
unsigned get_elapsed_time() const;
|
||||
unsigned get_elapsed_percentage();
|
||||
|
@ -157,6 +158,7 @@ namespace mpd {
|
|||
bool m_single = false;
|
||||
|
||||
int m_songid;
|
||||
int m_queuelen;
|
||||
|
||||
unsigned long m_total_time;
|
||||
unsigned long m_elapsed_time;
|
||||
|
|
|
@ -25,14 +25,12 @@ namespace modules {
|
|||
bool has_event();
|
||||
bool update();
|
||||
string get_format() const;
|
||||
string get_output();
|
||||
bool build(builder* builder, string tag) const;
|
||||
bool handle_event(string cmd);
|
||||
bool receive_events() const;
|
||||
|
||||
private:
|
||||
// static const int PROGRESSBAR_THREAD_SYNC_COUNT = 10;
|
||||
// const chrono::duration<double> PROGRESSBAR_THREAD_INTERVAL = 1s;
|
||||
|
||||
static constexpr auto FORMAT_ONLINE = "format-online";
|
||||
static constexpr auto TAG_BAR_PROGRESS = "<bar-progress>";
|
||||
static constexpr auto TAG_TOGGLE = "<toggle>";
|
||||
|
|
|
@ -315,6 +315,7 @@ namespace mpd {
|
|||
m_status.reset(mpd_run_status(*conn));
|
||||
m_updated_at = chrono::system_clock::now();
|
||||
m_songid = mpd_status_get_song_id(m_status.get());
|
||||
m_queuelen = mpd_status_get_queue_length(m_status.get());
|
||||
m_random = mpd_status_get_random(m_status.get());
|
||||
m_repeat = mpd_status_get_repeat(m_status.get());
|
||||
m_single = mpd_status_get_single(m_status.get());
|
||||
|
@ -323,7 +324,7 @@ namespace mpd {
|
|||
}
|
||||
|
||||
void mpdstatus::update(int event, mpdconnection* connection) {
|
||||
if (connection == nullptr || (event & (MPD_IDLE_PLAYER | MPD_IDLE_OPTIONS)) == false)
|
||||
if (connection == nullptr || (event & (MPD_IDLE_PLAYER | MPD_IDLE_OPTIONS | MPD_IDLE_PLAYLIST)) == false)
|
||||
return;
|
||||
|
||||
fetch_data(connection);
|
||||
|
@ -375,6 +376,10 @@ namespace mpd {
|
|||
return m_songid;
|
||||
}
|
||||
|
||||
int mpdstatus::get_queuelen() const {
|
||||
return m_queuelen;
|
||||
}
|
||||
|
||||
unsigned mpdstatus::get_total_time() const {
|
||||
return m_total_time;
|
||||
}
|
||||
|
|
|
@ -215,6 +215,15 @@ namespace modules {
|
|||
return connected() ? FORMAT_ONLINE : FORMAT_OFFLINE;
|
||||
}
|
||||
|
||||
string mpd_module::get_output() {
|
||||
if (m_status && m_status->get_queuelen() == 0) {
|
||||
m_log.info("%s: Hiding module since queue is empty", name());
|
||||
return "";
|
||||
} else {
|
||||
return event_module::get_output();
|
||||
}
|
||||
}
|
||||
|
||||
bool mpd_module::build(builder* builder, string tag) const {
|
||||
bool is_playing = false;
|
||||
bool is_paused = false;
|
||||
|
|
Loading…
Reference in New Issue