Add emergency exit buttons, (left) ctrl+shift+alt+esc to close gpu screen recorder and remove it from system startup

This commit is contained in:
dec05eba
2025-04-09 18:27:31 +02:00
parent 746ce51e65
commit 9ada8caabc
5 changed files with 30 additions and 5 deletions

View File

@@ -38,8 +38,11 @@ There are also additional dependencies needed at runtime:
* [GPU Screen Recorder Notification](https://git.dec05eba.com/gpu-screen-recorder-notification/)
## Program behavior notes
This program has to grab all keyboards and create a virtual keyboard (`gsr-ui virtual keyboard`) to make global hotkeys work on all Wayland compositors.
This might cause issues for you if you use input remapping software. To workaround this you can go into settings and select "Only grab virtual devices"
This program has to grab all keyboards and create a virtual keyboard (`gsr-ui virtual keyboard`) to make global hotkeys work on all Wayland compositors.\
This might cause issues for you if you use input remapping software. To workaround this you can go into settings and select "Only grab virtual devices".\
If you use input remapping software such as keyd then make sure to make it ignore "gsr-ui virtual keyboard", otherwise your keyboard can get locked
as gpu screen recorder tries to grab keys and keyd grabs gpu screen recorder, leading to a lock.\
If you are stuck in such a lock where you cant press and keyboard keys you can press (left) ctrl+shift+alt+esc to close gpu screen recorder and remove it from system startup.
# License
This software is licensed under GPL3.0-only. Files under `fonts/` directory belong to the Noto Sans Google fonts project and they are licensed under `SIL Open Font License`.\

4
TODO
View File

@@ -113,6 +113,8 @@ Check if "modprobe uinput" is needed on some systems (old fedora?).
Add recording timer to see duration of recording/streaming.
Make folder with window name work when using gamescope. Gamescope runs x11 itself so to get the window name inside that we have to connect to the gamescope X11 server (DISPLAY=:1 on x11 and DISPLAY=:2 on wayland, but not always).
Detect if the window is gamescope automatically (WM_CLASS = "gamescope") and get the x11 display automatically and connect to it to get the application its running.
This seems to only be an issue on wayland? the window title of the gamescope/steam bigpicture mode is the title of the game on x11, so it works automatically on x11.
When clicking on current directory in file manager show a dropdown menu where you can select common directories (HOME, Videos, Downloads and mounted drives) for quick navigation. Maybe even button to search.
@@ -158,3 +160,5 @@ Notification with the focused monitor (with CursorTrackerWayland) assumes that t
If CursorTrackerWayland fails then fallback to getting focused monitor by window creation trick. Need to take into consideration prime laptop with dGPU that controls external monitors which cant be captured (different /dev/dri/card device).
Maybe automatically switch to recording with the device that controls the monitor.
In that case also add all monitors available to capture in the capture list and automatically choose the gpu that controls the monitor.
Support cjk font. Use fc-match to find the location of the font. This also works in flatpak, in which case the fonts are in /run/host/..., where it lists system fonts.

View File

@@ -65,6 +65,7 @@ namespace gsr {
bool is_open() const;
bool should_exit(std::string &reason) const;
void exit();
void go_back_to_old_ui();
const Config& get_config() const;

View File

@@ -338,6 +338,13 @@ namespace gsr {
fprintf(stderr, "pressed %s\n", id.c_str());
overlay->take_screenshot_region();
});
global_hotkeys->bind_key_press(
config_hotkey_to_hotkey(ConfigHotkey{ mgl::Keyboard::Key::Escape, HOTKEY_MOD_LCTRL | HOTKEY_MOD_LSHIFT | HOTKEY_MOD_LALT }),
"exit", [overlay](const std::string &id) {
fprintf(stderr, "pressed %s\n", id.c_str());
overlay->go_back_to_old_ui();
});
}
static std::unique_ptr<GlobalHotkeysLinux> register_linux_hotkeys(Overlay *overlay, GlobalHotkeysLinux::GrabType grab_type) {
@@ -1468,6 +1475,19 @@ namespace gsr {
do_exit = true;
}
void Overlay::go_back_to_old_ui() {
const bool inside_flatpak = getenv("FLATPAK_ID") != NULL;
if(inside_flatpak)
exit_reason = "back-to-old-ui";
else
exit_reason = "exit";
const char *args[] = { "systemctl", "disable", "--user", "gpu-screen-recorder-ui", nullptr };
std::string stdout_str;
exec_program_on_host_get_stdout(args, stdout_str);
exit();
}
const Config& Overlay::get_config() const {
return config;
}

View File

@@ -303,9 +303,6 @@ int main(int argc, char **argv) {
if(exit_reason == "back-to-old-ui") {
const char *args[] = { "gpu-screen-recorder-gtk", "use-old-ui", nullptr };
execvp(args[0], (char* const*)args);
} else if(exit_reason == "restart") {
const char *args[] = { "gsr-ui", "launch-show", nullptr };
execvp(args[0], (char* const*)args);
}
return 0;