<?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>Upthrust &#187; ubuntu</title>
	<atom:link href="http://blog.mpathirage.com/tag/ubuntu/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.mpathirage.com</link>
	<description>This is the weblog of Milinda Pathirage</description>
	<lastBuildDate>Mon, 29 Aug 2011 02:00:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Merging PDF Files In Linux Using PyPDF</title>
		<link>http://blog.mpathirage.com/2010/01/16/merging-pdf-files-in-linux-using-pypdf/</link>
		<comments>http://blog.mpathirage.com/2010/01/16/merging-pdf-files-in-linux-using-pypdf/#comments</comments>
		<pubDate>Sat, 16 Jan 2010 16:26:58 +0000</pubDate>
		<dc:creator>Milinda Lakmal</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[pdf]]></category>
		<category><![CDATA[pyPdf]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://blog.mpathirage.com/?p=263</guid>
		<description><![CDATA[PyPDF is a handy and valuable Python library for merging and splitting PDF files in Linux. It&#8217;s pure Python library built as a PDF toolkit. It is capable of: extracting document information (title, author, &#8230;), splitting documents page by page, merging documents page by page, cropping pages, merging multiple pages into a single page, encrypting [...]]]></description>
			<content:encoded><![CDATA[<p><strong><a rel="nofollow" href="http://pybrary.net/pyPdf/" target="_blank">PyPDF</a></strong> is a handy and valuable Python library for merging and splitting PDF files in Linux. It&#8217;s pure Python library built as a PDF toolkit. It is capable of:</p>
<ul>
<li>extracting document information (title, author, &#8230;),</li>
<li>splitting documents page by page,</li>
<li>merging documents page by page,</li>
<li>cropping pages,</li>
<li>merging multiple pages into a single page,</li>
<li>encrypting and decrypting PDF files.</li>
</ul>
<p>PyPDF is a great Python library use by many Python applications which handles PDF files directly. <strong>PDF-Shuffler </strong> is a one of the tools written based on PyPDF which you can use to merge PDF files easily in Linux. In Ubuntu you can install it using following command.</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get install</span> pdfshuffler</div></div>
<p>Here is a sample code that merge PDF files together using PyPDF library. In this code I have used PdfFileWriter and PdfFileReader classes from PyPDF module to read and append PDF files together. This sample doesn&#8217;t contain completed error handling logic for file handling.</p>
<div class="codecolorer-container python default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:350px;"><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #808080; font-style: italic;"># Copyright (C) 2010 Milinda Pathirage</span><br />
<br />
<span style="color: #808080; font-style: italic;"># Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);</span><br />
<span style="color: #808080; font-style: italic;"># you may not use this file except in compliance with the License.</span><br />
<span style="color: #808080; font-style: italic;"># You may obtain a copy of the License at</span><br />
<span style="color: #808080; font-style: italic;">#</span><br />
<span style="color: #808080; font-style: italic;"># &nbsp; &nbsp;http://www.apache.org/licenses/LICENSE-2.0</span><br />
<span style="color: #808080; font-style: italic;">#</span><br />
<span style="color: #808080; font-style: italic;"># Unless required by applicable law or agreed to in writing, software</span><br />
<span style="color: #808080; font-style: italic;"># distributed under the License is distributed on an &quot;AS IS&quot; BASIS,</span><br />
<span style="color: #808080; font-style: italic;"># WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span><br />
<span style="color: #808080; font-style: italic;"># See the License for the specific language governing permissions and</span><br />
<span style="color: #808080; font-style: italic;"># limitations under the License.</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span><br />
<span style="color: #ff7700;font-weight:bold;">from</span> pyPdf <span style="color: #ff7700;font-weight:bold;">import</span> PdfFileWriter<span style="color: #66cc66;">,</span> PdfFileReader<br />
<br />
<span style="color: #ff7700;font-weight:bold;">def</span> mergePDFFiles<span style="color: black;">&#40;</span>outputFile<span style="color: #66cc66;">,</span> filesToBeMerged<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; output <span style="color: #66cc66;">=</span> PdfFileWriter<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span><span style="color: black;">&#40;</span><span style="color: #008000;">len</span><span style="color: black;">&#40;</span>filesToBeMerged<span style="color: black;">&#41;</span> <span style="color: #66cc66;">==</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'Empty Input File List'</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span><span style="color: #66cc66;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> inFile <span style="color: #ff7700;font-weight:bold;">in</span> filesToBeMerged:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'Adding file'</span> + inFile + <span style="color: #483d8b;">' to the out put'</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># Read the input PDF file</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">input</span> <span style="color: #66cc66;">=</span> PdfFileReader<span style="color: black;">&#40;</span><span style="color: #008000;">file</span><span style="color: black;">&#40;</span>inFile<span style="color: #66cc66;">,</span> <span style="color: #483d8b;">&quot;rb&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># Add every page in input PDF file to output</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> page <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">input</span>.<span style="color: black;">pages</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; output.<span style="color: black;">addPage</span><span style="color: black;">&#40;</span>page<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'Writing the final out put to file system'</span><br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># Out put stream for output file &nbsp; &nbsp; &nbsp; &nbsp;</span><br />
&nbsp; &nbsp; outputStream <span style="color: #66cc66;">=</span> <span style="color: #008000;">file</span><span style="color: black;">&#40;</span>outputFile<span style="color: #66cc66;">,</span> <span style="color: #483d8b;">&quot;wb&quot;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; output.<span style="color: black;">write</span><span style="color: black;">&#40;</span>outputStream<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; outputStream.<span style="color: black;">close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <br />
<br />
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ <span style="color: #66cc66;">==</span> <span style="color: #483d8b;">'__main__'</span>:<br />
&nbsp; &nbsp; i <span style="color: #66cc66;">=</span> <span style="color: #ff4500;">0</span><br />
&nbsp; &nbsp; outputFile <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">''</span><br />
&nbsp; &nbsp; inputFiles <span style="color: #66cc66;">=</span> <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> arg <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; i <span style="color: #66cc66;">=</span> i + <span style="color: #ff4500;">1</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># Getting out file</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> arg <span style="color: #66cc66;">==</span> <span style="color: #483d8b;">'-o'</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outputFile <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span>i<span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'Output File: '</span> + outputFile<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># Extracting Input files</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> arg <span style="color: #66cc66;">==</span> <span style="color: #483d8b;">'-i'</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outfileOptionPos <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span>.<span style="color: black;">index</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'-o'</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> i <span style="color: #66cc66;">&lt;</span> outfileOptionPos:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inputFiles <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span>i: outfileOptionPos<span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; filesStr <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">&quot;,&quot;</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span>inputFiles<span style="color: black;">&#41;</span>.<span style="color: black;">replace</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;,&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">&quot; &quot;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'Input Files: '</span> + filesStr<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">else</span>: &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inputFiles <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span>i:<span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; filesStr <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">&quot;,&quot;</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span>inputFiles<span style="color: black;">&#41;</span>.<span style="color: black;">replace</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;,&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">&quot; &quot;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'Input Files: '</span> + filesStr<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># Merging PDF files</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'Merging PDF Files......'</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; mergePDFFiles<span style="color: black;">&#40;</span>outputFile<span style="color: #66cc66;">,</span> inputFiles<span style="color: black;">&#41;</span></div></div>
<p>You can get more understanding about usages of PyPDF if you explore more about open source projects which uses PyPDF. Here are some of the projects which use PyPDF.</p>
<ul>
<li><a href="http://code.google.com/p/flaxcode/" target="_blank">Falx: Fast, feature-rich, flexible enterprise search </a></li>
<li><a href="http://pybrary.net/" target="_blank">Pybrary</a></li>
<li><a href="http://code.google.com/p/xhtml2pdf-base/" target="_blank">xhtml2pdf-base</a></li>
<li><a href="http://code.google.com/p/nglib/" arget="_blank">nglib</a></li>
</ul>
<p>Related Resources:</p>
<ul>
<li><a rel="nofollow" href="http://code.activestate.com/recipes/511465/" target="_blank"> Pure Python PDF to text converter</a></li>
<li><a rel="nofollow" href="http://sourceforge.net/projects/pypdfgui/" target="_blank">PyPDF GUI</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.mpathirage.com/2010/01/16/merging-pdf-files-in-linux-using-pypdf/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Install Adobe Air 2 On Ubuntu 9.10 64-bit</title>
		<link>http://blog.mpathirage.com/2009/12/24/install-adobe-air-2-on-ubuntu-9-10-64-bit/</link>
		<comments>http://blog.mpathirage.com/2009/12/24/install-adobe-air-2-on-ubuntu-9-10-64-bit/#comments</comments>
		<pubDate>Thu, 24 Dec 2009 17:12:37 +0000</pubDate>
		<dc:creator>Milinda Lakmal</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Adobe Air]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://blog.mpathirage.com/?p=229</guid>
		<description><![CDATA[Adobe AIR is a cross-operating system runtime that lets developers combine HTML, Ajax, Adobe Flash, and Adobe Flex technologies to deploy rich Internet applications (RIAs) on the desktop. The most recent version is Adobe Air 2 with more features than ever for the users as well as developers. AIR 2 builds on the success of [...]]]></description>
			<content:encoded><![CDATA[<p>Adobe AIR is a cross-operating system runtime that lets developers combine HTML, Ajax, Adobe Flash, and Adobe Flex technologies to deploy rich Internet applications (RIAs) on the desktop. The most recent version is Adobe Air 2 with more features than ever for the users as well as developers.</p>
<p>AIR 2 builds on the success of AIR 1 by giving developers new capabilities, and even tighter integration with the desktop. Some new features of AIR 2 include:</p>
<ul style="list-style-type: disc; list-style-position: outside; list-style-image: initial; margin-left: 0.5em; padding-left: 1.5em; margin-top: 1em; margin-bottom: 1.35em;">
<li style="font-size: 1em; line-height: 1.35em; padding-bottom: 0.5em;">Support for the detection of mass storage devices.</li>
<li style="font-size: 1em; line-height: 1.35em; padding-bottom: 0.5em;">Advanced networking capabilities like secure sockets, UDP support, and the ability to listen on sockets.</li>
<li style="font-size: 1em; line-height: 1.35em; padding-bottom: 0.5em;">Support for native code integration.</li>
<li style="font-size: 1em; line-height: 1.35em; padding-bottom: 0.5em;">The ability to open a file with its default application.</li>
<li style="font-size: 1em; line-height: 1.35em; padding-bottom: 0.5em;">Multi-touch and gesture support.</li>
<li style="font-size: 1em; line-height: 1.35em; padding-bottom: 0.5em;">New APIs for access to raw microphone data.</li>
<li style="font-size: 1em; line-height: 1.35em; padding-bottom: 0.5em;">Webkit update with HTML5/CSS3 support.</li>
<li style="font-size: 1em; line-height: 1.35em; padding-bottom: 0.5em;">Global error handling.</li>
<li style="font-size: 1em; line-height: 1.35em; padding-bottom: 0.5em;">Improved cross-platform printing</li>
<li style="font-size: 1em; line-height: 1.35em; padding-bottom: 0.5em;">Improved security and support for enterprise and government standards.</li>
</ul>
<p>The beta release of Adobe Air 2 is available for download from Adobe site. But the problem is they don&#8217;t provide us with a 64-bit Linux version(for Ubuntu 9.10 64-bit). But there are some workarounds to this problem. You can install 32-bit version in 64-bit Ubuntu by installing some 32-bit libraries.</p>
<p>First, install &#8216;<strong><em>getlibs</em></strong>&#8216; tool from <a rel="nofollow" href="http://frozenfox.freehostia.com/cappy/getlibs-all.deb" target="_blank">http://frozenfox.freehostia.com/cappy/getlibs-all.deb</a>. Then install &#8216;libhal-storage.so.1&#8242; library using following command.</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">sudo</span> getlibs <span style="color: #660033;">-l</span> libhal-storage.so.1</div></div>
<p>After the above step please download the Adobe Air 2 beta version&#8217;s Linux *.bin file from <a rel="nofollow" href="http://labs.adobe.com/downloads/air2.html" target="_blank">Adobe</a>, and install it by making it a executable and run the bin file in command line.</p>
<p>If every things went well, now you have Adobe Air 2 beta installed on your system. Please restart your browsers and try to navigate to some Adobe Air application sites and install your favorite Air applications from them.</p>
<p>Please note that I have &#8216;<em><strong>ia32-libs</strong></em>&#8216; installed in my Ubuntu 9.10 previously. If you have any problem running Adobe Air using above two steps, try to install the &#8216;ia32-libs&#8217; using Ubuntu package manager. Also refer <a rel="nofollow" href="http://kb2.adobe.com/cps/408/kb408084.html" target="_blank">this knowledge base article</a> from Adobe on installing Adobe Air 1.5 in 64-bit Linux including Ubuntu.</p>
<p>For more information Adobe Air 2:</p>
<ul>
<li><a rel="nofollow" href="http://www.adobe.com/devnet/logged_in/rchristensen_air_2.html" target="_blank">Introducing Adobe AIR 2 beta</a></li>
<li><a rel="nofollow" href="http://tv.adobe.com/watch/max-2009-develop/whats-coming-in-adobe-air-2-/" target="_blank">What&#8217;s Coming in Adobe AIR 2</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.mpathirage.com/2009/12/24/install-adobe-air-2-on-ubuntu-9-10-64-bit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To Disable Dynamic Frequency Scaling(CPU Throttling) In Ubuntu Jaunty(9.04)</title>
		<link>http://blog.mpathirage.com/2009/10/04/how-to-disable-dynamic-frequency-scalingcpu-throttling-in-ubuntu-jaunty9-04/</link>
		<comments>http://blog.mpathirage.com/2009/10/04/how-to-disable-dynamic-frequency-scalingcpu-throttling-in-ubuntu-jaunty9-04/#comments</comments>
		<pubDate>Sun, 04 Oct 2009 04:05:46 +0000</pubDate>
		<dc:creator>Milinda Lakmal</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[cpu throttling]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://blog.mpathirage.com/?p=157</guid>
		<description><![CDATA[The management of energy consumption in laptops and other mobile devices is increasingly important in order to extend the battery lifetime or to increase the number of applications that can use the system’s resources. It is also used in quiet computing settings and to decrease energy and cooling costs for lightly loaded machines. Even though [...]]]></description>
			<content:encoded><![CDATA[<p>The management of energy consumption in laptops and other mobile devices is increasingly important in order to extend the battery lifetime or to increase the number of applications that can use the system’s resources. It is also used in <a title="Quiet PC" href="http://en.wikipedia.org/wiki/Quiet_PC">quiet computing settings</a> and to decrease energy and cooling costs for lightly loaded machines.</p>
<p>Even though this technology has many advantages when using laptop with battery power, it makes me annoying sometimes when I work using AC power.In some situation it makes my laptop very slow when I run several applications like Firefox, IntelliJ IDEA and Adobe Acrobat simultaneously. I have to always switch frequency scaling to performance to get required level of responsiveness and sometimes my Ubuntu 9.04 failed to scale the frequency when I want it to do it. Because I have AC power most of the times I decided to switch to performance mode permanently.</p>
<p>As I found out, <span style="font-style: italic;">sudo dpkg-reconfigure gnome-applets</span> method does not work anymore and instead I have to install rcconf and configure CPU throttling using <em>rcconf</em>.</p>
<p>First we need to install rcconf using <span style="text-decoration: underline;"><em>sudo apt-get install rcconf</em></span> command and then run it with administrative privileges using <span style="text-decoration: underline;"><em>sudo rcconf </em></span>. You will following configuration view on you terminal. Then search for &#8216;<span style="text-decoration: underline;"><em>ondemand</em></span>&#8216; option and disable(un-check the check-box) it using space-bar. To save the configuration hit the tab key so that &#8220;OK&#8221; is highlighted then enter to save and reboot.</p>
<p style="text-align: center;"><img class="aligncenter" title="rcconf" src="http://blog.mpathirage.com/wp-content/uploads/2009/10/cpu_scale.png" alt="rcconf" width="490" height="365" /></p>
<p>Now from the add <span style="text-decoration: underline;"><em>CPU Frequency Scaling Monitor</em></span> applet to your Gnome panel and select &#8216;Performance&#8217; option by clicking applet.</p>
<p><strong>How to revert the change</strong></p>
<p>Open the <em>rcconf</em> application again with administrative privileges and scroll to bottom. There will be un-checked &#8216;ondemand&#8217; option, check it using space-bar and save. The change will be available from the next restart.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mpathirage.com/2009/10/04/how-to-disable-dynamic-frequency-scalingcpu-throttling-in-ubuntu-jaunty9-04/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Using libnotify in Ubuntu 9.04</title>
		<link>http://blog.mpathirage.com/2009/09/12/using-libnotify-in-ubuntu-9-04/</link>
		<comments>http://blog.mpathirage.com/2009/09/12/using-libnotify-in-ubuntu-9-04/#comments</comments>
		<pubDate>Sat, 12 Sep 2009 14:00:09 +0000</pubDate>
		<dc:creator>Milinda Lakmal</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[c]]></category>
		<category><![CDATA[libnotify]]></category>
		<category><![CDATA[notify osd]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://blog.mpathirage.com/?p=140</guid>
		<description><![CDATA[There are some applications which need to send notifications to users. Ubuntu 9.04 has new on-screen-display notification agent called Notify OSD which implmeents freedesktop.org Desktop Notifications Specification with semi-transparent click-through bubbles. This post is not about Notify OSD, but about how you can use libnotify to send notifications in you shell scripts, C programs and [...]]]></description>
			<content:encoded><![CDATA[<p>There are some applications which need to send notifications to users. Ubuntu 9.04 has new on-screen-display notification agent called <a href="https://launchpad.net/notify-osd" target="_blank">Notify OSD</a> which implmeents freedesktop.org Desktop Notifications Specification with semi-transparent click-through bubbles. This post is not about Notify OSD, but about how you can use libnotify to send notifications in you shell scripts, C programs and Python programs.</p>
<p><strong>Send notifications from your shell scripts</strong></p>
<p>You have to install <strong><em>libnotify-bin</em></strong> package in Ubuntu and you can use <strong><em>notify-send</em></strong> command to send notifications from your shell script. After installing libnotify-bin you can try notify-send command just like following.</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">notify-send <span style="color: #ff0000;">&quot;First Notification&quot;</span></div></div>
<p>By default the message will be displayed for 5 seconds. To change how long a message stays displayed use the &#8220;-t&#8221; switch. You can use &#8220;-t 0&#8243; leave the message up until the user closes it. But in new Ubuntu notification agent will display these notifications as alert box. You can find great explanations about <a href="https://wiki.ubuntu.com/NotificationDevelopmentGuidelines" target="_blank">Notify OSD here</a>.</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">notify-send <span style="color: #ff0000;">&quot;This message will be displayed for 3 seconds&quot;</span> <span style="color: #660033;">-t</span> <span style="color: #000000;">3000</span><br />
notify-send <span style="color: #ff0000;">&quot;Click me to close me.&quot;</span> <span style="color: #660033;">-t</span> <span style="color: #000000;">0</span></div></div>
<p>Add title to your notification like following:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">notify-send <span style="color: #ff0000;">&quot;This is the Title&quot;</span> &nbsp;<span style="color: #ff0000;">&quot;This is the message body&quot;</span></div></div>
<p>Add icon with title and message body(You can find <a href="https://wiki.ubuntu.com/NotificationDevelopmentGuidelines#How%20do%20I%20get%20these%20slick%20icons" target="_blank">icon codes here</a>):</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">notify-send <span style="color: #ff0000;">&quot;New Mail&quot;</span> <span style="color: #ff0000;">&quot;Hey buddy, you got a new E-mail&quot;</span> <span style="color: #660033;">-i</span> notification-message-email</div></div>
<p><strong>Send notifications from your Python application</strong></p>
<p>You need to install <strong><em>python-notify</em></strong> package first and then you can use <strong>pynotify</strong> to send notification from your Python script. There are different capabilities in different notification agents. I am ignoring getting those information in this example.</p>
<div class="codecolorer-container python default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #808080; font-style: italic;">#!/usr/bin/python</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span><br />
<span style="color: #ff7700;font-weight:bold;">import</span> pynotify<br />
<br />
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ <span style="color: #66cc66;">==</span> <span style="color: #483d8b;">&quot;__main__&quot;</span>:<br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># Check whether your notification agent support</span><br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># incon-summary-body layout.</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> pynotify.<span style="color: black;">init</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;icon-summary-body&quot;</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #dc143c;">sys</span>.<span style="color: black;">exit</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span><br />
<br />
&nbsp; &nbsp; n <span style="color: #66cc66;">=</span> pynotify.<span style="color: black;">Notification</span><span style="color: black;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">&quot;You have a mail&quot;</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">&quot;You have new e-mail from Milinda&quot;</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">&quot;notification-message-email&quot;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; n.<span style="color: black;">show</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></div>
<p><strong>Sample code in C</strong><br />
You need to install <strong><em>libnotify-dev</em></strong>, <strong><em>libglib2.0-dev</em></strong> and <em><strong>libgtk2.0-dev</strong></em> packages first. You can compile this sample using following gcc command.</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">gcc</span> test_notify.c <span style="color: #000000; font-weight: bold;">`</span>pkg-config <span style="color: #660033;">--cflags</span> glib-<span style="color: #000000;">2.0</span><span style="color: #000000; font-weight: bold;">`</span> <span style="color: #000000; font-weight: bold;">`</span>pkg-config <span style="color: #660033;">--cflags</span> <span style="color: #660033;">--libs</span> gtk+-<span style="color: #000000;">2.0</span><span style="color: #000000; font-weight: bold;">`</span> <span style="color: #660033;">-lnotify</span></div></div>
<div class="codecolorer-container c default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:350px;"><div class="c codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #339933;">#include</span><br />
<span style="color: #339933;">#include</span><br />
<span style="color: #339933;">#include</span><br />
<br />
<span style="color: #993333;">void</span> closed_handler <span style="color: #009900;">&#40;</span>NotifyNotification<span style="color: #339933;">*</span> notification<span style="color: #339933;">,</span> gpointer data<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; g_print <span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;closed_handler() called&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> argc<span style="color: #339933;">,</span> <span style="color: #993333;">char</span><span style="color: #339933;">**</span> argv<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; NotifyNotification<span style="color: #339933;">*</span> notification<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; gboolean &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;success<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; GError<span style="color: #339933;">*</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; error <span style="color: #339933;">=</span> NULL<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>notify_init <span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;icon-summary-body&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; notification <span style="color: #339933;">=</span> notify_notification_new <span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #ff0000;">&quot;You have a mail&quot;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #ff0000;">&quot;You have mail from Milinda&quot;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #ff0000;">&quot;notification-message-email&quot;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;NULL<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; error <span style="color: #339933;">=</span> NULL<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; success <span style="color: #339933;">=</span> notify_notification_show <span style="color: #009900;">&#40;</span>notification<span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span>error<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>success<span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; g_print <span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;That did not work ... <span style="color: #000099; font-weight: bold;">\&quot;</span>%s<span style="color: #000099; font-weight: bold;">\&quot;</span>.<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> error<span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>message<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; g_signal_connect <span style="color: #009900;">&#40;</span>G_OBJECT <span style="color: #009900;">&#40;</span>notification<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">&quot;closed&quot;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; G_CALLBACK <span style="color: #009900;">&#40;</span>closed_handler<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; NULL<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; notify_uninit <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p>For more information please refer <a href="https://wiki.ubuntu.com/NotificationDevelopmentGuidelines#How%20do%20I%20get%20these%20slick%20icons" target="_blank">Ubuntu Notification Development Guidelines</a> document.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mpathirage.com/2009/09/12/using-libnotify-in-ubuntu-9-04/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

