LinuxCommandLibrary

notify-send

Display desktop notifications

TLDR

Show a notification with the title "Test" and the content "This is a test"

$ notify-send "[Test]" "[This is a test]"
copy

Show a notification with a custom icon
$ notify-send [[-i|--icon]] [icon.png] "[Test]" "[This is a test]"
copy

Show a notification for 5 seconds
$ notify-send [[-t|--expire-time]] 5000 "[Test]" "[This is a test]"
copy

Show a notification with the specified urgency level (default: normal)
$ notify-send [[-u|--urgency]] [low|normal|critical] "[Test]" "[This is a test]"
copy

Show a notification with an app's icon and name
$ notify-send "[Test]" [[-i|--icon]] [google-chrome] [[-a|--app-name]] "[Google Chrome]"
copy

SYNOPSIS

notify-send [OPTIONS]

[BODY]

SUMMARY: The summary text of the notification, typically displayed as a bold title.
BODY: Optional. The main body text of the notification, usually displayed below the summary.

PARAMETERS

-u, --urgency=LEVEL
    Specifies the urgency level of the notification. Possible levels are low, normal, or critical. Critical notifications often bypass timeout settings and might require explicit user dismissal.

-t, --expire-time=MILLISECONDS
    Specifies the timeout duration for the notification in milliseconds. A value of 0 indicates that the notification should never expire on its own (until clicked or dismissed by the user).

-i, --icon=ICON[,ICON...]
    Specifies an icon to display with the notification. This can be a stock icon name (e.g., 'dialog-information', 'emblem-important') or an absolute path to an image file (e.g., '/usr/share/icons/gnome/256x256/apps/utilities-terminal.png').

-a, --app-name=NAME
    Specifies the application name sending the notification. This can influence how the notification daemon groups or displays messages, or which icon to show.

-c, --category=CATEGORY[,CATEGORY...]
    Specifies the notification category, which can provide hints to the notification server about the type of event. Examples include 'device', 'email', 'transfer'.

-h, --hint=TYPE:NAME:VALUE
    Adds extra information (hints) to the notification. This is a more advanced option, allowing control over various properties like X/Y position (e.g., int:x:100), transient behavior, or desktop entry (e.g., string:desktop-entry:firefox).

-R, --replace=ID
    Replaces an existing notification with the given ID. This is useful for updating a persistent notification (e.g., a progress bar) rather than creating a new one each time.

-v, --version
    Displays version information for notify-send and exits.

--help
    Displays a help message with available options and exits.

DESCRIPTION

notify-send is a command-line tool that sends desktop notifications to the user's notification daemon (e.g., dunst, GNOME Shell, KDE Plasma's notification system) via the D-Bus Desktop Notifications Specification. These notifications typically appear as small pop-up bubbles or banners on the screen, providing transient messages without interrupting the user's workflow.

It is commonly used by shell scripts or applications to inform the user about events, completion of tasks, or urgent status changes. It supports various options to customize the appearance and behavior of the notification, such as setting urgency levels, timeouts, icons, and categories. The notification daemon handles the display and persistence of these messages, making notify-send a versatile tool for system administrators and developers.

CAVEATS

notify-send relies on a running notification daemon that implements the D-Bus Desktop Notifications Specification. If no such daemon is running (common on minimal installations or servers), the command might fail silently or produce a D-Bus related error. The exact appearance and behavior of notifications (e.g., position, theme, sound) are entirely determined by the user's notification daemon and desktop environment, not by notify-send itself. Icon paths must be absolute paths to image files or valid stock icon names present in the system's icon themes.

D-BUS INTEGRATION

notify-send communicates with the notification daemon over D-Bus, an inter-process communication system. This architecture decouples the sender (notify-send) from the display mechanism, allowing different desktop environments and notification daemons to render messages in their own unique ways while adhering to a common underlying protocol. This ensures cross-desktop compatibility and flexibility.

SCRIPTING USAGE

notify-send is a popular choice for shell scripting. For example, to notify a user when a long-running command finishes: 'long_running_command && notify-send "Task Complete" "Your command has finished running."'. It can also be used with conditional logic to alert on errors or specific events.

HISTORY

notify-send is part of the libnotify library, which provides a simple API for sending desktop notifications. It originated within the GNOME project and has since become a standard command-line utility across various Linux desktop environments. Its development closely follows the D-Bus Desktop Notifications Specification, first published around 2005, which standardized how applications communicate transient messages to the user without direct GUI interaction. Its widespread adoption highlights the importance of a uniform, non-intrusive notification mechanism for applications and scripts.

SEE ALSO

dunst(1), knotify(1), dbus-monitor(1), logger(1)

Copied to clipboard