Using dunstify (with examples)
- Linux
- November 5, 2023
dunstify is a notification tool that allows users to display notifications on their desktop. It provides additional features compared to the traditional notify-send
command. In this article, we will explore different use cases of dunstify
with practical examples.
Use Case 1: Show a notification with a given title and message
Code:
dunstify "Title" "Message"
Motivation: This use case is helpful when you want to display a simple notification with a title and message. It can be used to provide user feedback, reminders, or any important information.
Explanation:
The dunstify
command is used to show notifications. The first argument represents the notification title, and the second argument represents the notification message.
Example Output: A notification will be displayed with the provided title and message.
Use Case 2: Show a notification with specified urgency
Code:
dunstify "Title" "Message" -u low|normal|critical
Motivation: Different notifications may have different levels of urgency. By specifying the urgency level, you can ensure that important notifications grab the user’s attention, while less critical ones are displayed more discreetly.
Explanation:
The -u
option is used to specify the urgency level of the notification. It accepts three values: low
, normal
, and critical
. The low
urgency level is used for less critical notifications that do not require immediate attention. The normal
urgency level is used for general notifications. The critical
urgency level is used for urgent notifications that require immediate attention.
Example Output: A notification will be displayed with the provided title and message, with the specified urgency level.
Use Case 3: Specify a message ID
Code:
dunstify "Title" "Message" -r 123
Motivation: Using message IDs can be useful when you want to update or remove a specific notification programmatically. By specifying a message ID, you can ensure that subsequent notifications with the same ID will overwrite the previous one.
Explanation:
The -r
option is used to specify the message ID for the notification. The ID can be any numeric or alphanumeric value. Subsequent notifications with the same message ID will overwrite the previous ones.
Example Output: A notification will be displayed with the provided title and message, and a specific message ID. If another notification with the same message ID is triggered, it will replace the previous one.
Additional Options
To explore other possible options of dunstify
, you can use the notify-send --help
command. This will display a list of available options and their explanations.
notify-send --help
Conclusion
In this article, we explored different use cases of the dunstify
command. We learned how to display notifications with a title and message, specify urgency levels, and assign message IDs. With these examples, you can now utilize dunstify
to provide timely notifications and user feedback on your desktop.