Show error notification if another gpu screen recorder process is running when starting the ui

This commit is contained in:
dec05eba
2025-06-04 01:32:30 +02:00
parent 636150ef08
commit 7d2f2e9b47
3 changed files with 25 additions and 5 deletions

4
TODO
View File

@@ -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.
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.

View File

@@ -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;
}

View File

@@ -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