2016-12-19 16:01:37 -05:00
|
|
|
#pragma once
|
|
|
|
|
2022-03-02 08:58:47 -05:00
|
|
|
#include <atomic>
|
|
|
|
|
2016-12-19 16:01:37 -05:00
|
|
|
#include "modules/meta/timer_module.hpp"
|
2017-11-07 17:29:44 -05:00
|
|
|
#include "settings.hpp"
|
2016-12-19 16:01:37 -05:00
|
|
|
#include "utils/http.hpp"
|
|
|
|
|
|
|
|
POLYBAR_NS
|
|
|
|
|
|
|
|
namespace modules {
|
|
|
|
/**
|
|
|
|
* Module used to query the GitHub API for notification count
|
|
|
|
*/
|
|
|
|
class github_module : public timer_module<github_module> {
|
|
|
|
public:
|
|
|
|
explicit github_module(const bar_settings&, string);
|
|
|
|
|
|
|
|
bool update();
|
|
|
|
bool build(builder* builder, const string& tag) const;
|
2020-02-21 07:58:23 -05:00
|
|
|
string get_format() const;
|
|
|
|
|
2020-05-15 13:59:08 -04:00
|
|
|
static constexpr auto TYPE = "internal/github";
|
|
|
|
|
2016-12-19 16:01:37 -05:00
|
|
|
private:
|
2019-08-04 14:58:25 -04:00
|
|
|
void update_label(int);
|
2017-11-07 17:29:44 -05:00
|
|
|
int get_number_of_notification();
|
|
|
|
string request();
|
2016-12-19 16:01:37 -05:00
|
|
|
static constexpr auto TAG_LABEL = "<label>";
|
2020-02-21 07:58:23 -05:00
|
|
|
static constexpr auto TAG_LABEL_OFFLINE = "<label-offline>";
|
|
|
|
static constexpr auto FORMAT_OFFLINE = "format-offline";
|
2016-12-19 16:01:37 -05:00
|
|
|
|
|
|
|
label_t m_label{};
|
2020-02-21 07:58:23 -05:00
|
|
|
label_t m_label_offline{};
|
2019-08-04 14:58:25 -04:00
|
|
|
string m_api_url;
|
2020-03-26 07:50:42 -04:00
|
|
|
string m_user;
|
2016-12-19 16:01:37 -05:00
|
|
|
string m_accesstoken{};
|
2022-03-06 11:44:48 -05:00
|
|
|
http_downloader m_http{};
|
2016-12-19 23:53:45 -05:00
|
|
|
bool m_empty_notifications{false};
|
2020-02-21 07:58:23 -05:00
|
|
|
std::atomic<bool> m_offline{false};
|
2016-12-19 16:01:37 -05:00
|
|
|
};
|
2022-03-02 08:58:47 -05:00
|
|
|
} // namespace modules
|
2016-12-19 16:01:37 -05:00
|
|
|
|
|
|
|
POLYBAR_NS_END
|