您的位置:首页 > 其它

使用notify-send发送桌面通知

2017-11-09 19:39 501 查看

目录

常用的选项
-t –expire-time=TIME
-u –urgency=LEVEL
-i –icon=ICON[,ICON…]
Standard Action Icons
Standard Animation Icons
Standard Application Icons
Standard Category Icons
Standard Device Icons
Standard Emblem Icons
Standard Emotion Icons
Standard International Icons
Standard MIME Type Icons
Standard Place Icons
Standard Status Icons

不常用的选项
-c –category=TYPE[,TYPE…]
-h –hint=TYPE:NAME:VALUE

通过notify-send是一个可以让你发送桌面通知的命令. 它的语法非常简单:

notify-send [其他选项...] 标题 [内容]
1
2
其中”标题”一般为单行不超过40个字符的文本.

而”内容”则可以是多行的文本,且某些notification server还支持简单的标记语法:

标记说明
粗体
斜体
下划线

超链接

图片

常用的选项

notify-send的常用的几个选项有这么几个:

-t –expire-time=TIME

指定通知显示多长时间后消失,单位是毫秒. (Ubuntu的Notify OSD以及GNOME Shell会忽略该参数)

若参数为-1表示使用notification server上配置的超时时间.

若参数为0则表示永不自动消失.

-u –urgency=LEVEL

指定通知的级别,只能是
low
,
normal
,
critical
这三个值中的一个.

当有多个通知待显示时,一般会优先选择优先级高的那个通知显示. 但具体不同的
notification server
有不同的处理方法.

例如在我的机器上运行

#!/bin/bash

notify-send ignore
for level in low normal critical
do
notify-send -u $level $level
done
1
2
3
4
5
6
7
8
会先显示ignore,再显示critical,再是low,最后才是normal

另外,根据标准,Critical级别的通知是应该一直显示直到用户手工关闭的,然而实际情况还是依具体的notification server而定.

-i –icon=ICON[,ICON…]

指定显示通知的图标. 其中ICON既可以是一个指向图标文件的路径,也可以是标准图标的名称.

其中标准图标名称一般包括以下这些:

Standard Action Icons

