2016-10-19 12:46:43 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "components/config.hpp"
|
2016-12-23 04:08:19 +00:00
|
|
|
#include "modules/meta/event_handler.hpp"
|
2016-11-20 22:04:31 +00:00
|
|
|
#include "modules/meta/static_module.hpp"
|
2020-05-15 17:59:08 +00:00
|
|
|
#include "settings.hpp"
|
2016-12-21 13:55:19 +00:00
|
|
|
#include "x11/extensions/randr.hpp"
|
2016-10-19 12:46:43 +00:00
|
|
|
|
2016-11-19 05:22:44 +00:00
|
|
|
POLYBAR_NS
|
2016-10-19 12:46:43 +00:00
|
|
|
|
2016-11-20 22:04:31 +00:00
|
|
|
class connection;
|
|
|
|
|
2016-10-19 12:46:43 +00:00
|
|
|
namespace modules {
|
|
|
|
/**
|
|
|
|
* Backlight module built using the RandR X extension.
|
|
|
|
*
|
|
|
|
* This is built as a replacement for the old backlight
|
|
|
|
* module that was set up using with inotify watches listening
|
|
|
|
* for changes to the raw file handle.
|
|
|
|
*
|
2019-01-29 16:54:38 +00:00
|
|
|
* This module is a lot faster, it's more responsive and it will
|
2016-10-19 12:46:43 +00:00
|
|
|
* be dormant until new values are reported. Inotify watches
|
|
|
|
* are a bit random when it comes to proc-/sysfs.
|
|
|
|
*/
|
2020-05-15 17:59:08 +00:00
|
|
|
class xbacklight_module : public static_module<xbacklight_module>, public event_handler<evt::randr_notify> {
|
2016-10-19 12:46:43 +00:00
|
|
|
public:
|
2016-12-21 07:00:09 +00:00
|
|
|
explicit xbacklight_module(const bar_settings& bar, string name_);
|
2016-11-20 22:04:31 +00:00
|
|
|
|
2016-11-02 19:22:45 +00:00
|
|
|
void update();
|
2016-11-12 08:40:14 +00:00
|
|
|
string get_output();
|
2016-11-25 12:55:15 +00:00
|
|
|
bool build(builder* builder, const string& tag) const;
|
2016-12-21 07:38:44 +00:00
|
|
|
|
2020-05-15 17:59:08 +00:00
|
|
|
static constexpr auto TYPE = "internal/xbacklight";
|
|
|
|
|
2020-05-24 16:35:12 +00:00
|
|
|
static constexpr const char* EVENT_INC = "inc";
|
|
|
|
static constexpr const char* EVENT_DEC = "dec";
|
|
|
|
|
2016-12-21 07:38:44 +00:00
|
|
|
protected:
|
2016-12-23 04:08:19 +00:00
|
|
|
void handle(const evt::randr_notify& evt);
|
2020-05-23 22:36:16 +00:00
|
|
|
bool input(string&& action, string&& data);
|
2016-10-19 12:46:43 +00:00
|
|
|
|
|
|
|
private:
|
2016-12-05 19:41:00 +00:00
|
|
|
static constexpr const char* TAG_LABEL{"<label>"};
|
|
|
|
static constexpr const char* TAG_BAR{"<bar>"};
|
|
|
|
static constexpr const char* TAG_RAMP{"<ramp>"};
|
2016-10-19 12:46:43 +00:00
|
|
|
|
2016-11-20 22:04:31 +00:00
|
|
|
connection& m_connection;
|
2016-10-19 12:46:43 +00:00
|
|
|
monitor_t m_output;
|
2016-12-15 08:29:14 +00:00
|
|
|
xcb_window_t m_proxy{};
|
2016-10-19 12:46:43 +00:00
|
|
|
|
|
|
|
ramp_t m_ramp;
|
|
|
|
label_t m_label;
|
|
|
|
progressbar_t m_progressbar;
|
|
|
|
|
2016-12-05 19:41:00 +00:00
|
|
|
bool m_scroll{true};
|
2017-01-11 03:16:33 +00:00
|
|
|
std::atomic<int> m_percentage{0};
|
2016-10-19 12:46:43 +00:00
|
|
|
};
|
2020-05-15 17:59:08 +00:00
|
|
|
} // namespace modules
|
2016-10-19 12:46:43 +00:00
|
|
|
|
2016-11-19 05:22:44 +00:00
|
|
|
POLYBAR_NS_END
|