From df1610431dc44007c472a3877f2eca16b8d0bea4 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 31 Dec 2025 16:29:11 +0100 Subject: [PATCH] Add application icon, show gsr icon in notification --- depends/mglpp | 2 +- gpu-screen-recorder.desktop | 10 +++++ .../128x128/apps/gpu-screen-recorder.png | Bin 0 -> 3709 bytes .../32x32/apps/gpu-screen-recorder.png | Bin 0 -> 2202 bytes .../64x64/apps/gpu-screen-recorder.png | Bin 0 -> 2110 bytes include/Overlay.hpp | 6 ++- meson.build | 7 +++ src/Overlay.cpp | 23 ++++++---- src/main.cpp | 40 ++++++++++++------ 9 files changed, 64 insertions(+), 24 deletions(-) create mode 100644 gpu-screen-recorder.desktop create mode 100644 icons/hicolor/128x128/apps/gpu-screen-recorder.png create mode 100644 icons/hicolor/32x32/apps/gpu-screen-recorder.png create mode 100644 icons/hicolor/64x64/apps/gpu-screen-recorder.png diff --git a/depends/mglpp b/depends/mglpp index cdd4014..f69b0d3 160000 --- a/depends/mglpp +++ b/depends/mglpp @@ -1 +1 @@ -Subproject commit cdd401478d8e70a895e06415e95c077f3fdd0ba5 +Subproject commit f69b0d3ee0f6278974470f7f1ff0abdd23398ffe diff --git a/gpu-screen-recorder.desktop b/gpu-screen-recorder.desktop new file mode 100644 index 0000000..078911a --- /dev/null +++ b/gpu-screen-recorder.desktop @@ -0,0 +1,10 @@ +[Desktop Entry] +Type=Application +Name=GPU Screen Recorder +GenericName=Screen recorder +Comment=A ShadowPlay-like screen recorder for Linux +Icon=gpu-screen-recorder +Exec=gsr-ui launch-hide-announce +Terminal=false +Keywords=gpu-screen-recorder;gsr-ui;screen recorder;streaming;twitch;replay;shadowplay; +Categories=AudioVideo;Recorder; diff --git a/icons/hicolor/128x128/apps/gpu-screen-recorder.png b/icons/hicolor/128x128/apps/gpu-screen-recorder.png new file mode 100644 index 0000000000000000000000000000000000000000..f2b99a10982ad91c572e03e0ce1b8d75d65a1901 GIT binary patch literal 3709 zcmV-@4ubKCP)mHk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ZK`HhBqrIcIcEQTlM%6|hFBp}6j0OYO9a-(^2EyMaPEiNc4c^mG$ zdlC#Ed4t)7|7*yfUKYjuE-hUEwFtCn;ZWqqUGZPL-L3G>rfu-?N1uaF8p`tXoC;7?u1Xae{M$M?-fmd)CfHo6nxE}Cb4f_RY(8FYAIJ0 zpMM3T$K9y9zCfH}iIKd3gIcvQF)@0fC8s#dIC}Vr(cC~yyN6D=ZH$x)KufjSY*uL+ znB9JbYM4vhdR)DGDYGeHm4H6l; zVJ(!e91r1)1t>2O6Ndj3d~xC#T3tYfZcyJkK8%4qn>Yx}z*Jr&imvU0yc<~{`XYug z5b@UW9)Y$9KfY6kf*HnurwbSuuEsFp3p_V42GC};ba)G(D=PB`f!)a~dFmzn3q8BV zmI63491AP4DoB16uz561|k^~-6~U&;U`e`JFA zfnHqih5)%+FCt$;dUm6xOxcf+wA$w6XcXW(3QQ;JP;iD2#tfrEEXQL&ln0fSp3%{&0yd;Ze~o zv?Isrf(%P5p5%=l^ulGV%^H^-D_t=nm?U0gB{|tc$vBh(*dr+;;cw484jBopEPkCa zyCDbGITdq3X+*X^$m#k1pj?6MXcT}9h|R*#@YlM@{%?PGiyOM5@Vi-fkte+|(AKP0 z)DQVQ@+oAEIA;}o|5HL%nib$aVepk8Jx@R}-s#9GN;k0RJ00{AQdSm?=#~q6UuyIKnC(Rf{ZxS9EORZ-U2LKj=g<^ zL%O+WrOuxSkZk9g)f?MB0Vv(4{r=jM5h_6Kcai^yJCi2vv#>e>luoa(^Cx!!3|0U} zbPBMTtHHFGMhY++Ig9JURG?Wz6f9cf=>lE_IcEHRG~e3X!b`k&6dEry>-AMDL7v?u b%_aOl@cXj3At7Tl00000NkvXXu0mjf!nxJ# literal 0 HcmV?d00001 diff --git a/icons/hicolor/32x32/apps/gpu-screen-recorder.png b/icons/hicolor/32x32/apps/gpu-screen-recorder.png new file mode 100644 index 0000000000000000000000000000000000000000..431162b4151ccdeafc2b12714f3fe4b777aa7c2b GIT binary patch literal 2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7833c&}r!=0{S*3vOE8{|C29}xaes-I(@QxRqyux0JWx# za1^QCa5=}e#{0*<`4Oj1obg!YrA+~~#^ud{!X@$ixr<(r3()x@`T%}QW*Sr~CCnzv z-gEm>sZ@GzGDImfG(^^spi}@ljsD)e&pbv6gV88{fW8`c;s=}qV0pjZiK?q=5ioY}fQny@D`7}4X|1CaCXu+9|e$dWk=i1F2I&?P76^l`JVW`p+u z@O;t|ew^?rDF7r`mkv5Tu6u#-UI}zh($07*qoM6N<$g4@Xk!~g&Q literal 0 HcmV?d00001 diff --git a/include/Overlay.hpp b/include/Overlay.hpp index 284dd70..e39765b 100644 --- a/include/Overlay.hpp +++ b/include/Overlay.hpp @@ -40,7 +40,8 @@ namespace gsr { RECORD, REPLAY, STREAM, - SCREENSHOT + SCREENSHOT, + NOTICE }; enum class NotificationLevel { @@ -98,6 +99,7 @@ namespace gsr { bool global_hotkeys_ungrab_keyboard = false; private: + const char* notification_type_to_string(NotificationType notification_type); void update_upause_status(); void hide(); @@ -171,6 +173,8 @@ namespace gsr { Config config; Config current_recording_config; + std::string gsr_icon_path; + bool visible = false; mgl::Texture window_texture_texture; diff --git a/meson.build b/meson.build index 584a35a..2dfbd96 100644 --- a/meson.build +++ b/meson.build @@ -64,6 +64,7 @@ mglpp_dep = mglpp_proj.get_variable('mglpp_dep') prefix = get_option('prefix') datadir = get_option('datadir') gsr_ui_resources_path = join_paths(prefix, datadir, 'gsr-ui') +icons_path = join_paths(prefix, datadir, 'icons') add_project_arguments('-DGSR_UI_VERSION="' + meson.project_version() + '"', language: ['c', 'cpp']) add_project_arguments('-DGSR_FLATPAK_VERSION="5.11.1"', language: ['c', 'cpp']) @@ -112,6 +113,12 @@ executable( install_subdir('images', install_dir : gsr_ui_resources_path) install_subdir('fonts', install_dir : gsr_ui_resources_path) +install_data(files('gpu-screen-recorder.desktop'), install_dir : join_paths(prefix, datadir, 'applications')) +install_subdir('icons/hicolor', install_dir : icons_path) + +gnome = import('gnome') +gnome.post_install(update_desktop_database : true) + if get_option('systemd') == true install_data(files('extra/gpu-screen-recorder-ui.service'), install_dir : 'lib/systemd/user') endif diff --git a/src/Overlay.cpp b/src/Overlay.cpp index cb20682..dbf7aab 100644 --- a/src/Overlay.cpp +++ b/src/Overlay.cpp @@ -473,6 +473,8 @@ namespace gsr { top_bar_background({0.0f, 0.0f}), close_button_widget({0.0f, 0.0f}) { + gsr_icon_path = this->resources_path + "images/gpu_screen_recorder_logo.png"; + key_bindings[0].key_event.code = mgl::Keyboard::Escape; key_bindings[0].key_event.alt = false; key_bindings[0].key_event.control = false; @@ -519,7 +521,7 @@ namespace gsr { if(!config.main_config.wayland_warning_shown) { config.main_config.wayland_warning_shown = true; save_config(config); - show_notification("Wayland doesn't support GPU Screen Recorder UI properly,\nthings may not work as expected. Use X11 if you experience issues.", notification_error_timeout_seconds, mgl::Color(255, 0, 0), mgl::Color(255, 0, 0), NotificationType::NONE, nullptr, NotificationLevel::ERROR); + show_notification("Wayland doesn't support GPU Screen Recorder UI properly,\nthings may not work as expected. Use X11 if you experience issues.", notification_error_timeout_seconds, mgl::Color(255, 255, 255), mgl::Color(255, 0, 0), NotificationType::NOTICE, nullptr, NotificationLevel::ERROR); } } @@ -735,7 +737,7 @@ namespace gsr { show_notification( "Some keyboard remapping software conflicts with GPU Screen Recorder on your system.\n" "Keyboards have been ungrabbed, applications will now receive the hotkeys you press." - , 7.0, mgl::Color(255, 0, 0), mgl::Color(255, 0, 0), NotificationType::NONE, nullptr, NotificationLevel::ERROR); + , 7.0, mgl::Color(255, 255, 255), mgl::Color(255, 0, 0), NotificationType::NOTICE, nullptr, NotificationLevel::ERROR); config.main_config.hotkeys_enable_option = "enable_hotkeys_no_grab"; save_config(config); @@ -774,7 +776,7 @@ namespace gsr { if(selected_window && selected_window != DefaultRootWindow(display)) { on_window_selected(); } else { - show_notification("No window selected", notification_timeout_seconds, mgl::Color(255, 0, 0), mgl::Color(255, 0, 0), NotificationType::NONE, nullptr, NotificationLevel::ERROR); + show_notification("No window selected", notification_timeout_seconds, mgl::Color(255, 255, 255), mgl::Color(255, 0, 0), NotificationType::NOTICE, nullptr, NotificationLevel::ERROR); } on_window_selected = nullptr; } @@ -825,7 +827,7 @@ namespace gsr { start_region_capture = false; hide(); if(!region_selector.start(get_color_theme().tint_color)) { - show_notification("Failed to start region capture", notification_error_timeout_seconds, mgl::Color(255, 0, 0), mgl::Color(255, 0, 0), NotificationType::NONE, nullptr, NotificationLevel::ERROR); + show_notification("Failed to start region capture", notification_error_timeout_seconds, mgl::Color(255, 255, 255), mgl::Color(255, 0, 0), NotificationType::NOTICE, nullptr, NotificationLevel::ERROR); on_region_selected = nullptr; } } @@ -834,7 +836,7 @@ namespace gsr { start_window_capture = false; hide(); if(!window_selector.start(get_color_theme().tint_color)) { - show_notification("Failed to start window capture", notification_error_timeout_seconds, mgl::Color(255, 0, 0), mgl::Color(255, 0, 0), NotificationType::NONE, nullptr, NotificationLevel::ERROR); + show_notification("Failed to start window capture", notification_error_timeout_seconds, mgl::Color(255, 255, 255), mgl::Color(255, 0, 0), NotificationType::NOTICE, nullptr, NotificationLevel::ERROR); on_window_selected = nullptr; } } @@ -1321,12 +1323,12 @@ namespace gsr { if(exit_status == 127) { 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.", 7.0, mgl::Color(255, 0, 0), mgl::Color(255, 0, 0), NotificationType::NONE, nullptr, NotificationLevel::ERROR); + 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.", 7.0, mgl::Color(255, 255, 255), mgl::Color(255, 0, 0), NotificationType::NOTICE, nullptr, NotificationLevel::ERROR); } else { if(enable) - show_notification("Failed to add GPU Screen Recorder to system startup", notification_timeout_seconds, mgl::Color(255, 0, 0), mgl::Color(255, 0, 0), NotificationType::NONE, nullptr, NotificationLevel::ERROR); + show_notification("Failed to add GPU Screen Recorder to system startup", notification_timeout_seconds, mgl::Color(255, 255, 255), mgl::Color(255, 0, 0), NotificationType::NOTICE, nullptr, NotificationLevel::ERROR); else - show_notification("Failed to remove GPU Screen Recorder from system startup", notification_timeout_seconds, mgl::Color(255, 0, 0), mgl::Color(255, 0, 0), NotificationType::NONE, nullptr, NotificationLevel::ERROR); + show_notification("Failed to remove GPU Screen Recorder from system startup", notification_timeout_seconds, mgl::Color(255, 255, 255), mgl::Color(255, 0, 0), NotificationType::NOTICE, nullptr, NotificationLevel::ERROR); } }; @@ -1576,13 +1578,14 @@ namespace gsr { on_press_take_screenshot(false, ScreenshotForceType::WINDOW); } - static const char* notification_type_to_string(NotificationType notification_type) { + const char* Overlay::notification_type_to_string(NotificationType notification_type) { switch(notification_type) { case NotificationType::NONE: return nullptr; case NotificationType::RECORD: return "record"; case NotificationType::REPLAY: return "replay"; case NotificationType::STREAM: return "stream"; case NotificationType::SCREENSHOT: return "screenshot"; + case NotificationType::NOTICE: return gsr_icon_path.c_str(); } return nullptr; } @@ -1972,6 +1975,7 @@ namespace gsr { } case NotificationType::NONE: case NotificationType::STREAM: + case NotificationType::NOTICE: break; } show_notification(msg, notification_timeout_seconds, mgl::Color(255, 255, 255), get_color_theme().tint_color, notification_type, capture_target); @@ -2070,6 +2074,7 @@ namespace gsr { const char *prefix = ""; switch(notification_type) { case NotificationType::NONE: + case NotificationType::NOTICE: break; case NotificationType::SCREENSHOT: prefix = "Failed to take a screenshot"; diff --git a/src/main.cpp b/src/main.cpp index 24939ec..14d9185 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,6 +3,7 @@ #include "../include/gui/Utils.hpp" #include "../include/Process.hpp" #include "../include/Rpc.hpp" +#include "../include/Theme.hpp" #include #include @@ -174,6 +175,7 @@ static void usage() { enum class LaunchAction { LAUNCH_SHOW, LAUNCH_HIDE, + LAUNCH_HIDE_ANNOUNCE, LAUNCH_DAEMON }; @@ -197,6 +199,8 @@ int main(int argc, char **argv) { launch_action = LaunchAction::LAUNCH_SHOW; } else if(strcmp(launch_action_opt, "launch-hide") == 0) { launch_action = LaunchAction::LAUNCH_HIDE; + } else if(strcmp(launch_action_opt, "launch-hide-announce") == 0) { + launch_action = LaunchAction::LAUNCH_HIDE_ANNOUNCE; } else if(strcmp(launch_action_opt, "launch-daemon") == 0) { launch_action = LaunchAction::LAUNCH_DAEMON; } else { @@ -209,6 +213,19 @@ int main(int argc, char **argv) { set_display_server_environment_variables(); + std::string resources_path; + if(access("sibs-build/linux_x86_64/debug/gsr-ui", F_OK) == 0) { + resources_path = "./"; + } else { +#ifdef GSR_UI_RESOURCES_PATH + resources_path = GSR_UI_RESOURCES_PATH "/"; +#else + resources_path = "/usr/share/gsr-ui/"; +#endif + } + + const std::string gsr_icon_path = resources_path + "images/gpu_screen_recorder_logo.png"; + auto rpc = std::make_unique(); const gsr::RpcOpenResult rpc_open_result = rpc->open("gsr-ui"); @@ -220,7 +237,10 @@ int main(int argc, char **argv) { fprintf(stderr, "Error: another instance of gsr-ui is already running, opening that one instead\n"); } 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"); - const char *args[] = { "gsr-notify", "--text", "Another instance of GPU Screen Recorder UI is already running.\nPress Alt+Z to open the UI.", "--timeout", "5.0", "--icon-color", "ff0000", "--bg-color", "ff0000", nullptr }; + const char *args[] = { + "gsr-notify", "--text", "Another instance of GPU Screen Recorder UI is already running.\nPress Alt+Z to open the UI.", "--timeout", "5.0", + "--icon-color", "ffffff", "--icon", gsr_icon_path.c_str(), "--bg-color", "ff0000", nullptr + }; gsr::exec_program_daemonized(args); } return 1; @@ -230,7 +250,10 @@ int main(int argc, char **argv) { fprintf(stderr, "Error: Failed to create rpc\n"); if(gsr::pidof("gpu-screen-recorder", -1) != -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", "ffffff", "--icon", gsr_icon_path.c_str(), "--bg-color", "ff0000", nullptr + }; gsr::exec_program_daemonized(args); } @@ -284,17 +307,6 @@ int main(int argc, char **argv) { gsr::SupportedCaptureOptions capture_options = gsr::get_supported_capture_options(gsr_info); - std::string resources_path; - if(access("sibs-build/linux_x86_64/debug/gsr-ui", F_OK) == 0) { - resources_path = "./"; - } else { -#ifdef GSR_UI_RESOURCES_PATH - resources_path = GSR_UI_RESOURCES_PATH "/"; -#else - resources_path = "/usr/share/gsr-ui/"; -#endif - } - mgl_context *context = mgl_get_context(); egl_functions egl_funcs; @@ -313,6 +325,8 @@ int main(int argc, char **argv) { auto overlay = std::make_unique(resources_path, std::move(gsr_info), std::move(capture_options), egl_funcs); if(launch_action == LaunchAction::LAUNCH_SHOW) overlay->show(); + else if(launch_action == LaunchAction::LAUNCH_HIDE_ANNOUNCE) + overlay->show_notification("Press Alt+Z to open the GPU Screen Recorder UI", 5.0, mgl::Color(255, 255, 255), gsr::get_color_theme().tint_color, gsr::NotificationType::NOTICE, nullptr, gsr::NotificationLevel::ERROR); rpc_add_commands(rpc.get(), overlay.get());