NameDescription
address-book-newThe icon used for the action to create a new address book.
application-exitThe icon used for exiting an application. Typically this is seen in the application’s menus as File->Quit.
appointment-newThe icon used for the action to create a new appointment in a calendaring application.
call-startThe icon used for initiating or accepting a call. Should be similar to the standard cellular call pickup icon, a green handset with ear and mouth pieces facing upward.
call-stopThe icon used for stopping a current call. Should be similar to the standard cellular call hangup icon, a red handset with ear and mouth pieces facing downward.
contact-newThe icon used for the action to create a new contact in an address book application.
document-newThe icon used for the action to create a new document.
document-openThe icon used for the action to open a document.
document-open-recentThe icon used for the action to open a document that was recently opened.
document-page-setupThe icon for the page setup action of a document editor.
document-printThe icon for the print action of an application.
document-print-previewThe icon for the print preview action of an application.
document-propertiesThe icon for the action to view the properties of a document in an application.
document-revertThe icon for the action of reverting to a previous version of a document.
document-saveThe icon for the save action. Should be an arrow pointing down and toward a hard disk.
document-save-asThe icon for the save as action.
document-sendThe icon for the send action. Should be an arrow pointing up and away from a hard disk.
edit-clearThe icon for the clear action.
edit-copyThe icon for the copy action.
edit-cutThe icon for the cut action.
edit-deleteThe icon for the delete action.
edit-findThe icon for the find action.
edit-find-replaceThe icon for the find and replace action.
edit-pasteThe icon for the paste action.
edit-redoThe icon for the redo action.
edit-select-allThe icon for the select all action.
edit-undoThe icon for the undo action.
folder-newThe icon for creating a new folder.
format-indent-lessThe icon for the decrease indent formatting action.
format-indent-moreThe icon for the increase indent formatting action.
format-justify-centerThe icon for the center justification formatting action.
format-justify-fillThe icon for the fill justification formatting action.
format-justify-leftThe icon for the left justification formatting action.
format-justify-rightThe icon for the right justification action.
format-text-direction-ltrThe icon for the left-to-right text f
1cf6b
ormatting action.
format-text-direction-rtlThe icon for the right-to-left formatting action.
format-text-boldThe icon for the bold text formatting action.
format-text-italicThe icon for the italic text formatting action.
format-text-underlineThe icon for the underlined text formatting action.
format-text-strikethroughThe icon for the strikethrough text formatting action.
go-bottomThe icon for the go to bottom of a list action.
go-downThe icon for the go down in a list action.
go-firstThe icon for the go to the first item in a list action.
go-homeThe icon for the go to home location action.
go-jumpThe icon for the jump to action.
go-lastThe icon for the go to the last item in a list action.
go-nextThe icon for the go to the next item in a list action.
go-previousThe icon for the go to the previous item in a list action.
go-topThe icon for the go to the top of a list action.
go-upThe icon for the go up in a list action.
help-aboutThe icon for the About item in the Help menu.
help-contentsThe icon for Contents item in the Help menu.
help-faqThe icon for the FAQ item in the Help menu.
insert-imageThe icon for the insert image action of an application.
insert-linkThe icon for the insert link action of an application.
insert-objectThe icon for the insert object action of an application.
insert-textThe icon for the insert text action of an application.
list-addThe icon for the add to list action.
list-removeThe icon for the remove from list action.
mail-forwardThe icon for the forward action of an electronic mail application.
mail-mark-importantThe icon for the mark as important action of an electronic mail application.
mail-mark-junkThe icon for the mark as junk action of an electronic mail application.
mail-mark-notjunkThe icon for the mark as not junk action of an electronic mail application.
mail-mark-readThe icon for the mark as read action of an electronic mail application.
mail-mark-unreadThe icon for the mark as unread action of an electronic mail application.
mail-message-newThe icon for the compose new mail action of an electronic mail application.
mail-reply-allThe icon for the reply to all action of an electronic mail application.
mail-reply-senderThe icon for the reply to sender action of an electronic mail application.
mail-sendThe icon for the send action of an electronic mail application.
mail-send-receiveThe icon for the send and receive action of an electronic mail application.
media-ejectThe icon for the eject action of a media player or file manager.
media-playback-pauseThe icon for the pause action of a media player.
media-playback-startThe icon for the start playback action of a media player.
media-playback-stopThe icon for the stop action of a media player.
media-recordThe icon for the record action of a media application.
media-seek-backwardThe icon for the seek backward action of a media player.
media-seek-forwardThe icon for the seek forward action of a media player.
media-skip-backwardThe icon for the skip backward action of a media player.
media-skip-forwardThe icon for the skip forward action of a media player.
object-flip-horizontalThe icon for the action to flip an object horizontally.
object-flip-verticalThe icon for the action to flip an object vertically.
object-rotate-leftThe icon for the rotate left action performed on an object.
object-rotate-rightThe icon for the rotate rigt action performed on an object.
process-stopThe icon used for the “Stop” action in applications with actions that may take a while to process, such as web page loading in a browser.
system-lock-screenThe icon used for the “Lock Screen” item in the desktop’s panel application.
system-log-outThe icon used for the “Log Out” item in the desktop’s panel application.
system-runThe icon used for the “Run Application…” item in the desktop’s panel application.
system-searchThe icon used for the “Search” item in the desktop’s panel application.
system-rebootThe icon used for the “Reboot” item in the desktop’s panel application.
system-shutdownThe icon used for the “Shutdown” item in the desktop’s panel application.
tools-check-spellingThe icon used for the “Check Spelling” item in the application’s “Tools” menu.
view-fullscreenThe icon used for the “Fullscreen” item in the application’s “View” menu.
view-refreshThe icon used for the “Refresh” item in the application’s “View” menu.
view-restoreThe icon used by an application for leaving the fullscreen view, and returning to a normal windowed view.
view-sort-ascendingThe icon used for the “Sort Ascending” item in the application’s “View” menu, or in a button for changing the sort method for a list.
view-sort-descendingThe icon used for the “Sort Descending” item in the application’s “View” menu, or in a button for changing the sort method for a list.
window-closeThe icon used for the “Close Window” item in the application’s “Windows” menu.
window-newThe icon used for the “New Window” item in the application’s “Windows” menu.
zoom-fit-bestThe icon used for the “Best Fit” item in the application’s “View” menu.
zoom-inThe icon used for the “Zoom in” item in the application’s “View” menu.
zoom-originalThe icon used for the “Original Size” item in the application’s “View” menu.
zoom-outThe icon used for the “Zoom Out” item in the application’s “View” menu.

