It really depends on what you are trying to accomplish.
Dialog creates curses-based text dialog boxes that are accessible from the console. This is useful for adding some level of interaction to shell scripts. Dialog is older than the hills but still has its uses.
Zenity creates GTK-based graphical dialog boxes for use in a windowed GUI environment. This is useful for adding a few graphical touches to something that is running as a script but the user didn't run it from a text console and it needs some interaction. Zenity is a relatively new player but since it's distributed with Gnome it's widely available and stable.
There are of course other use-cases but the two tools are so fundamentally different that it's up to you to decide what you are trying to accomplish, then one tool or the other will be an obvious choice.
I've not figured out a method to reduce it's size below the defaults either. You might want to give gxmessage
a try instead. It can be reduced, though it too has a minimum size that it can be shrunken to. It does have better control surfaces, IMO, than zenity
with respect to font size selection and window dimensions though.
Example
$ gxmessage -center -timeout 60 -font "monospace 9" -buttons "Okay":1
-geometry 300x50 --wrap \
" Hello there friends. Hello there friends. Hello there friends. Hello there friends."
.gtkrc-2.0
If you really want to control the look of GTK+ applications I believe the appropriate way is through the resource file $HOME/.gtkrc-2.0
. You can add things like the font in here to override to say a monospace font. For experimentation purposes I made a copy of .gtkrc-2.0
and called it .gtkrc-20.mono8
.
The following will make the default font monospace 8:
# $HOME/.gtkrc-2.0.mono8
style "font" {
font_name = "monospace 8"
}
widget_class "*" style "font"
gtk-font-name = "monospace 8"
You can then control whether this file get's used by GTK+ applications like so:
$ GTK2_RC_FILES=.gtkrc-2.0.mono8 <gtk app>
So here's zenity
using defaults:
Here's zenity
using our .gtkrc-2.0.mono8
resource file:
NOTE: The command used above was this:
$ GTK2_RC_FILES=.gtkrc-2.0.mono8 zenity --info --title="Status" --text \
"Hello there friends. Hello there friends. Hello there friends."
gtk-parasite
So you can see that we can control GTK+ applications through the .gtkrc-2.0
file but what options can we put in this file. Well there's an app for that 8-), called gtk-parasite. It was in my Fedora repositories as gtkparasite
.
Once installed you invoke it against a GTK+ application like so:
$ GTK_MODULES=gtkparasite <gtk app>
So let's invoke zenity
:
$ GTK_MODULES=gtkparasite zenity --info --title="Status" --text \
"Hello there friends. Hello there friends. Hello there friends."
If you mess around with changing spacing in some of the sub-components and hiding the icon you can get the zenity
down to a size of 440x65:
Best Answer
1st,
--window-icon
is the icon that is displayed in the title bar of the window, not the icon within the dialog box, which is placed to the left of the text you specify.2nd, the latter icon can be set with
--icon-name
, which is an undocumented feature that does not appear in the man page.However, a path is not allowed here, rather just one of the predefined names "error", "info", "question", "warning", and probably "password".
On Debian, these names are translated to icon file paths, for example "info" to
/usr/share/icons/gnome/xx/status/dialog-information.png
, where "xx" is the icon resolution that is calculated to be appropriate for being displayed in the dialog depending on the screen resolution, for instance "48x48".If you set
--icon-name
to something invalid, then no icon is displayed at all.If you omit
--icon-name
, then a hardcoded icon in zenity is used.So, if you want to display a different icon for instance in the "information dialog", you would have to specify
--icon-name=info
and replace the existing icon e.g./usr/share/icons/gnome/48x48/status/dialog-information.png
with one of your liking, which can have a resolution different from 48x48.Update:
Speaking of the
gnome/
subdirectory: This corresponds to the icon theme I had selected in my appearance settings. Had I selected "Adwaita" for instance, then the subdirectory would beAdwaita/
.