Problem executing a shell script using Zenity. Message: Gtk-Message: GtkDialog mapped without a parent transient. This is discouraged

1

When I run script.sh via linux shell, this message appears: Gtk-Message: GtkDialog mapped without a parent transient. This is discouraged. How do I resolve this?

#!/bin/bash

get_url ()
{
    url=$(zenity --entry --title="Youtube" --text="Criado por: Leandro Sciola\nCole o link do vídeo aqui para extrair o áudio:" --ok-label=Extrair --width="600" height="50")

    if [ $? -eq 1 ]; then
        exit
    fi
}

download ()
{
    (
        youtube-dl -f m4a --output "%(title)s.%(ext)s" --print-json --no-warnings $url >metadata
    ) | zenity --progress --title="Youtube" --pulsate --auto-close --no-cancel --text "Extraindo o áudio..."

    title=$(jq -r ".title" metadata)
    rm metadata

    if [ "$title" ]; then
        zenity --info --title="Youtube" --text="Áudio extraído com sucesso!\nTítulo: $title"
    else
        zenity --error --title="Youtube" --text="Erro! Não foi possível extrair o áudio!"
        setup
    fi
}

setup ()
{
    get_url

    if [ "$url" ]; then
        download
    else
        zenity --warning --title="Youtube" --text="Nenhum link foi adicionado no campo!"
        setup
    fi
}

setup
    
asked by anonymous 30.07.2018 / 02:04

1 answer

1

Warning messages in GTK are somewhat frequent and often, as in the present case, can be ignored without any problem.

In this specific case, to translate into intelligible language, the message is saying: "dialog windows should be started by other windows" , that is, they should have parent windows. This ensures that window manager is able to know what the application is and what the dialog is, to know which windows are associated with the same application, etc.

In this way, this is a warning inherent in Zenity, because it is a case where dialog windows come directly and legitimately from a command line interface! Note that the message says that such a practice is discouraged, but does not say that this is a mistake. The existence of the message in no way affects the execution of your script.

As there is no way for Zenity to inhibit GTK message feedback, if you want to keep the console clean when scripting is running, I suggest that you redirect error output from zenity calls to /dev/null , for example :

    url=$(zenity --entry --title ... height="50" 2> /dev/null);

I also suggest that this be done after ensuring that calls to zenity do not fail, as this inhibits any error output and may make the debug process difficult.

Reference: linuxquestions.org

    
31.07.2018 / 04:07