Standard Animation Icons

NameDescription
process-workingThis is the standard spinner animation for web browsers and file managers to show that the location is loading.

Standard Application Icons

NameDescription
accessories-calculatorThe icon used for the desktop’s calculator accessory program.
accessories-character-mapThe icon used for the desktop’s international and extended text character accessory program.
accessories-dictionaryThe icon used for the desktop’s dictionary accessory program.
accessories-text-editorThe icon used for the desktop’s text editing accessory program.
help-browserThe icon used for the desktop’s help browsing application.
multimedia-volume-controlThe icon used for the desktop’s hardware volume control application.
preferences-desktop-accessibilityThe icon used for the desktop’s accessibility preferences.
preferences-desktop-fontThe icon used for the desktop’s font preferences.
preferences-desktop-keyboardThe icon used for the desktop’s keyboard preferences.
preferences-desktop-localeThe icon used for the desktop’s locale preferences.
preferences-desktop-multimediaThe icon used for the desktop’s multimedia preferences.
preferences-desktop-screensaverThe icon used for the desktop’s screen saving preferences.
preferences-desktop-themeThe icon used for the desktop’s theme preferences.
preferences-desktop-wallpaperThe icon used for the desktop’s wallpaper preferences.
system-file-managerThe icon used for the desktop’s file management application.
system-software-installThe icon used for the desktop’s software installer application.
system-software-updateThe icon used for the desktop’s software updating application.
utilities-system-monitorThe icon used for the desktop’s system resource monitor application.
utilities-terminalThe icon used for the desktop’s terminal emulation application.

Standard Category Icons

NameDescription
applications-accessoriesThe icon for the “Accessories” sub-menu of the Programs menu.
applications-developmentThe icon for the “Programming” sub-menu of the Programs menu.
applications-engineeringThe icon for the “Engineering” sub-menu of the Programs menu.
applications-gamesThe icon for the “Games” sub-menu of the Programs menu.
applications-graphicsThe icon for the “Graphics” sub-menu of the Programs menu.
applications-internetThe icon for the “Internet” sub-menu of the Programs menu.
applications-multimediaThe icon for the “Multimedia” sub-menu of the Programs menu.
applications-officeThe icon for the “Office” sub-menu of the Programs menu.
applications-otherThe icon for the “Other” sub-menu of the Programs menu.
applications-scienceThe icon for the “Science” sub-menu of the Programs menu.
applications-systemThe icon for the “System Tools” sub-menu of the Programs menu.
applications-utilitiesThe icon for the “Utilities” sub-menu of the Programs menu.
preferences-desktopThe icon for the “Desktop Preferences” category.
preferences-desktop-peripheralsThe icon for the “Peripherals” sub-category of the “Desktop Preferences” category.
preferences-desktop-personalThe icon for the “Personal” sub-category of the “Desktop Preferences” category.
preferences-otherThe icon for the “Other” preferences category.
preferences-systemThe icon for the “System Preferences” category.
preferences-system-networkThe icon for the “Network” sub-category of the “System Preferences” category.
system-helpThe icon for the “Help” system category.

Standard Device Icons

NameDescription
audio-cardThe icon used for the audio rendering device.
audio-input-microphoneThe icon used for the microphone audio input device.
batteryThe icon used for the system battery device.
camera-photoThe icon used for a digital still camera devices.
camera-videoThe fallback icon for video cameras.
camera-webThe fallback icon for web cameras.
computerThe icon used for the computing device as a whole.
drive-harddiskThe icon used for hard disk drives.
drive-opticalThe icon used for optical media drives such as CD and DVD.
drive-removable-mediaThe icon used for removable media drives.
input-gamingThe icon used for the gaming input device.
input-keyboardThe icon used for the keyboard input device.
input-mouseThe icon used for the mousing input device.
input-tabletThe icon used for graphics tablet input devices.
media-flashThe fallback icon used for flash media, such as memory stick and SD.
media-floppyThe icon used for physical floppy disk media.
media-opticalThe icon used for physical optical media such as CD and DVD.
media-tapeThe icon used for generic physical tape media.
modemThe icon used for modem devices.
multimedia-playerThe icon used for generic multimedia playing devices.
network-wiredThe icon used for wired network connections.
network-wirelessThe icon used for wireless network connections.
pdaThis is the fallback icon for Personal Digial Assistant devices. Primary use of this icon is for PDA devices connected to the PC. Connection medium is not an important aspect of the icon. The metaphor for this fallback icon should be a
generic PDA device icon.
phoneThis is the default fallback for phone devices. Primary use of this icon group is for phone devices which support connectivity to the PC. These may be VoIP, cellular, or possibly landline phones. The metaphor for this fallback should be
a generic mobile phone device.
printerThe icon used for a printer device.
scannerThe icon used for a scanner device.
video-displayThe icon used for the monitor that video gets displayed to.

