diff options
author | dec05eba <dec05eba@protonmail.com> | 2023-04-08 07:10:10 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2023-04-08 07:10:10 +0200 |
commit | 6b78e40e256168742334897e1411fbe472b8b35a (patch) | |
tree | 5dff9654e670a68a00d3ddf0acf09352d9658727 /src | |
parent | 3b775bd7f121a8309b1baa2c67296e5770a17dc1 (diff) |
Show error if pkexec is not installed (on flatpak too)
Diffstat (limited to 'src')
-rw-r--r-- | src/main.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/main.cpp b/src/main.cpp index 31e4639..87a8e43 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1529,8 +1529,15 @@ static bool is_program_installed(const StringView program_name) { return program_installed; } +static bool is_inside_flatpak(void) { + return getenv("FLATPAK_ID") != NULL; +} + static bool is_pkexec_installed() { - return is_program_installed({ "pkexec", 6 }); + if(is_inside_flatpak()) + return system("flatpak-spawn --host pkexec --version") == 0; + else + return is_program_installed({ "pkexec", 6 }); } typedef gboolean (*KeyPressHandler)(GtkButton *button, gpointer userdata); @@ -2490,6 +2497,15 @@ static void activate(GtkApplication *app, gpointer userdata) { g_application_quit(G_APPLICATION(app)); return; } + } else { + if(!is_pkexec_installed()) { + GtkWidget *dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, + "pkexec needs to be installed to record a monitor with an AMD/Intel GPU. Please install and run polkit."); + 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 "; |