mirror of
https://repo.dec05eba.com/gpu-screen-recorder-ui
synced 2026-04-24 10:39:51 +09:00
Add option to launch the program and show the UI immediately, with 'gsr-ui launch-show'
This commit is contained in:
@@ -985,7 +985,7 @@ namespace gsr {
|
|||||||
|
|
||||||
if(exit_status == 127) {
|
if(exit_status == 127) {
|
||||||
if(enable)
|
if(enable)
|
||||||
show_notification("Failed to add GPU Screen Recorder to system startup.\nThis option only works on systems that use systemd.\nYou have to manually add gsr-ui to system startup on systems that uses another init system.", 10.0, mgl::Color(255, 0, 0), mgl::Color(255, 0, 0), NotificationType::NONE);
|
show_notification("Failed to add GPU Screen Recorder to system startup.\nThis option only works on systems that use systemd.\nYou have to manually add \"gsr-ui\" to system startup on systems that uses another init system.", 10.0, mgl::Color(255, 0, 0), mgl::Color(255, 0, 0), NotificationType::NONE);
|
||||||
} else {
|
} else {
|
||||||
if(enable)
|
if(enable)
|
||||||
show_notification("Failed to add GPU Screen Recorder to system startup", 3.0, mgl::Color(255, 0, 0), mgl::Color(255, 0, 0), NotificationType::NONE);
|
show_notification("Failed to add GPU Screen Recorder to system startup", 3.0, mgl::Color(255, 0, 0), mgl::Color(255, 0, 0), NotificationType::NONE);
|
||||||
|
|||||||
38
src/main.cpp
38
src/main.cpp
@@ -1,6 +1,5 @@
|
|||||||
#include "../include/GsrInfo.hpp"
|
#include "../include/GsrInfo.hpp"
|
||||||
#include "../include/Theme.hpp"
|
#include "../include/Theme.hpp"
|
||||||
#include "../include/window_texture.h"
|
|
||||||
#include "../include/Overlay.hpp"
|
#include "../include/Overlay.hpp"
|
||||||
#include "../include/GlobalHotkeysX11.hpp"
|
#include "../include/GlobalHotkeysX11.hpp"
|
||||||
#include "../include/GlobalHotkeysLinux.hpp"
|
#include "../include/GlobalHotkeysLinux.hpp"
|
||||||
@@ -9,6 +8,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include <X11/keysym.h>
|
#include <X11/keysym.h>
|
||||||
#include <mglpp/mglpp.hpp>
|
#include <mglpp/mglpp.hpp>
|
||||||
@@ -132,7 +132,21 @@ static std::unique_ptr<gsr::GlobalHotkeysLinux> register_linux_hotkeys(gsr::Over
|
|||||||
return global_hotkeys;
|
return global_hotkeys;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void) {
|
static void usage() {
|
||||||
|
printf("usage: gsr-ui [action]\n");
|
||||||
|
printf("OPTIONS:\n");
|
||||||
|
printf(" action The launch action. Should be either \"launch-show\" or \"launch-hide\". Optional, defaults to \"launch-hide\".\n");
|
||||||
|
printf(" If \"launch-show\" is used then the program starts and the UI is immediately opened and can be shown/hidden with Alt+Z.\n");
|
||||||
|
printf(" If \"launch-hide\" is used then the program starts but the UI is not opened until Alt+Z is pressed.\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
enum class LaunchAction {
|
||||||
|
LAUNCH_SHOW,
|
||||||
|
LAUNCH_HIDE
|
||||||
|
};
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
setlocale(LC_ALL, "C"); // Sigh... stupid C
|
setlocale(LC_ALL, "C"); // Sigh... stupid C
|
||||||
|
|
||||||
if(geteuid() == 0) {
|
if(geteuid() == 0) {
|
||||||
@@ -140,6 +154,22 @@ int main(void) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LaunchAction launch_action = LaunchAction::LAUNCH_HIDE;
|
||||||
|
if(argc == 1) {
|
||||||
|
launch_action = LaunchAction::LAUNCH_HIDE;
|
||||||
|
} else if(argc == 2) {
|
||||||
|
if(strcmp(argv[1], "launch-show") == 0) {
|
||||||
|
launch_action = LaunchAction::LAUNCH_SHOW;
|
||||||
|
} else if(strcmp(argv[1], "launch-hide") == 0) {
|
||||||
|
launch_action = LaunchAction::LAUNCH_HIDE;
|
||||||
|
} else {
|
||||||
|
printf("error: invalid action \"%s\", expected \"launch-show\" or \"launch-hide\".\n", argv[1]);
|
||||||
|
usage();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
usage();
|
||||||
|
}
|
||||||
|
|
||||||
// Cant get window texture when prime-run is used
|
// Cant get window texture when prime-run is used
|
||||||
disable_prime_run();
|
disable_prime_run();
|
||||||
|
|
||||||
@@ -201,7 +231,6 @@ int main(void) {
|
|||||||
fprintf(stderr, "Info: gsr ui is now ready, waiting for inputs. Press alt+z to show/hide the overlay\n");
|
fprintf(stderr, "Info: gsr ui is now ready, waiting for inputs. Press alt+z to show/hide the overlay\n");
|
||||||
|
|
||||||
auto overlay = std::make_unique<gsr::Overlay>(resources_path, std::move(gsr_info), std::move(capture_options), egl_funcs);
|
auto overlay = std::make_unique<gsr::Overlay>(resources_path, std::move(gsr_info), std::move(capture_options), egl_funcs);
|
||||||
//overlay.show();
|
|
||||||
|
|
||||||
// std::unique_ptr<gsr::GlobalHotkeys> global_hotkeys = nullptr;
|
// std::unique_ptr<gsr::GlobalHotkeys> global_hotkeys = nullptr;
|
||||||
// if(display_server == gsr::DisplayServer::X11) {
|
// if(display_server == gsr::DisplayServer::X11) {
|
||||||
@@ -215,6 +244,9 @@ int main(void) {
|
|||||||
// }
|
// }
|
||||||
std::unique_ptr<gsr::GlobalHotkeys> global_hotkeys = register_linux_hotkeys(overlay.get());
|
std::unique_ptr<gsr::GlobalHotkeys> global_hotkeys = register_linux_hotkeys(overlay.get());
|
||||||
|
|
||||||
|
if(launch_action == LaunchAction::LAUNCH_SHOW)
|
||||||
|
overlay->show();
|
||||||
|
|
||||||
// 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.
|
||||||
|
|
||||||
mgl::Clock frame_delta_clock;
|
mgl::Clock frame_delta_clock;
|
||||||
|
|||||||
Reference in New Issue
Block a user