summaryrefslogtreecommitdiff
path: root/gbrightness.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gbrightness.cpp')
-rw-r--r--gbrightness.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/gbrightness.cpp b/gbrightness.cpp
new file mode 100644
index 0000000..985d159
--- /dev/null
+++ b/gbrightness.cpp
@@ -0,0 +1,22 @@
+#include <iostream>
+#include <X11/keysym.h>
+#include "got-gui/command.h"
+#include "got-gui/xutil.h"
+
+
+int main() {
+ auto display = x::XOpenDisplayRAII(nullptr);
+ Display *dpy = display.first;
+
+ x::globalKeyboardGrab(dpy, [dpy](const XKeyEvent &ev) -> bool {
+ x::Keycode kc{ev.keycode};
+ if (kc == x::Keysym{XK_Up}.toCode(dpy)) {
+ runCommand({"brightness", "+"});
+ } else if (kc == x::Keysym{XK_Down}.toCode(dpy)) {
+ runCommand({"brightness", "-"});
+ } else {
+ return true;
+ }
+ return false;
+ });
+}