mirror of
https://repo.dec05eba.com/gpu-screen-recorder-ui
synced 2026-03-31 09:17:04 +09:00
Add better single instance detection (use rpc fifo file existence with unlink to detect process instead of pidof gsr-ui)
This commit is contained in:
10
TODO
10
TODO
@@ -195,3 +195,13 @@ Add a window that shows a warning for wayland users, that wayland doesn't suppor
|
|||||||
Add a window that shows a warning if gpu video encoding isn't supported.
|
Add a window that shows a warning if gpu video encoding isn't supported.
|
||||||
|
|
||||||
Disable system notifications when recording. Does the notification dbus interface support pausing notifications?
|
Disable system notifications when recording. Does the notification dbus interface support pausing notifications?
|
||||||
|
|
||||||
|
Automatically mark window region in window capture for screenshot on x11.
|
||||||
|
|
||||||
|
Disable hotkeys if virtual keyboard is found (either at startup or after running), if grab type if not virtual. Show a notification if that happens that hotkeys have been disabled.
|
||||||
|
Detect if keyboard is locked by listening to gsr-ui virtual keyboard events and if no event is received after pressing a key (when writing to it after receiving input from another keyboard)
|
||||||
|
then remove the keyboard grab and show a message or something.
|
||||||
|
This can happen if the gsr-ui virtual keyboard is grabbed by some other software.
|
||||||
|
Maybe this can be fixed automatically by grabbing gsr-ui virtual keyboard and releasing it just before we write to it and then release it again.
|
||||||
|
But wont keyboard remapping software grab the keyboard first if they detect it quickly?
|
||||||
|
If we fail to grab it because some other software did then dont grab any keyboards nor gsr-ui virtual keyboards, just listen to them.
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ namespace gsr {
|
|||||||
fclose(file);
|
fclose(file);
|
||||||
|
|
||||||
if(!fifo_filepath.empty())
|
if(!fifo_filepath.empty())
|
||||||
remove(fifo_filepath.c_str());
|
unlink(fifo_filepath.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Rpc::create(const char *name) {
|
bool Rpc::create(const char *name) {
|
||||||
@@ -44,15 +44,16 @@ namespace gsr {
|
|||||||
char fifo_filepath_tmp[PATH_MAX];
|
char fifo_filepath_tmp[PATH_MAX];
|
||||||
get_runtime_filepath(fifo_filepath_tmp, sizeof(fifo_filepath_tmp), name);
|
get_runtime_filepath(fifo_filepath_tmp, sizeof(fifo_filepath_tmp), name);
|
||||||
fifo_filepath = fifo_filepath_tmp;
|
fifo_filepath = fifo_filepath_tmp;
|
||||||
remove(fifo_filepath.c_str());
|
unlink(fifo_filepath.c_str());
|
||||||
|
|
||||||
if(mkfifo(fifo_filepath.c_str(), 0600) != 0) {
|
if(mkfifo(fifo_filepath.c_str(), 0600) != 0) {
|
||||||
fprintf(stderr, "Error: mkfifo failed, error: %s, %s\n", strerror(errno), fifo_filepath.c_str());
|
fprintf(stderr, "Error: mkfifo failed, error: %s, %s\n", strerror(errno), fifo_filepath.c_str());
|
||||||
|
fifo_filepath.clear();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!open_filepath(fifo_filepath.c_str())) {
|
if(!open_filepath(fifo_filepath.c_str())) {
|
||||||
remove(fifo_filepath.c_str());
|
unlink(fifo_filepath.c_str());
|
||||||
fifo_filepath.clear();
|
fifo_filepath.clear();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
32
src/main.cpp
32
src/main.cpp
@@ -14,7 +14,6 @@
|
|||||||
#include <mglpp/system/Clock.hpp>
|
#include <mglpp/system/Clock.hpp>
|
||||||
|
|
||||||
// TODO: Make keyboard/controller controllable for steam deck (and other controllers).
|
// TODO: Make keyboard/controller controllable for steam deck (and other controllers).
|
||||||
// TODO: Keep track of gpu screen recorder run by other programs to not allow recording at the same time, or something.
|
|
||||||
// TODO: Add systray by using org.kde.StatusNotifierWatcher/etc dbus directly.
|
// TODO: Add systray by using org.kde.StatusNotifierWatcher/etc dbus directly.
|
||||||
// TODO: Make sure the overlay always stays on top. Test with starting the overlay and then opening youtube in fullscreen.
|
// TODO: Make sure the overlay always stays on top. Test with starting the overlay and then opening youtube in fullscreen.
|
||||||
// This is done in Overlay::force_window_on_top, but it's not called right now. It cant be used because the overlay will be on top of
|
// This is done in Overlay::force_window_on_top, but it's not called right now. It cant be used because the overlay will be on top of
|
||||||
@@ -220,17 +219,17 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
set_display_server_environment_variables();
|
set_display_server_environment_variables();
|
||||||
|
|
||||||
// TODO: This is a shitty method to detect if multiple instances of gsr-ui is running but this will work properly even in flatpak
|
auto rpc = std::make_unique<gsr::Rpc>();
|
||||||
// that uses pid sandboxing. Replace this with a better method once we no longer rely on linux global hotkeys on some platform.
|
const bool rpc_created = rpc->create("gsr-ui");
|
||||||
// TODO: This method doesn't work when disabling hotkeys and the method below with pidof gsr-ui doesn't work in flatpak.
|
if(!rpc_created)
|
||||||
// What do? creating a pid file doesn't work in flatpak either.
|
fprintf(stderr, "Error: Failed to create rpc\n");
|
||||||
// TODO: This doesn't work in flatpak when disabling hotkeys.
|
|
||||||
if(is_gsr_ui_virtual_keyboard_running() || gsr::pidof("gsr-ui", getpid()) != -1) {
|
if(is_gsr_ui_virtual_keyboard_running() || !rpc_created) {
|
||||||
if(launch_action == LaunchAction::LAUNCH_DAEMON)
|
if(launch_action == LaunchAction::LAUNCH_DAEMON)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
gsr::Rpc rpc;
|
rpc = std::make_unique<gsr::Rpc>();
|
||||||
if(rpc.open("gsr-ui") && rpc.write("show_ui\n", 8)) {
|
if(rpc->open("gsr-ui") && rpc->write("show_ui\n", 8)) {
|
||||||
fprintf(stderr, "Error: another instance of gsr-ui is already running, opening that one instead\n");
|
fprintf(stderr, "Error: another instance of gsr-ui is already running, opening that one instead\n");
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "Error: failed to send command to running gsr-ui instance, user will have to open the UI manually with Alt+Z\n");
|
fprintf(stderr, "Error: failed to send command to running gsr-ui instance, user will have to open the UI manually with Alt+Z\n");
|
||||||
@@ -243,6 +242,12 @@ int main(int argc, char **argv) {
|
|||||||
if(gsr::pidof("gpu-screen-recorder", getpid()) != -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 };
|
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);
|
gsr::exec_program_daemonized(args);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(mgl_init(MGL_WINDOW_SYSTEM_X11) != 0) {
|
||||||
|
fprintf(stderr, "Error: failed to initialize mgl. Failed to either connect to the X11 server or setup opengl\n");
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_flatpak())
|
if(is_flatpak())
|
||||||
@@ -288,11 +293,6 @@ int main(int argc, char **argv) {
|
|||||||
disable_prime_run();
|
disable_prime_run();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mgl_init(MGL_WINDOW_SYSTEM_X11) != 0) {
|
|
||||||
fprintf(stderr, "Error: failed to initialize mgl. Failed to either connect to the X11 server or setup opengl\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
gsr::SupportedCaptureOptions capture_options = gsr::get_supported_capture_options(gsr_info);
|
gsr::SupportedCaptureOptions capture_options = gsr::get_supported_capture_options(gsr_info);
|
||||||
|
|
||||||
std::string resources_path;
|
std::string resources_path;
|
||||||
@@ -325,10 +325,6 @@ int main(int argc, char **argv) {
|
|||||||
if(launch_action == LaunchAction::LAUNCH_SHOW)
|
if(launch_action == LaunchAction::LAUNCH_SHOW)
|
||||||
overlay->show();
|
overlay->show();
|
||||||
|
|
||||||
auto rpc = std::make_unique<gsr::Rpc>();
|
|
||||||
if(!rpc->create("gsr-ui"))
|
|
||||||
fprintf(stderr, "Error: Failed to create rpc, commands won't be received\n");
|
|
||||||
|
|
||||||
rpc_add_commands(rpc.get(), overlay.get());
|
rpc_add_commands(rpc.get(), overlay.get());
|
||||||
|
|
||||||
// TODO: Add hotkeys in Overlay when using x11 global hotkeys. The hotkeys in Overlay should duplicate each key that is used for x11 global hotkeys.
|
// TODO: Add hotkeys in Overlay when using x11 global hotkeys. The hotkeys in Overlay should duplicate each key that is used for x11 global hotkeys.
|
||||||
|
|||||||
Reference in New Issue
Block a user