mirror of
https://github.com/flatpak/flatpak.git
synced 2026-01-01 12:28:10 -05:00
flatpak: Disable progress escape sequence by default
And add the FLATPAK_TTY_PROGRESS env var to re-enable it. This seems to only be supported by recent versions of terminal emulators which will cause problems with shipping Flatpak on older distros. Closes https://github.com/flatpak/flatpak/issues/6052
This commit is contained in:
committed by
Georges Basile Stavracas Neto
parent
2eb4819240
commit
4febfb5973
@@ -522,14 +522,37 @@ flatpak_print_escaped_string (const char *s,
|
||||
g_print ("%s", escaped);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
use_progress_escape_sequence (void)
|
||||
{
|
||||
static gsize tty_progress_once = 0;
|
||||
enum {
|
||||
TTY_PROGRESS_ENABLED = 1,
|
||||
TTY_PROGRESS_DISABLED = 2
|
||||
};
|
||||
|
||||
if (g_once_init_enter (&tty_progress_once))
|
||||
{
|
||||
// FIXME: make this opt-out for Flatpak 1.18
|
||||
if (g_strcmp0 (g_getenv ("FLATPAK_TTY_PROGRESS"), "1") == 0)
|
||||
g_once_init_leave (&tty_progress_once, TTY_PROGRESS_ENABLED);
|
||||
else
|
||||
g_once_init_leave (&tty_progress_once, TTY_PROGRESS_DISABLED);
|
||||
}
|
||||
|
||||
return tty_progress_once == TTY_PROGRESS_ENABLED;
|
||||
}
|
||||
|
||||
void
|
||||
flatpak_pty_clear_progress (void)
|
||||
{
|
||||
g_print ("\033]9;4;0\007");
|
||||
if (use_progress_escape_sequence ())
|
||||
g_print ("\033]9;4;0\007");
|
||||
}
|
||||
|
||||
void
|
||||
flatpak_pty_set_progress (guint percent)
|
||||
{
|
||||
g_print ("\033]9;4;1;%d\007", MIN (percent, 100));
|
||||
if (use_progress_escape_sequence ())
|
||||
g_print ("\033]9;4;1;%d\007", MIN (percent, 100));
|
||||
}
|
||||
|
||||
@@ -617,6 +617,14 @@
|
||||
or when <envar>G_MESSAGES_DEBUG</envar> is set.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><envar>FLATPAK_TTY_PROGRESS</envar></term>
|
||||
|
||||
<listitem><para>
|
||||
May be set to <literal>1</literal> to enable emitting
|
||||
the progress escape character.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><envar>FLATPAK_USER_DIR</envar></term>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user