aboutsummaryrefslogtreecommitdiff
path: root/gpu-screen-recorder-overlay-daemon
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-03-31 02:38:18 +0200
committerdec05eba <dec05eba@protonmail.com>2022-03-31 02:38:18 +0200
commit5dc945eb6a0361ee7a64314f7a2acbf24ea9b565 (patch)
tree51132c347bda1d8c33945a962f8bc1ac0948a982 /gpu-screen-recorder-overlay-daemon
parent900553e6c0120edaf90fa8d28f34bd82af4c5a58 (diff)
Start/stop recording if not running/already running
Diffstat (limited to 'gpu-screen-recorder-overlay-daemon')
-rw-r--r--gpu-screen-recorder-overlay-daemon/main.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/gpu-screen-recorder-overlay-daemon/main.c b/gpu-screen-recorder-overlay-daemon/main.c
index 197d411..7db83bd 100644
--- a/gpu-screen-recorder-overlay-daemon/main.c
+++ b/gpu-screen-recorder-overlay-daemon/main.c
@@ -1,14 +1,19 @@
#include <stdio.h>
#include <stdlib.h>
+#include <signal.h>
#include <X11/Xlib.h>
#include <X11/keysym.h>
-static int xerror_dummy(Display *dpy, XErrorEvent *ee) {
- (void)dpy;
+static int ignore_xerror(Display *display, XErrorEvent *ee) {
+ (void)display;
(void)ee;
return 0;
}
+static void sigterm_handler(int dummy) {
+ (void)dummy;
+}
+
static const KeySym toggle_overlay_key = XK_Z;
static void grab_keys(Display *display) {
unsigned int numlockmask = 0;
@@ -22,7 +27,7 @@ static void grab_keys(Display *display) {
}
XFreeModifiermap(modmap);
- XErrorHandler prev_error_handler = XSetErrorHandler(xerror_dummy);
+ XErrorHandler prev_error_handler = XSetErrorHandler(ignore_xerror);
Window root_window = DefaultRootWindow(display);
unsigned int modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask };
@@ -52,6 +57,10 @@ int main() {
grab_keys(display);
const KeyCode overlay_keycode = XKeysymToKeycode(display, toggle_overlay_key);
+ XSetErrorHandler(ignore_xerror);
+ /* Killing gpu-screen-recorder with SIGTERM also gives us SIGTERM. We want to ignore that as that has no meaning here */
+ signal(SIGTERM, sigterm_handler);
+
XEvent xev;
for(;;) {
XNextEvent(display, &xev);