summaryrefslogtreecommitdiff
path: root/gbrightness.cpp
diff options
context:
space:
mode:
authorTom Smeding <t.j.smeding@uu.nl>2022-08-30 16:00:36 +0200
committerTom Smeding <t.j.smeding@uu.nl>2022-08-30 16:00:36 +0200
commitf81c9e531fba1831397e4c319ba352c07b24f564 (patch)
treeebc7b4f38753d738fbcd327f539f04075103ba09 /gbrightness.cpp
parent989334821826bc16adf8d3c93a5a9d6be813b796 (diff)
gbrightnessHEADmaster
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;
+ });
+}