aboutsummaryrefslogtreecommitdiff
path: root/include/GlobalHotkeysLinux.hpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2024-11-24 18:25:58 +0100
committerdec05eba <dec05eba@protonmail.com>2024-11-24 18:33:57 +0100
commit734280f3042a1b2d08764599d1decdee2d4d3132 (patch)
tree4f72eb3aee2f8a98c05e4554f137f6e296fb2018 /include/GlobalHotkeysLinux.hpp
parent56a7e558d290d168a906dba984f5051c1e327712 (diff)
Use linux /dev/input for global hotkeys instead of x11. This also works on wayland on any compositor
Diffstat (limited to 'include/GlobalHotkeysLinux.hpp')
-rw-r--r--include/GlobalHotkeysLinux.hpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/include/GlobalHotkeysLinux.hpp b/include/GlobalHotkeysLinux.hpp
new file mode 100644
index 0000000..62da74e
--- /dev/null
+++ b/include/GlobalHotkeysLinux.hpp
@@ -0,0 +1,24 @@
+#pragma once
+
+#include "GlobalHotkeys.hpp"
+#include <unordered_map>
+#include <sys/types.h>
+
+namespace gsr {
+ class GlobalHotkeysLinux : public GlobalHotkeys {
+ public:
+ GlobalHotkeysLinux();
+ GlobalHotkeysLinux(const GlobalHotkeysLinux&) = delete;
+ GlobalHotkeysLinux& operator=(const GlobalHotkeysLinux&) = delete;
+ ~GlobalHotkeysLinux() override;
+
+ bool start();
+ bool bind_action(const std::string &id, GlobalHotkeyCallback callback) override;
+ void poll_events() override;
+ private:
+ pid_t process_id = 0;
+ int pipes[2];
+ FILE *read_file = nullptr;
+ std::unordered_map<std::string, GlobalHotkeyCallback> bound_actions_by_id;
+ };
+} \ No newline at end of file