From c987121acf5c87436a0b05ca75cd70bf38c452ca Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Sun, 27 Mar 2022 19:12:55 +0200 Subject: [PATCH] glib: Add support for GNOME Console MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GNOME Console (aka King’s Cross) is the default terminal emulator in GNOME 42. Let’s make GLib aware of it so that apps relying on it (e.g. GNOME Shell) can launch terminal apps like htop. This is a downstream patch since GLib does not want to add any more terminal emulators: https://gitlab.gnome.org/GNOME/glib/-/issues/2618 --- pkgs/development/libraries/glib/default.nix | 4 ++ .../glib/gnome-console-support.patch | 55 +++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 pkgs/development/libraries/glib/gnome-console-support.patch diff --git a/pkgs/development/libraries/glib/default.nix b/pkgs/development/libraries/glib/default.nix index f057618e7880..f2b6df3c855a 100644 --- a/pkgs/development/libraries/glib/default.nix +++ b/pkgs/development/libraries/glib/default.nix @@ -69,6 +69,10 @@ stdenv.mkDerivation rec { ./glib-appinfo-watch.patch ./schema-override-variable.patch + # Add support for the GNOME’s default terminal emulator. + # https://gitlab.gnome.org/GNOME/glib/-/issues/2618 + ./gnome-console-support.patch + # GLib contains many binaries used for different purposes; # we will install them to different outputs: # 1. Tools for desktop environment ($bin) diff --git a/pkgs/development/libraries/glib/gnome-console-support.patch b/pkgs/development/libraries/glib/gnome-console-support.patch new file mode 100644 index 000000000000..7f6894a5cec9 --- /dev/null +++ b/pkgs/development/libraries/glib/gnome-console-support.patch @@ -0,0 +1,55 @@ +diff --git a/gio/gdesktopappinfo.c b/gio/gdesktopappinfo.c +index 60d6debb2..a441bfec9 100644 +--- a/gio/gdesktopappinfo.c ++++ b/gio/gdesktopappinfo.c +@@ -2627,6 +2627,7 @@ prepend_terminal_to_vector (int *argc, + int i, j; + char **term_argv = NULL; + int term_argc = 0; ++ gboolean pass_cmd_as_single_arg = FALSE; + char *check; + char **the_argv; + +@@ -2672,6 +2673,11 @@ prepend_terminal_to_vector (int *argc, + } + else + { ++ if (check == NULL) { ++ check = g_find_program_in_path ("kgx"); ++ if (check != NULL) ++ pass_cmd_as_single_arg = TRUE; ++ } + if (check == NULL) + check = g_find_program_in_path ("tilix"); + if (check == NULL) +@@ -2697,14 +2703,27 @@ prepend_terminal_to_vector (int *argc, + } + } + +- real_argc = term_argc + *argc; ++ real_argc = term_argc + (pass_cmd_as_single_arg ? 1 : *argc); + real_argv = g_new (char *, real_argc + 1); + + for (i = 0; i < term_argc; i++) + real_argv[i] = term_argv[i]; + +- for (j = 0; j < *argc; j++, i++) +- real_argv[i] = (char *)the_argv[j]; ++ if (pass_cmd_as_single_arg) { ++ char **quoted_argv = g_new (char *, *argc + 1); ++ ++ for (j = 0; j < *argc; j++) { ++ quoted_argv[j] = g_shell_quote (the_argv[j]); ++ g_free (the_argv[j]); ++ } ++ quoted_argv[j] = NULL; ++ ++ real_argv[i++] = g_strjoinv (" ", quoted_argv); ++ g_strfreev (quoted_argv); ++ } else { ++ for (j = 0; j < *argc; j++, i++) ++ real_argv[i] = (char *)the_argv[j]; ++ } + + real_argv[i] = NULL; +