Standard Emblem Icons

NameDescription
emblem-defaultThe icon used as an emblem to specify the default selection of a printer for example.
emblem-documentsThe icon used as an emblem for the directory where a user’s documents are stored.
emblem-downloadsThe icon used as an emblem for the directory where a user’s downloads from the internet are stored.
emblem-favoriteThe icon used as an emblem for files and directories that the user marks as favorites.
emblem-importantThe icon used as an emblem for files and directories that are marked as important by the user.
emblem-mailThe icon used as an emblem to specify the directory where the user’s electronic mail is stored.
emblem-photosThe icon used as an emblem to specify the directory where the user stores photographs.
emblem-readonlyThe icon used as an emblem for files and directories which can not be written to by the user.
emblem-sharedThe icon used as an emblem for files and directories that are shared to other users.
emblem-symbolic-linkThe icon used as an emblem for files and direcotires that are links to other files or directories on the filesystem.
emblem-synchronizedThe icon used as an emblem for files or directories that are configured to be synchronized to another device.
emblem-systemThe icon used as an emblem for directories that contain system libraries, settings, and data.
emblem-unreadableThe icon used as an emblem for files and directories that are inaccessible.

Standard Emotion Icons

NameDescription
face-angelThe icon used for the 0:-) emote.
face-angryThe icon used for the X-( emote.
face-coolThe icon used for the B-) emote.
face-cryingThe icon used for the :’( emote.
face-devilishThe icon used for the >:-) emote.
face-embarrassedThe icon used for the :-[ emote.
face-kissThe icon used for the :-\* emote.
face-laughThe icon used for the :-)) emote.
face-monkeyThe icon used for the :-(|) emote.
face-plainThe icon used for the :-| emote.
face-raspberryThe icon used for the :-P emote.
face-sadThe icon used for the :-( emote.
face-sickThe icon used for the :-& emote.
face-smileThe icon used for the :-) emote.
face-smile-bigThe icon used for the :-D emote.
face-smirkThe icon used for the :-! emote.
face-surpriseThe icon used for the :-0 emote.
face-tiredThe icon used for the |-) emote.
face-uncertainThe icon used for the :-/ emote.
face-winkThe icon used for the ;-) emote.
face-worriedThe icon used for the :-S emote.

Standard International Icons

NameDescription
flag-aaThe flag for the country with the ISO 3166 country code AA. All flags should use ISO 3166 two-letter country codes, in lowercase form, as the specifier for the country.

Standard MIME Type Icons

NameDescription
application-x-executableThe icon used for executable file types.
audio-x-genericThe icon used for generic audio file types.
font-x-genericThe icon used for generic font file types.
image-x-genericThe icon used for generic image file types.
package-x-genericThe icon used for generic package file types.
text-htmlThe icon used for HTML text file types.
text-x-genericThe icon used for generic text file types.
text-x-generic-templateThe icon used for generic text templates.
text-x-scriptThe icon used for script file types, such as shell scripts.
video-x-genericThe icon used for generic video file types.
x-office-address-bookThe icon used for generic address book file types.
x-office-calendarThe icon used for generic calendar file types.
x-office-documentThe icon used for generic document and letter file types.
x-office-presentationThe icon used for generic presentation file types.
x-office-spreadsheetThe icon used for generic spreadsheet file types.

Standard Place Icons

