2016-10-19 12:46:43 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "components/config.hpp"
|
|
|
|
#include "config.hpp"
|
2016-11-20 22:04:31 +00:00
|
|
|
#include "modules/meta/static_module.hpp"
|
2016-11-25 07:42:31 +00:00
|
|
|
#include "x11/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.
|
|
|
|
*
|
|
|
|
* This module is alot faster, it's more responsive and it will
|
|
|
|
* 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-11-25 07:42:31 +00:00
|
|
|
class xbacklight_module : public static_module<xbacklight_module>, public xpp::event::sink<evt::randr_notify> {
|
2016-10-19 12:46:43 +00:00
|
|
|
public:
|
|
|
|
using static_module::static_module;
|
|
|
|
|
2016-11-20 22:04:31 +00:00
|
|
|
xbacklight_module(const bar_settings bar, const logger& logger, const config& config, string name);
|
|
|
|
|
2016-11-02 19:22:45 +00:00
|
|
|
void setup();
|
2016-11-19 03:03:18 +00:00
|
|
|
void teardown();
|
2016-11-02 19:22:45 +00:00
|
|
|
void handle(const evt::randr_notify& evt);
|
|
|
|
void update();
|
2016-11-12 08:40:14 +00:00
|
|
|
string get_output();
|
2016-11-02 19:22:45 +00:00
|
|
|
bool build(builder* builder, string tag) const;
|
2016-11-12 08:40:14 +00:00
|
|
|
bool handle_event(string cmd);
|
|
|
|
bool receive_events() const {
|
|
|
|
return true;
|
|
|
|
}
|
2016-10-19 12:46:43 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
static constexpr auto TAG_LABEL = "<label>";
|
|
|
|
static constexpr auto TAG_BAR = "<bar>";
|
|
|
|
static constexpr auto TAG_RAMP = "<ramp>";
|
|
|
|
|
2016-11-12 08:40:14 +00:00
|
|
|
static constexpr auto EVENT_SCROLLUP = "xbacklight+";
|
|
|
|
static constexpr auto EVENT_SCROLLDOWN = "xbacklight-";
|
|
|
|
|
2016-11-20 22:04:31 +00:00
|
|
|
connection& m_connection;
|
2016-10-19 12:46:43 +00:00
|
|
|
monitor_t m_output;
|
2016-11-12 08:40:14 +00:00
|
|
|
xcb_window_t m_proxy;
|
|
|
|
xcb_timestamp_t m_timestamp;
|
2016-10-19 12:46:43 +00:00
|
|
|
|
|
|
|
ramp_t m_ramp;
|
|
|
|
label_t m_label;
|
|
|
|
progressbar_t m_progressbar;
|
|
|
|
|
2016-11-12 08:40:14 +00:00
|
|
|
bool m_scroll = true;
|
2016-10-19 12:46:43 +00:00
|
|
|
int m_percentage = 0;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2016-11-19 05:22:44 +00:00
|
|
|
POLYBAR_NS_END
|