diff options
author | dec05eba <dec05eba@protonmail.com> | 2023-04-09 16:27:37 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2023-04-09 16:27:43 +0200 |
commit | 902e18d6c5f1a6b87932582c87f56ccd4c9dac94 (patch) | |
tree | ce40c45d746f2b1d8a5f44cfe55fcb84e6e743d7 /src | |
parent | 6b78e40e256168742334897e1411fbe472b8b35a (diff) |
Make sure pkexec is installed when using flatpak and for the flatpak to be installed system-wide
Diffstat (limited to 'src')
-rw-r--r-- | src/main.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
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 "; |