Bash – Zenity dialog windows have excessive height and cannot be resized. Bug workaround anyone

bashzenity

I'm trying to do some things in zenity, and it's been driving me bonkers. To illustrate my problem, try running this:

zenity --info --text "Hello there friends."

Simple enough right. Now try this:

zenity --info --text " Hello there friends. Hello there friends. Hello there friends. Hello there friends."

Notice how the dialog box got considerably taller?

So you can resize the width of the dialog. In particular, notice what happens when you try to make the width as small as possible. This illustrates my next point: you can't resize the height DOWN at all–it appears to have a hard minimum which is based on the height that would be required if your dialog box was squeezed horizontally to the smallest size possible.

None of this matters for short messages, but what if you have a long message? You don't have to do very much typing in order to end up with a dialog box that is so tall that the ok button is off the screen — and that is a big problem for my users.

Here's a bug report:
FS#34164 : [zenity] – dialog size bug
https://bugs.archlinux.org/task/34164

But that patch doesn't do me any good. My end users are installing Zenity on their own computers and I can't patch their Zenity.

Is there any way around this? Any tricks with regard to the text or anything else?

Best Answer

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."

                                       ss of gxmessage

.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:

                    default zenity rc file

Here's zenity using our .gtkrc-2.0.mono8 resource file:

                  mono8 zenity rc 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:

                  ss of little zenity