From 902e18d6c5f1a6b87932582c87f56ccd4c9dac94 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 9 Apr 2023 16:27:37 +0200 Subject: Make sure pkexec is installed when using flatpak and for the flatpak to be installed system-wide --- src/main.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index 87a8e43..9c8636a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1540,6 +1540,10 @@ static bool is_pkexec_installed() { return is_program_installed({ "pkexec", 6 }); } +static bool flatpak_is_installed_as_system(void) { + return system("flatpak run --system --command=pwd com.dec05eba.gpu_screen_recorder") == 0; +} + typedef gboolean (*KeyPressHandler)(GtkButton *button, gpointer userdata); static void keypress_toggle_recording(bool recording_state, GtkButton *record_button, KeyPressHandler keypress_handler, GtkApplication *app) { if(!gtk_widget_get_sensitive(GTK_WIDGET(record_button))) @@ -2506,6 +2510,16 @@ static void activate(GtkApplication *app, gpointer userdata) { g_application_quit(G_APPLICATION(app)); return; } + + if(is_inside_flatpak() && !flatpak_is_installed_as_system()) { + GtkWidget *dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, + "GPU Screen Recorder needs to be installed system-wide to record your monitor on AMD/Intel. To install GPU Screen recorder system-wide, you can run this command:\n" + "flatpak install flathub --system com.dec05eba.gpu_screen_recorder"); + gtk_dialog_run(GTK_DIALOG(dialog)); + gtk_widget_destroy(dialog); + g_application_quit(G_APPLICATION(app)); + return; + } } std::string window_title = "GPU Screen Recorder | Running on "; -- cgit v1.2.3