Zenity annoys me by always displaying the warning in terminal:

Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged.

Apparently I'm not the only one:

Almost all the answers tell you to change the way you call zenity by appending 2>/dev/null to the end of the command. I don't want to do this to all the code I've already written and remember this for future code I write.

Is there an easier way of making this annoying message disappear?


I prefer to edit ~/.bashrc with:

alias zenity="zenity 2> >(grep -v 'GtkDialog' >&2)"

This is more restrictive, inhibits only the warning messages that have the GtkDialog string, leaving the other error or warning messages to be displayed


Basically, there's no other way except redirecting stderr to /dev/null. The main reason is because Gtk requires dialog windows ( which is what zenity windows actually are ) to have a parent application window. This same thing happens if you build GUI dialog from scratch in c or python.

Thus, the only "real" way is for Gtk developers to actually allow dialog windows to stand on their own, or zenity developers to silence those warning from within their source code. Otherwise, your only option is to constantly add 2>/dev/null to any zenity command. Of course you can always make an alias or wrapper function that will do it for you, something along the lines of this:

    /usr/bin/zenity "$@" 2>/dev/null

This, however, may have issues with quoting and passing arguments, but for the most part should work. If you work in Python or another language that can actually handle Gtk, you can brew your own popup dialogs with hidden parent windows, which comes at the cost of complexity and learning how to create those things. But again, the real way would be for zenity developers actually fix this or Gtk developers to acknowledge the need for standalone dialog windows.

  • When researching the question I read somewhere developers were working on making this warning go away. When was not addressed though.... – WinEunuuchs2Unix Mar 26 '17 at 2:41
  • This may have issues with quoting, especially since you used mismatched quotes. – Nic Hartley Mar 26 '17 at 6:58
  • @QPaysTaxes ooops, thanks for catching the mismatched quotes. Was typing without glasses – Sergiy Kolodyazhnyy Mar 26 '17 at 7:33

Automatically add 2>/dev/null every time zenity is called

Edit the file ~/.bashrc and search for these lines:

# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'

Add the following lines after:

# Add zenity alias to make the annoying terminal error message disappear forever:
# "Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged."
alias zenity="zenity 2>/dev/null"

Save the file and open a new terminal window to test:

zenity --info --text "Hello Zenity-Silly-Error-Free World"

Voila! All your old code is fixed and future code doesn't need to have 2>/dev/null appended to it like all the other answers instruct.

  • Why would you use sudo powers to edit your own bashrc? – Andrea Lazzarotto Mar 26 '17 at 1:55
  • @AndreaLazzarotto fixed that ;) – Sergiy Kolodyazhnyy Mar 26 '17 at 1:58
  • "...future code doesn't need to have 2>/dev/null appended to it like all the other answers instruct". Well, it still effectively has redirection appended to it each time, you just don't do it by hand. – Sergiy Kolodyazhnyy Mar 26 '17 at 2:02
  • 1
    @AndreaLazzarotto You are so right. Sorry my mind has been conditioned to put sudo into all my posts. Bad habits are hard to break... – WinEunuuchs2Unix Mar 26 '17 at 2:16
  • Simple and effective. I like it. – Elder Geek Sep 7 '17 at 22:50

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.