2021-02-07 21:05:11 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <fmt/chrono.h>
|
2022-04-06 08:37:19 +02:00
|
|
|
#include <gtkmm/label.h>
|
|
|
|
|
2022-08-22 14:36:21 +02:00
|
|
|
#include <unordered_map>
|
|
|
|
|
2021-02-08 00:46:39 +01:00
|
|
|
#include "AModule.hpp"
|
|
|
|
#include "bar.hpp"
|
2021-02-07 21:05:11 +01:00
|
|
|
#include "util/sleeper_thread.hpp"
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
#include <libevdev/libevdev.h>
|
2022-08-22 14:36:21 +02:00
|
|
|
#include <libinput.h>
|
2021-02-07 21:05:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace waybar::modules {
|
|
|
|
|
2021-02-08 00:46:39 +01:00
|
|
|
class KeyboardState : public AModule {
|
2021-02-07 21:05:11 +01:00
|
|
|
public:
|
2021-02-08 00:46:39 +01:00
|
|
|
KeyboardState(const std::string&, const waybar::Bar&, const Json::Value&);
|
2023-03-02 14:57:07 +01:00
|
|
|
virtual ~KeyboardState();
|
|
|
|
auto update() -> void override;
|
2021-02-07 21:05:11 +01:00
|
|
|
|
|
|
|
private:
|
2022-08-23 17:18:40 +02:00
|
|
|
auto tryAddDevice(const std::string&) -> void;
|
2022-08-22 14:36:21 +02:00
|
|
|
|
2022-04-06 08:37:19 +02:00
|
|
|
Gtk::Box box_;
|
|
|
|
Gtk::Label numlock_label_;
|
|
|
|
Gtk::Label capslock_label_;
|
|
|
|
Gtk::Label scrolllock_label_;
|
2021-02-08 00:46:39 +01:00
|
|
|
|
|
|
|
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_;
|
2022-08-23 17:18:40 +02:00
|
|
|
std::string devices_path_;
|
2021-02-08 00:46:39 +01:00
|
|
|
|
2022-08-22 14:36:21 +02:00
|
|
|
struct libinput* libinput_;
|
|
|
|
std::unordered_map<std::string, struct libinput_device*> libinput_devices_;
|
2021-02-08 00:46:39 +01:00
|
|
|
|
2022-08-23 17:18:40 +02:00
|
|
|
util::SleeperThread libinput_thread_, hotplug_thread_;
|
2021-02-07 21:05:11 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace waybar::modules
|