summaryrefslogtreecommitdiff
path: root/gbrightness.cpp
blob: 985d1590792e290c6b87d239b2c3f8e04b84220a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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;
	});
}