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