D-Bus is a message bus system, a simple way for applications(I call it dbus client) to talk to
one another(dbus server). In addition to interprocess communication, D-Bus helps
coordinate process lifecycle; it makes it simple and reliable to code a
"single instance" application or daemon, and to launch applications and
daemons on demand when their services are needed.
The following is the architecture of the notification through dbus protocol in ubuntu operating system.
Server:
1)notify-osd
2)notification-daemon
Client:
1)libnotify-bin
2)as i know,program use pnotify module in python
This is the service that Dbus protocol exporting to other applications.
djstava@djstava:~$ cat /usr/share/dbus-1/services/org.freedesktop.Notifications.service
[D-BUS Service]
Name=org.freedesktop.Notifications
Exec=/bin/sh -c 'if [ ! -x /usr/lib/notification-daemon/notification-daemon ] || [ "${GDMSESSION%.desktop}" = gnome ] || [ "${GDMSESSION%.desktop}" = default -a "$(basename `readlink /etc/alternatives/x-session-manager`)" = gnome-session ]; then exec /usr/lib/notify-osd/notify-osd; else exec /usr/lib/notification-daemon/notification-daemon; fi'
sudo apt-get source notify-osd
cd notify-osd-0.9.24
vi notify-osd/src/default.c
Here is a copy of what you should see:
#define DEFAULT_DESKTOP_BOTTOM_GAP 6.0f
#define DEFAULT_BUBBLE_WIDTH 24.0f
#define DEFAULT_BUBBLE_MIN_HEIGHT 5.0f
#define DEFAULT_BUBBLE_MAX_HEIGHT 12.2f
#define DEFAULT_BUBBLE_VERT_GAP 0.5f
#define DEFAULT_BUBBLE_HORZ_GAP 0.5f
#define DEFAULT_BUBBLE_SHADOW_SIZE 0.7f
#define DEFAULT_BUBBLE_SHADOW_COLOR "#000000"
#define DEFAULT_BUBBLE_BG_COLOR "#131313"
#define DEFAULT_BUBBLE_BG_OPACITY "#cc"
#define DEFAULT_BUBBLE_HOVER_OPACITY "#66"
#define DEFAULT_BUBBLE_CORNER_RADIUS 0.375f
#define DEFAULT_CONTENT_SHADOW_SIZE 0.125f
#define DEFAULT_CONTENT_SHADOW_COLOR "#000000"
#define DEFAULT_MARGIN_SIZE 1.0f
#define DEFAULT_ICON_SIZE 3.0f
#define DEFAULT_GAUGE_SIZE 0.625f
#define DEFAULT_GAUGE_OUTLINE_WIDTH 0.125f
#define DEFAULT_TEXT_FONT_FACE "Sans"
#define DEFAULT_TEXT_TITLE_COLOR "#ffffff"
#define DEFAULT_TEXT_TITLE_WEIGHT TEXT_WEIGHT_BOLD
#define DEFAULT_TEXT_TITLE_SIZE 1.0f
#define DEFAULT_TEXT_BODY_COLOR "#eaeaea"
#define DEFAULT_TEXT_BODY_WEIGHT TEXT_WEIGHT_NORMAL
#define DEFAULT_TEXT_BODY_SIZE 0.9f
#define DEFAULT_PIXELS_PER_EM 10.0f
#define DEFAULT_SYSTEM_FONT_SIZE 10.0f
#define DEFAULT_SCREEN_DPI 96.0f
#define DEFAULT_GRAVITY GRAVITY_NORTH_EAST |
Note:DEFAULT_GRAVITY can take three values
1)GRAVITY_NONE: the behaviour in Jaunty. A notification will always go
into the top right corner.
2)GRAVITY_EAST: the behaviour NotifyOsd has been having for about a week
in Karmic's development cycle, with the notifications centered
vertically on the screen.
3)GRAVITY_NORTH_EAST: the Karmic behaviour. Works like GRAVITY_NONE but
does not put asynchronous notifications on top of the screen, even if
there is no synchronous notification being displayed.
./configure
make
make install(if you need)
Have a test,I change the DEFAULT_TEXT_TITLE_SIZE marco from 1.0f to 4.0f.
1)Install client(or python program use pnotify module,look at this post
http://blog.chinaunix.net/u3/93196/showart.php?id=2179984)
sudo apt-get install libnotify-bin
2)Make server start(Make sure other server like system default notify-osd of notification-daemon is not being used)
./src/notify-osd
3)Send notification to the server
notify-send "djstava" "I Love It"
If dbus server is not running,client will return error
djstava@djstava:~$ notify-send "djstava" "I Love It"
libnotify-Message: GetServerInformation call failed: The name org.freedesktop.Notifications was not provided by any .service files
libnotify-Message: Error getting spec version
Have fun
djstava
References:
1、
2、
3、
4、
5、
6、
Libnotify Reference Manual
阅读(3715) | 评论(0) | 转发(0) |