<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>
<channel>
	<title>apt-blog.net   无证程序员的PT桑 &#187; 通知机制</title>
	<atom:link href="http://apt-blog.net/tag/%e9%80%9a%e7%9f%a5%e6%9c%ba%e5%88%b6/feed" rel="self" type="application/rss+xml" />
	<link>http://apt-blog.net</link>
	<description>潜逃中。</description>
	<lastBuildDate>Fri, 18 May 2012 11:25:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>玩转libnotify</title>
		<link>http://apt-blog.net/playing_libnotify</link>
		<comments>http://apt-blog.net/playing_libnotify#comments</comments>
		<pubDate>Fri, 22 May 2009 14:56:55 +0000</pubDate>
		<dc:creator>PT</dc:creator>
				<category><![CDATA[Unix/Linux]]></category>
		<category><![CDATA[libnotify]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[通知机制]]></category>
		<guid isPermaLink="false">http://apt-blog.net/archives/386.html</guid>
		<description><![CDATA[Ubuntu 9.04一个特性就是新的通知机制Notify OSD，让人一眼看上去很酷的样子，其实只是基于libnotify的调用，别看又DBUS又OSD那么复杂，其实一点都不神秘，跟PT来： 1 2 3 4 5 6 7 8 #!/usr/bin/python #coding:utf-8 &#160; import pynotify &#160; pynotify.init &#40;&#34;PT-Title&#34;&#41; n = pynotify.Notification &#40;&#34;PT的贺电&#34;, &#34;PT再次发来贺电&#34;&#41; n.show &#40;&#41; 没看错，就是这么几句Python，保存成文件运行试试： 哈哈，很简单吧！ 如果你安装了libnotify-bin包，shell里面会有notify-send这个工具： notify-send &#34;PT的贺电&#34; &#34;PT发来贺电&#34; 差不多的效果，我就不抓图了，自己试试！ 当然除了python，libnotify还能在很多种语言的库实现，我用aptitude search libnotify搜索了一下，很明显有libinotify-ruby，libnotify-dev，libnotifymm-dev分别是ruby、C、C++方式的绑定，不过，python的pynotify是Ubuntu 9.04里面默认安装的呢…… 详细的开发还是看看Ubuntu的Notification Development Guidelines吧，注意在后部分有很多example的噢！！！]]></description>
			<content:encoded><![CDATA[<p>Ubuntu 9.04一个特性就是新的通知机制Notify OSD，让人一眼看上去很酷的样子，其实只是基于libnotify的调用，别看又DBUS又OSD那么复杂，其实一点都不神秘，跟PT来：</p>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">#!/usr/bin/python</span>
<span style="color: #808080; font-style: italic;">#coding:utf-8</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">import</span> pynotify
&nbsp;
pynotify.<span style="color: black;">init</span> <span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;PT-Title&quot;</span><span style="color: black;">&#41;</span>
n = pynotify.<span style="color: black;">Notification</span> <span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;PT的贺电&quot;</span>, <span style="color: #483d8b;">&quot;PT再次发来贺电&quot;</span><span style="color: black;">&#41;</span>
n.<span style="color: black;">show</span> <span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></td></tr></table></div>
<p>没看错，就是这么几句Python，保存成文件运行试试：<br />
<img src="http://apt-blog.net/wp-content/uploads/2009/05/notify.png" /></p>
<p>哈哈，很简单吧！</p>
<p>如果你安装了libnotify-bin包，shell里面会有notify-send这个工具：</p>
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">notify-send <span style="color: #ff0000;">&quot;PT的贺电&quot;</span> <span style="color: #ff0000;">&quot;PT发来贺电&quot;</span></pre></div></div>
<p>差不多的效果，我就不抓图了，自己试试！</p>
<p>当然除了python，libnotify还能在很多种语言的库实现，我用aptitude search libnotify搜索了一下，很明显有libinotify-ruby，libnotify-dev，libnotifymm-dev分别是ruby、C、C++方式的绑定，不过，python的pynotify是Ubuntu 9.04里面默认安装的呢……</p>
<p><span style="font-weight: bold;">详细的开发还是看看Ubuntu的<a href="https://wiki.ubuntu.com/NotificationDevelopmentGuidelines" target="_blank">Notification Development Guidelines</a>吧，注意在后部分有很多example的噢！！！</span></p>
]]></content:encoded>
			<wfw:commentRss>http://apt-blog.net/playing_libnotify/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