NameDescription
folderThe standard folder icon used to represent directories on local filesystems, mail folders, and other hierarchical groups.
folder-remoteThe icon used for normal directories on a remote filesystem.
network-serverThe icon used for individual host machines under the “Network Servers” place in the file manager.
network-workgroupThe icon for the “Network Servers” place in the desktop’s file manager, and workgroups within the network.
start-hereThe icon used by the desktop’s main menu for accessing places, applications, and other features.
user-bookmarksThe icon for the user’s special “Bookmarks” place.
user-desktopThe icon for the special “Desktop” directory of the user.
user-homeThe icon for the special “Home” directory of the user.
user-trashThe icon for the user’s “Trash” place in the desktop’s file manager.

Standard Status Icons

NameDescription
appointment-missedThe icon used when an appointment was missed.
appointment-soonThe icon used when an appointment will occur soon.
audio-volume-highThe icon used to indicate high audio volume.
audio-volume-lowThe icon used to indicate low audio volume.
audio-volume-mediumThe icon used to indicate medium audio volume.
audio-volume-mutedThe icon used to indicate the muted state for audio playback.
battery-cautionThe icon used when the battery is below 40%.
battery-lowThe icon used when the battery is below 20%.
dialog-errorThe icon used when a dialog is opened to explain an error condition to the user.
dialog-informationThe icon used when a dialog is opened to give information to the user that may be pertinent to the requested action.
dialog-passwordThe icon used when a dialog requesting the authentication credentials for a user is opened.
dialog-questionThe icon used when a dialog is opened to ask a simple question of the user.
dialog-warningThe icon used when a dialog is opened to warn the user of impending issues with the requested action.
folder-drag-acceptThe icon used for a folder while an object is being dragged onto it, that is of a type that the directory can contain.
folder-openThe icon used for folders, while their contents are being displayed within the same window. This icon would normally be shown in a tree or list view, next to the main view of a folder’s contents.
folder-visitingThe icon used for folders, while their contents are being displayed in another window. This icon would typically be used when using multiple windows to navigate the hierarchy, such as in Nautilus’s spatial mode.
image-loadingThe icon used when another image is being loaded, such as thumnails for larger images in the file manager.
image-missingThe icon used when another image could not be loaded.
mail-attachmentThe icon used for an electronic mail that contains attachments.
mail-unreadThe icon used for an electronic mail that is unread.
mail-readThe icon used for an electronic mail that is read.
mail-repliedThe icon used for an electronic mail that has been replied to.
mail-signedThe icon used for an electronic mail that contains a signature.
mail-signed-verifiedThe icon used for an electronic mail that contains a signature which has also been verified by the security system.
media-playlist-repeatThe icon for the repeat mode of a media player.
media-playlist-shuffleThe icon for the shuffle mode of a media player.
network-errorThe icon used when an error occurs trying to intialize the network connection of the computing device. This icon should be two computers, one in the background, with the screens of both computers, colored black, and with the theme’s style
element for errors, overlayed on top of the icon.
network-idleThe icon used when no data is being transmitted or received, while the computing device is connected to a network. This icon should be two computers, one in the background, with the screens of both computers, colored black.
network-offlineThe icon used when the computing device is disconnected from the network. This icon should be a computer in the background, with a screen colored black, and the theme’s icon element to show that a device is not accessible, in the foreground.
network-receiveThe icon used when data is being received, while the computing device is connected to a network. This icon should be two computers, one in the background, with its screen colored green, and the screen of the computer in the foreground,
colored black.
network-transmitThe icon used when data is being transmitted, while the computing device is connected to a network. This icon should be two computers, one in the background, with its screen colored black, and the screen of the computer in the foreground,
colored green.
network-transmit-receiveThe icon used data is being both transmitted and received simultaneously, while the computing device is connected to a network. This icon should be two computers, one in the background, with the screens of both computers, colored green.
printer-errorThe icon used when an error occurs while attempting to print. This icon should be the theme’s printer device icon, with the theme’s style element for errors, overlayed on top of the icon.
printer-printingThe icon used while a print job is successfully being spooled to a printing device. This icon should be the theme’s printer device icon, with a document emerging from the printing device.
security-highThe icon used to indicate that the security level of a connection is known to be secure, using strong encryption and a valid certificate.
security-mediumThe icon used to indicate that the security level of a connection is presumed to be secure, using strong encryption, and a certificate that could not be automatically verified, but which the user has chosen to trust.
security-lowThe icon used to indicate that the security level of a connection is presumed to be insecure, either by using weak encryption, or by using a certificate that the could not be automatically verified, and which the user has not chosent to
trust.
software-update-availableThe icon used when an update is available for software installed on the computing device, through the system software update program.
software-update-urgentThe icon used when an urgent update is available through the system software update program.
sync-errorThe icon used when an error occurs while attempting to synchronize data from the computing device, to another device.
sync-synchronizingThe icon used while data is successfully synchronizing to another device.
task-dueThe icon used when a task is due soon.
task-past-dueThe icon used when a task that was due, has been left incomplete.
user-availableThe icon used when a user on a chat network is available to initiate a conversation with.
user-awayThe icon used when a user on a chat network is away from their keyboard and the chat program.
user-idleThe icon used when a user on a chat network has not been an active participant in any chats on the network, for an extended period of time.
user-offlineThe icon used when a user on a chat network is not available.
user-trash-fullThe icon for the user’s “Trash” in the desktop’s file manager, when there are items in the “Trash” waiting for disposal or recovery.
weather-clearThe icon used while the weather for a region is “clear skies”.
weather-clear-nightThe icon used while the weather for a region is “clear skies” during the night.
weather-few-cloudsThe icon used while the weather for a region is “partly cloudy”.
weather-few-clouds-nightThe icon used while the weather for a region is “partly cloudy” during the night.
weather-fogThe icon used while the weather for a region is “foggy”.
weather-overcastThe icon used while the weather for a region is “overcast”.
weather-severe-alertThe icon used while a sever weather alert is in effect for a region.
weather-showersThe icon used while rain showers are occurring in a region.
weather-showers-scatteredThe icon used while scattered rain showers are occurring in a region.
weather-snowThe icon used while snow showers are occurring in a region.
weather-stormThe icon used while storms are occurring in a region.

