Waybar/include/modules/keyboard_state.hpp

48 lines
975 B
C++
Raw Normal View History

2021-02-07 20:05:11 +00:00
#pragma once
#include <fmt/format.h>
#if FMT_VERSION < 60000
#include <fmt/time.h>
#else
#include <fmt/chrono.h>
#endif
2021-02-07 23:46:39 +00:00
#include "AModule.hpp"
#include "bar.hpp"
2021-02-07 20:05:11 +00:00
#include "util/sleeper_thread.hpp"
2021-02-07 23:46:39 +00:00
#include <gtkmm/label.h>
2021-02-07 20:05:11 +00:00
extern "C" {
#include <libevdev/libevdev.h>
}
namespace waybar::modules {
2021-02-07 23:46:39 +00:00
class KeyboardState : public AModule {
2021-02-07 20:05:11 +00:00
public:
2021-02-07 23:46:39 +00:00
KeyboardState(const std::string&, const waybar::Bar&, const Json::Value&);
2021-02-07 20:05:11 +00:00
~KeyboardState();
auto update() -> void;
private:
static auto openDevice(const std::string&) -> std::pair<int, libevdev*>;
2021-02-07 23:46:39 +00:00
Gtk::Box box_;
Gtk::Label numlock_label_;
Gtk::Label capslock_label_;
Gtk::Label scrolllock_label_;
std::string numlock_format_;
std::string capslock_format_;
std::string scrolllock_format_;
const std::chrono::seconds interval_;
std::string icon_locked_;
std::string icon_unlocked_;
2021-02-07 20:05:11 +00:00
int fd_;
libevdev* dev_;
2021-02-07 23:46:39 +00:00
2021-02-07 20:05:11 +00:00
util::SleeperThread thread_;
};
} // namespace waybar::modules