Sitemap
DevOps Lite

DevOps Lite

DevOpsLite.com is a personal blog specializing in technology with main topics about DevOps, DevSecOps, SRE and System Administrator.

3 min readSep 21, 2024

--

This entry is part 3 of 13 in the series GUI for bash script using Zenity

To create a notification icon in zenity, use the --notification option. This article will guide you fully on this option of zenity. This option is quite interesting, you can write a bash script using this option to display task reminders for you.

Create a notification icon

To create a notification icon with zenity, just type the following command, replace the text of your text into the command.

You Might Be Interested In

zenity --notification --text="Demo text content - WriteBash.com"
Demo zenity create notification

As you can see in the image above, a small message window appears at the top of the screen.

All options of notification

To display other options that --notification support, you type the following command:

zenity --help-notification
Display other options of notification

OptionsMeaning--notificationDisplay notification. This is the main option use to create a notification icon.--text=TEXTSpecifies the text that is displayed in the notification area. Example: –text=”Demo text – WriteBash.com”--listenListen for commands on stdin. Commands include ‘message’, ‘tooltip’, ‘icon’, and ‘visible’ separated by a colon. For example, ‘message: Hello world’, ‘visible: false’, or ‘icon: /path/to/icon’. The icon command also accepts the four stock icon: ‘error’, ‘info’, ‘question’, and ‘warning’--hint=TEXTSet the notification hints. Almost not use. Example: –hint=urgency

Get DevOps Lite’s stories in your inbox

Join Medium for free to get updates from this writer.

If you look at the table above, the --notification and --text options are easy to understand and use. I also had the example above.

Of the two remaining options, the --hint option is almost useless. About --listen option, how to use it?

Read more: Create calendar dialog with Zenity

Okey, I’ll try using it as I wrote in the table above. I’ll using --listen with message command.

zenity --notification --text="Demo text content - WriteBash.com" --listen
Use zenity notification with –listen option

In the image above, you can see that if you use the --listen option, it will wait for you to enter the command into the terminal window. In the demo I used the message command, you see that it prints the text content of the message command instead of the text of the --text option.

Conclusion

The --notification option in zenity is very simple, it helps you create a notification icon easily and quickly. What is the idea of using it? You can write a bash script, which is a feature that checks your work hours and tells you when it’s time for dinner.

(This is an article from my old blog that has been inactive for a long time, I don’t want to throw it away so I will keep it and hope it helps someone).

Original post: https://devopslite.com/zenity-create-a-notification-icon

--

--

DevOps Lite
DevOps Lite

Written by DevOps Lite

DevOpsLite.com is a personal blog specializing in technology with main topics about DevOps, DevSecOps, SRE and System Administrator.