不常用的选项

-c –category=TYPE[,TYPE…]

指定通知的类别.

该选项并不作为client与server的强制实现. 但有些notificatioin server会以不同的方式来显示不同类别的通知.

notification标准定义了如下几种类别:

类别说明
“device”A generic device-related notification that doesn’t fit into any other category.
“device.added”A device, such as a USB device, was added to the system.
“device.error”A device had some kind of error.
“device.removed”A device, such as a USB device, was removed from the system.
“email”A generic e-mail-related notification that doesn’t fit into any other category.
“email.arrived”A new e-mail notification.
“email.bounced”A notification stating that an e-mail has bounced.
“im”A generic instant message-related notification that doesn’t fit into any other category.
“im.error”An instant message error notification.
“im.received”A received instant message notification.
“network”A generic network notification that doesn’t fit into any other category.
“network.connected”A network connection notification, such as successful sign-on to a network service. This should not be confused with device.added for new network devices.
“network.disconnected”A network disconnected notification. This should not be confused with device.removed for disconnected network devices.
“network.error”A network-related or connection-related error.
“presence”A generic presence change notification that doesn’t fit into any other category, such as going away or idle.
“presence.offline”An offline presence change notification.
“presence.online”An online presence change notification.
“transfer”A generic file transfer or download notification that doesn’t fit into any other category.
“transfer.complete”A file transfer or download complete notification.
“transfer.error”A file transfer or download error.

-h –hint=TYPE:NAME:VALUE

指定传递给notification server的额外数据,其中TYPE只能是int,double,string以及byte中的一个.

该选项也不作为client与server的强制实现.

notification标准定义了如下几种hint:

NameValue TypeDescription
“urgency”byteThe urgency level.
“category”stringThe type of notification this is.
“image\_data”byteThis is a raw data image format which describes the width, height, rowstride, has alpha, bits per sample, channels and image data respectively. We use this value if the icon field is left blank.
“sound-file”stringThe path to a sound file to play when the notification pops up.
“x”intSpecifies the X location on the screen that the notification should point to. The “y” hint must also be specified.
“y”intSpecifies the Y location on the screen that the notification should point to. The “x” hint must also be specified.
转载自:http://blog.csdn.net/lujun9972/article/details/53292620
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  notify-send