aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-03-22 13:33:02 +0100
committerdec05eba <dec05eba@protonmail.com>2022-03-22 13:33:02 +0100
commitff8fa9f0f7c0903ca4a327737e7839b4f221d6d5 (patch)
tree992d46bf952465c5969576cc378655cb0ef1d44c
parentb8f643a7e196962bf3f76b431ff2cfe4a683a55b (diff)
Record black screen instead of crash when compositor + window is not supported at the moment
-rwxr-xr-xrecord-selected.sh8
-rw-r--r--src/main.cpp14
-rwxr-xr-xtoggle-recording-selected.sh9
3 files changed, 19 insertions, 12 deletions
diff --git a/record-selected.sh b/record-selected.sh
deleted file mode 100755
index 5782ac3..0000000
--- a/record-selected.sh
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh -e
-
-window=$(xdotool selectwindow)
-active_sink="$(pactl get-default-sink).monitor"
-mkdir -p "$HOME/Videos"
-video="$HOME/Videos/$(date +"Video_%Y-%m-%d_%H-%M-%S.mp4")"
-gpu-screen-recorder -w "$window" -c mp4 -f 60 -a "${active_sink}.monitor" -o "$video"
-notify-send "GPU Screen Recorder" "Saved video to $video"
diff --git a/src/main.cpp b/src/main.cpp
index ecc178a..689eeb6 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -242,16 +242,22 @@ static bool recreate_window_pixmap(Display *dpy, Window window_id,
// glEnable(GL_BLEND);
// glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ pixmap.texture_width = attr.width;
+ pixmap.texture_height = attr.height;
+
glXBindTexImageEXT(dpy, pixmap.glx_pixmap, GLX_FRONT_EXT, NULL);
- glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH,
- &pixmap.texture_width);
- glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT,
- &pixmap.texture_height);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
GL_NEAREST); // GL_LINEAR );
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_NEAREST); // GL_LINEAR);//GL_LINEAR_MIPMAP_LINEAR );
//glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+
+ GLint gl_texture_width = 0;
+ glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &gl_texture_width);
+ if(gl_texture_width == 0) {
+ fprintf(stderr, "Warning: failed to get texture size. You are probably running an unsupported compositor and recording the selected window doesn't work at the moment. A black window will be displayed instead\n");
+ }
+
fprintf(stderr, "texture width: %d, height: %d\n", pixmap.texture_width,
pixmap.texture_height);
diff --git a/toggle-recording-selected.sh b/toggle-recording-selected.sh
new file mode 100755
index 0000000..663f360
--- /dev/null
+++ b/toggle-recording-selected.sh
@@ -0,0 +1,9 @@
+#!/bin/sh -e
+
+killall -INT gpu-screen-recorder && notify-send -u low 'GPU Screen Recorder' 'Stopped recording' && exit 0;
+window=$(xdotool selectwindow)
+active_sink="$(pactl get-default-sink).monitor"
+mkdir -p "$HOME/Videos"
+video="$HOME/Videos/$(date +"Video_%Y-%m-%d_%H-%M-%S.mp4")"
+notify-send -u low 'GPU Screen Recorder' "Started recording video to $video"
+gpu-screen-recorder -w "$window" -c mp4 -f 60 -a "$active_sink" -o "$video"