
dunstify: A Practical Guide to Sending Notifications
dunstify: A practical guide to sending notifications
dunstify is an enhanced wrapper around notify-send for the Dunst notification daemon. It accepts all options from notify-send and adds convenient features like message replacement and easier urgency handling. This guide starts with concrete examples and highlights common pitfalls for beginners and intermediate users.
Quick start: simple notifications
The most basic usage shows a title and a message.
dunstify "Build complete" "Your project finished successfully."
Tip: Quotes matter if your title or message contains spaces. Prefer using simple titles and messages to avoid escaping issues.
Show with urgency
You can specify the urgency level using -u or —urgency. Accepted values are low, normal, and critical.
dunstify "Backup status" "The backup finished" --urgency normal
Common pitfall: If you omit the urgency, dunstify uses the default behavior, which may be interpreted differently by your notification daemon. Make the urgency explicit when the message outcome matters.
Replace an existing notification
Dunstify can replace a previous notification by using the replace flag and a numeric ID. This is useful for updating progress or status without stacking multiple notifications.
dunstify "Download" "Downloading: 25%" --replace 123
Then later you can update the same notification:
dunstify "Download" "Downloading: 50%" --replace 123
If you reuse an ID that isn’t currently displayed, the behavior may depend on your setup. Track IDs you use consistently.
Re-using the title and message format
You can reuse a consistent format by scripting: generate the title and message strings, then pass them to dunstify. This is handy for status dashboards or build systems.
TITLE="Build status"
MESSAGE="All tests passed"
dunstify "$TITLE" "$MESSAGE" --urgency normal
Display help and learn more
If you’re unsure about options, you can display help directly from the command line.
dunstify --help
Or use the short form:
dunstify -?
The help output lists all flags and their meanings. If you’ve customized your notification daemon, you may see slightly different behavior; always verify with a quick test.
Common pitfalls and quick fixes
- Pitfall: Forgetting to quote titles or messages with spaces.
- Fix: Quote both arguments or build them in shell variables.
- Pitfall: Assuming a default urgency; explicitly set it when needed.
- Fix: Always specify —urgency for important alerts.
- Pitfall: Using replace IDs without tracking their lifecycle.
- Fix: Maintain a small mapping in your script to avoid orphaned notifications.
- Pitfall: Relying on graphical environments where Dunst isn’t running.
- Fix: Check for a running notification daemon before calling dunstify or fall back to echo in scripts.
When to prefer dunstify over notify-send
- Need to update a running notification: use —replace with a stable ID.
- You want to ensure consistent urgency handling across notifications.
- You’re using a Dunst-based desktop where dunstify integrates smoothly with its features.
Summary
dunstify elevates notify-send with extra controls (like replace) and a straightforward syntax. Start with simple notifications, then add urgency and replace IDs as your workflow requires. Always test a quick run to confirm the appearance and behavior on your desktop.
See Also
- How to Use the fg Command in Linux
- How to Use the ss Command for Socket Investigation
- How to Use the cp Command for Effective File Management in Linux
- How to Use the chgrp Command in Linux?
- How Can You Master the dmesg Command for Effective Linux Troubleshooting?
- How to Use the Shutdown Command in Linux Effectively