如何在 Ubuntu GNOME 上调用桌面通知?

11 notification gnome

我想知道如何在 Ubuntu GNOME 15.10 和 GNOME 3.18 上显示桌面通知?我的意思是如何让这些桌面通知之一提供我指定的文本?:

在此处输入图片说明

如果我可以执行一个可以执行此操作的命令或脚本,以便我能够获得有关系统中事物的通知,那将会很有用。

A.B*_*.B. 12

与 GNOME 3.16 和其他桌面环境中的方式相同。可以通过命令行中的通知守护程序发送通知。

该命令是包的一部分,libnotify-bin*-desktop元包安装。

依赖项是libc6, libglib2.0-0, libnotify4。运行strace以查看通知的方式:

% strace -e open notify-send foo bar 
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/x86_64-linux-gnu/libnotify.so.4", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0", O_RDONLY|O_CLOEXEC) = 3
open("/lib/x86_64-linux-gnu/libglib-2.0.so.0", O_RDONLY|O_CLOEXEC) = 3
open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/x86_64-linux-gnu/libgdk_pixbuf-2.0.so.0", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/x86_64-linux-gnu/libgio-2.0.so.0", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/x86_64-linux-gnu/libffi.so.6", O_RDONLY|O_CLOEXEC) = 3
open("/lib/x86_64-linux-gnu/libpcre.so.3", O_RDONLY|O_CLOEXEC) = 3
open("/lib/x86_64-linux-gnu/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/x86_64-linux-gnu/libgmodule-2.0.so.0", O_RDONLY|O_CLOEXEC) = 3
open("/lib/x86_64-linux-gnu/libm.so.6", O_RDONLY|O_CLOEXEC) = 3
open("/lib/x86_64-linux-gnu/libz.so.1", O_RDONLY|O_CLOEXEC) = 3
open("/lib/x86_64-linux-gnu/libselinux.so.1", O_RDONLY|O_CLOEXEC) = 3
open("/lib/x86_64-linux-gnu/libresolv.so.2", O_RDONLY|O_CLOEXEC) = 3
open("/lib/x86_64-linux-gnu/libdl.so.2", O_RDONLY|O_CLOEXEC) = 3
Run Code Online (Sandbox Code Playgroud)

发送您自己的通知

notify-send foo bar
Run Code Online (Sandbox Code Playgroud)

来自man notify-send

SYNOPSIS
       notify-send [OPTIONS] <summary> [body]

OPTIONS
       -u, --urgency=LEVEL Specifies the urgency level (low, normal,
            critical).

       -t, --expire-time=TIME
            The duration, in milliseconds, for the notification to appear
            on screen.  (Ubuntu's Notify OSD and GNOME Shell both ignore
            this parameter.)

       -i, --icon=ICON[,ICON...]
             Specifies an icon filename or stock icon to display.

       -c, --category=TYPE[,TYPE...]
             Specifies the notification category.

          Help options:

       -?, --help
             Show this help message

       -h, --hint=TYPE:NAME:VALUE
             Specifies basic extra data to pass. Valid types are int,
             double, string and byte.
Run Code Online (Sandbox Code Playgroud)