1. Yad Notification

Show an icon in the notification area and when left-clicking on the icon it prints 'clicked' in the terminal.

yad notification 1

yad notification 2

Source code

# create a FIFO file, used to manage the I/O redirection from shell
PIPE=$(mktemp -u --tmpdir ${0##*/}.XXXXXXXX)
mkfifo $PIPE

# attach a file descriptor to the file
exec 3<> $PIPE

# add handler to manage process shutdown
function on_exit() {
  echo "quit" >&3
  rm -f $PIPE
trap on_exit EXIT

# add handler for tray icon left click
function on_click() {
  echo "clicked"
export -f on_click

# create the notification icon
yad --notification \
  --listen \
  --image="gnome-info" \
  --text="Notification tooltip" \
  --command="bash -c on_click" <&3"

1.1. --command=CMD

Set the command running when clicked on the icon.
Default action is quit if --listen is not specified.

1.2. --listen

Listen for commands on stdin. See NOTIFICATION section.

1.3. --separator=STRING

Set separator character for menu values. Default is |.

1.4. --item-separator=STRING

Set separator character for menu items. Default is !.

1.5. --menu=STRING

Set initial menu for right-click.

1.6. --no-middle

Disable exit on middle click

1.7. --hidden

Doesn’t show icon at startup

1.8. --icon-size=SIZE

Set notification icon size to SIZE (default - 16). This option doesn’t works for themed icons.


Allows commands to be sent to yad in the form command:args.
Possible commands are icon, tooltip, visible, action, menu and quit.

2.1. icon:ICONNAME

Set notification icon to ICONNAME.

2.2. tooltip:STRING

Set notification tooltip.

Set notification icon to visible, invisible or blinking states.

2.4. action:COMMAND

Specify the command running when click on the icon.
There are two special commands - menu for popup user defined menu and quit for exit the program.

2.5. menu:STRING

Set popup menu for notification icon.
STRING must be in form name1[!action1[!icon1]]|name2[!action2[!icon2]]…​.
Empty name add separator to menu. Separator character for values (e.g. |) sets with --separator argument.
Separator character for menu items (e.g. !) sets with --item-separator argument.

2.6. quit

Exit the program.
Middle click on icon also send quit command.

3. Examples

Here are some examples on how to use YAD notification

3.1. A tray icon with right click menu

In this example if you do a left klick it will start a xfce4 terminal
if you do a right click it will show you a menu with the menu items About and Quit.

yad notification 3.1 1

yad notification 3.1 2

yad notification 3.1 3

Source code for example 3.1

yad --notification \
  --image=gnome-terminal \
  --text="My Tray Icon" \
  --menu="About!yad --about!gtk-help|Quit!quit!gtk-quit" \
  --command="xfce4-terminal" \

3.2. A tray icon for launching applications

In this example if you click on the icon it will show a menu with applications you can start.

yad notification 3.2 1

yad notification 3.2 2

yad notification 3.2 3

Source code for example 3.2

yad --notification \
  --image="applications-other" \
  --text="My Tray Icon" \
  --menu="L3afpad ! l3afpad
  |Geany ! geany
  |Terminal ! xfce4-terminal
  |Filemanager ! thunar
  |Quit ! quit" \

Back to YAD Guide