Table of Contents
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.
zenity --notification --text="Demo text content - WriteBash.com"
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
| Options | Meaning |
--notification | Display notification. This is the main option use to create a notification icon. |
--text=TEXT | Specifies the text that is displayed in the notification area. Example: –text=”Demo text – WriteBash.com” |
--listen | Listen 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=TEXT | Set the notification hints. Almost not use. Example: –hint=urgency |
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
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).
GOOD POST