5

I want to change the default icon of any dialog in zenity , I write this line of code for ERROR Dialog

zenity --error --text='Icon As It Is' --window-icon=/home/ --icon-name=64.png --no-wrap

From above Line I succeed To remove default icon, But I want To Change the default icon with 64.png (64.png is 64*64 screen resolution image).

The default icon in the dialog box for error is ' -(Minus) sign in red colour' ,for info ' small i in blue color '. It's this icon I want to change.

I am using Linux mint 19.

roaima
  • 107,089
  • 14
  • 139
  • 261
AlphaCoder
  • 163
  • 1
  • 3
  • 8
  • 1
    According to the man page (`man zenity`) there is no `--icon-name` option. Have you tried `--window-icon=/home/64.png` like shown in the examples? – roaima Dec 08 '18 at 13:41
  • @roaima Thanks For **(man zenity )**, You can see **--icon-name=NAME ** For ERROR dialog if you type **zenity--help-error** in terminal , I Tried Your Trick But nothing happen new, Actually when we use this only ** --window-icon=/home/64.png** in zenity error then default error icon is visible, But when we use in zenity error this **--window-icon=/home/64.png --icon-name=64.png** then no any icon is visible. – AlphaCoder Dec 08 '18 at 16:54
  • What OS are you using? I really don't see an `--icon-name` in my version on Debian Linux. – roaima Dec 08 '18 at 22:24
  • @roaima I am using Linux mint 19 and I want 64.png at dialog icon, you can see, the default icon for error is **' -(Minus) sign in red colour'** ,for info **' small i in blue color '** – AlphaCoder Dec 09 '18 at 03:03

3 Answers3

6

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 be Adwaita/.

nst0022
  • 466
  • 2
  • 4
  • It seems like We are changing dialog icon permanently, It helps for **ERROR** and **WARNING** dialogs but for **INFO** I am writing program for multiple dialog icons at single run, – AlphaCoder Dec 09 '18 at 05:40
  • and how can i get this path as you specified /usr/share/icons/gnome/48*48/status/dialog-information.png – AlphaCoder Dec 09 '18 at 05:42
  • How to get the path? I don't know, I stumbled upon this in the past, when I was trying to accomplish the same as you. – nst0022 Dec 09 '18 at 10:07
  • I Tried with **locate usr/share/icon/gnome/** , It was awesome experience. Thank You For conceal the mystry – AlphaCoder Dec 09 '18 at 11:49
  • I tried with changing default icon in 48*48 but it is still not work. – AlphaCoder Dec 09 '18 at 12:36
  • 48x48 was just an example, try one of the next higher resolutions that are present, like 96x96 or 128x128. See also "Update:" in my answer. – nst0022 Dec 09 '18 at 15:22
  • But in 128*128 i've only 2 subdirectories apps and mimetypes and there not any icon specified for dialog icons, From gnome/xx*xx I tried with Every Possible resolution and It not work, here in gnome at 48*48 there is no any default icon for --info which is specified in zenity dialog , the icon is small i letter in blue colour but in gnome the for info is light bulb, It is suspicious, After Refer your update for Adwaita I found In ** gnome-colour-coloumn ** subdirectory there is present every matching dialog icon from zenity even the --info icon, So I think this is Our Right Workplace. – AlphaCoder Dec 09 '18 at 16:40
0
zenity --text-info --icon-name=info --title="Window title" --width=640 --height=800 --html --filename=FILE

Works for me

From the docs:

--window-icon=icon_path

Specifies the icon that is displayed in the window frame of the dialog. There are 4 stock icons also available by providing the following keywords - 'info', 'warning', 'question' and 'error'.

And yes, icon_path is badly named ; It's definitely not a path, more like a keyword.

yPhil
  • 222
  • 2
  • 11
-1

@nst0022 is correct, use --icon-name="foo", but it seems you can use any of the standard icon names in GNOME (see https://developer.gnome.org/icon-naming-spec/#names).

Thanks the folks answering this question here: https://askubuntu.com/questions/526202/getting-window-icon-to-work-with-zenity