How to make zenity "transient parent" warning disappear permanently [duplicate]
Update 2019-05-17: OP has found another resolution along the same method presented here via global redirection by use of exec command. Please refer to linked duplicate post for more info
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:
zenity(){
/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.
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.