2016-05-31 03:58:58 +00:00
|
|
|
#pragma once
|
2016-05-19 14:41:06 +00:00
|
|
|
|
2016-10-19 12:46:43 +00:00
|
|
|
#include "components/config.hpp"
|
2016-11-20 22:04:31 +00:00
|
|
|
#include "modules/meta/inotify_module.hpp"
|
2020-01-15 15:32:17 +00:00
|
|
|
#include "modules/meta/input_handler.hpp"
|
|
|
|
#include "settings.hpp"
|
2016-05-19 14:41:06 +00:00
|
|
|
|
2016-11-19 05:22:44 +00:00
|
|
|
POLYBAR_NS
|
2016-06-15 03:32:35 +00:00
|
|
|
|
|
|
|
namespace modules {
|
2020-01-15 15:32:17 +00:00
|
|
|
class backlight_module : public inotify_module<backlight_module>, public input_handler {
|
2016-12-21 07:38:44 +00:00
|
|
|
public:
|
|
|
|
struct brightness_handle {
|
|
|
|
void filepath(const string& path);
|
|
|
|
float read() const;
|
2016-10-19 12:46:43 +00:00
|
|
|
|
2016-12-21 07:38:44 +00:00
|
|
|
private:
|
|
|
|
string m_path;
|
|
|
|
};
|
2016-10-19 12:46:43 +00:00
|
|
|
|
2020-01-15 15:32:17 +00:00
|
|
|
string get_output();
|
|
|
|
|
2016-06-15 03:32:35 +00:00
|
|
|
public:
|
2016-12-21 07:00:09 +00:00
|
|
|
explicit backlight_module(const bar_settings&, string);
|
2016-06-15 03:32:35 +00:00
|
|
|
|
2016-11-02 19:22:45 +00:00
|
|
|
void idle();
|
|
|
|
bool on_event(inotify_event* event);
|
2016-11-25 12:55:15 +00:00
|
|
|
bool build(builder* builder, const string& tag) const;
|
2016-06-15 03:32:35 +00:00
|
|
|
|
2020-01-15 15:32:17 +00:00
|
|
|
protected:
|
|
|
|
bool input(string&& cmd);
|
|
|
|
|
2016-06-15 03:32:35 +00:00
|
|
|
private:
|
|
|
|
static constexpr auto TAG_LABEL = "<label>";
|
|
|
|
static constexpr auto TAG_BAR = "<bar>";
|
|
|
|
static constexpr auto TAG_RAMP = "<ramp>";
|
|
|
|
|
2020-01-15 15:32:17 +00:00
|
|
|
static constexpr const char* EVENT_SCROLLUP{"backlight+"};
|
|
|
|
static constexpr const char* EVENT_SCROLLDOWN{"backlight-"};
|
|
|
|
|
2016-06-15 03:32:35 +00:00
|
|
|
ramp_t m_ramp;
|
|
|
|
label_t m_label;
|
|
|
|
progressbar_t m_progressbar;
|
2020-01-15 15:32:17 +00:00
|
|
|
string m_path_backlight;
|
|
|
|
float m_max_brightness;
|
|
|
|
bool m_scroll{false};
|
2016-06-15 03:32:35 +00:00
|
|
|
|
2016-10-19 12:46:43 +00:00
|
|
|
brightness_handle m_val;
|
|
|
|
brightness_handle m_max;
|
2016-06-15 03:32:35 +00:00
|
|
|
|
2016-10-19 12:46:43 +00:00
|
|
|
int m_percentage = 0;
|
2016-05-19 14:41:06 +00:00
|
|
|
};
|
2020-01-15 15:32:17 +00:00
|
|
|
} // namespace modules
|
2016-06-15 03:32:35 +00:00
|
|
|
|
2016-11-19 05:22:44 +00:00
|
|
|
POLYBAR_NS_END
|