aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2025-06-04 01:32:30 +0200
committerdec05eba <dec05eba@protonmail.com>2025-06-04 01:32:30 +0200
commit7d2f2e9b47b15af25ebcda1023c0fef662845f81 (patch)
treeb340c13ac343406059a4d28b15e8089eaf105429
parent636150ef08867178ca8a826e912502112865346d (diff)
Show error notification if another gpu screen recorder process is running when starting the ui
-rw-r--r--TODO4
-rw-r--r--src/Process.cpp21
-rw-r--r--src/main.cpp5
3 files changed, 25 insertions, 5 deletions
diff --git a/TODO b/TODO
index fa0fdb7..05ef754 100644
--- a/TODO
+++ b/TODO
@@ -180,4 +180,6 @@ Support vector graphics. Maybe support svg, rendering it to a texture for better
Support freetype for text rendering. Maybe load freetype as runtime (with dlopen) and use that when available and fallback to stb_freetype if not available.
-Show .webm container option. It's currently chosen automatically if vp8/vp9 is chosen. The available containers should automatically switch depending on the video codec. \ No newline at end of file
+Show .webm container option. It's currently chosen automatically if vp8/vp9 is chosen. The available containers should automatically switch depending on the video codec.
+
+In settings show audio levels for each audio. Maybe show audio level image beside the audio name in the dropdown box and switch to a different image (have 3-4 different images for each level) depending on the volume.
diff --git a/src/Process.cpp b/src/Process.cpp
index 45be208..c02753a 100644
--- a/src/Process.cpp
+++ b/src/Process.cpp
@@ -176,11 +176,21 @@ namespace gsr {
}
}
+ static const char *get_basename(const char *path, int size) {
+ for(int i = size - 1; i >= 0; --i) {
+ if(path[i] == '/')
+ return path + i + 1;
+ }
+ return path;
+ }
+
// |output_buffer| should be at least PATH_MAX in size
bool read_cmdline_arg0(const char *filepath, char *output_buffer, int output_buffer_size) {
output_buffer[0] = '\0';
+ const char *arg0_start = NULL;
const char *arg0_end = NULL;
+ int arg0_size = 0;
int fd = open(filepath, O_RDONLY);
if(fd == -1)
return false;
@@ -190,13 +200,16 @@ namespace gsr {
if(bytes_read == -1)
goto err;
- arg0_end = (const char*)memchr(buffer, '\0', bytes_read);
+ arg0_start = buffer;
+ arg0_end = (const char*)memchr(arg0_start, '\0', bytes_read);
if(!arg0_end)
goto err;
- if((arg0_end - buffer) + 1 <= output_buffer_size) {
- memcpy(output_buffer, buffer, arg0_end - buffer);
- output_buffer[arg0_end - buffer] = '\0';
+ arg0_start = get_basename(arg0_start, arg0_end - arg0_start);
+ arg0_size = arg0_end - arg0_start;
+ if(arg0_size + 1 <= output_buffer_size) {
+ memcpy(output_buffer, arg0_start, arg0_size);
+ output_buffer[arg0_size] = '\0';
close(fd);
return true;
}
diff --git a/src/main.cpp b/src/main.cpp
index 31ec8ff..a68ff7d 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -240,6 +240,11 @@ int main(int argc, char **argv) {
return 1;
}
+ if(gsr::pidof("gpu-screen-recorder", getpid()) != -1) {
+ const char *args[] = { "gsr-notify", "--text", "GPU Screen Recorder is already running in another process.\nPlease close it before using GPU Screen Recorder UI.", "--timeout", "5.0", "--icon-color", "ff0000", "--bg-color", "ff0000", nullptr };
+ gsr::exec_program_daemonized(args);
+ }
+
if(is_flatpak())
install_flatpak_systemd_service();
else