2016-10-19 08:46:43 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "components/config.hpp"
|
2017-01-10 21:07:28 -05:00
|
|
|
#include "settings.hpp"
|
2016-12-22 23:08:19 -05:00
|
|
|
#include "modules/meta/event_handler.hpp"
|
2016-11-20 17:04:31 -05:00
|
|
|
#include "modules/meta/static_module.hpp"
|
2016-12-21 08:55:19 -05:00
|
|
|
#include "x11/extensions/randr.hpp"
|
2016-10-19 08:46:43 -04:00
|
|
|
|
2016-11-19 00:22:44 -05:00
|
|
|
POLYBAR_NS
|
2016-10-19 08:46:43 -04:00
|
|
|
|
2016-11-20 17:04:31 -05:00
|
|
|
class connection;
|
|
|
|
|
2016-10-19 08:46:43 -04: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 11:54:38 -05:00
|
|
|
* This module is a lot faster, it's more responsive and it will
|
2016-10-19 08:46:43 -04:00
|
|
|
* be dormant until new values are reported. Inotify watches
|
|
|
|
* are a bit random when it comes to proc-/sysfs.
|
|
|
|
*
|
|
|
|
* TODO: Implement backlight configuring using scroll events
|
|
|
|
*/
|
2016-12-21 02:38:44 -05:00
|
|
|
class xbacklight_module : public static_module<xbacklight_module>,
|
2019-12-02 13:14:26 -05:00
|
|
|
public event_handler<evt::randr_notify> {
|
2016-10-19 08:46:43 -04:00
|
|
|
public:
|
2016-12-21 02:00:09 -05:00
|
|
|
explicit xbacklight_module(const bar_settings& bar, string name_);
|
2016-11-20 17:04:31 -05:00
|
|
|
|
2016-11-02 15:22:45 -04:00
|
|
|
void update();
|
2016-11-12 03:40:14 -05:00
|
|
|
string get_output();
|
2016-11-25 07:55:15 -05:00
|
|
|
bool build(builder* builder, const string& tag) const;
|
2016-12-21 02:38:44 -05:00
|
|
|
|
|
|
|
protected:
|
2016-12-22 23:08:19 -05:00
|
|
|
void handle(const evt::randr_notify& evt);
|
2016-12-23 14:43:52 -05:00
|
|
|
bool input(string&& cmd);
|
2016-10-19 08:46:43 -04:00
|
|
|
|
|
|
|
private:
|
2016-12-05 14:41:00 -05: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 08:46:43 -04:00
|
|
|
|
2016-12-05 14:41:00 -05:00
|
|
|
static constexpr const char* EVENT_SCROLLUP{"xbacklight+"};
|
|
|
|
static constexpr const char* EVENT_SCROLLDOWN{"xbacklight-"};
|
2016-11-12 03:40:14 -05:00
|
|
|
|
2016-11-20 17:04:31 -05:00
|
|
|
connection& m_connection;
|
2016-10-19 08:46:43 -04:00
|
|
|
monitor_t m_output;
|
2016-12-15 03:29:14 -05:00
|
|
|
xcb_window_t m_proxy{};
|
2016-10-19 08:46:43 -04:00
|
|
|
|
|
|
|
ramp_t m_ramp;
|
|
|
|
label_t m_label;
|
|
|
|
progressbar_t m_progressbar;
|
|
|
|
|
2016-12-05 14:41:00 -05:00
|
|
|
bool m_scroll{true};
|
2017-01-10 22:16:33 -05:00
|
|
|
std::atomic<int> m_percentage{0};
|
2016-10-19 08:46:43 -04:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2016-11-19 00:22:44 -05:00
|
|
|
POLYBAR_NS_END
|