<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://maemo.octonezd.me/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=75.119.206.105</id>
	<title>Maemo Wiki Mirror - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://maemo.octonezd.me/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=75.119.206.105"/>
	<link rel="alternate" type="text/html" href="https://maemo.octonezd.me/index.php/Special:Contributions/75.119.206.105"/>
	<updated>2026-04-22T01:45:43Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://maemo.octonezd.me/index.php?title=Desktop_Command_Execution_Widget_scripts&amp;diff=5623</id>
		<title>Desktop Command Execution Widget scripts</title>
		<link rel="alternate" type="text/html" href="https://maemo.octonezd.me/index.php?title=Desktop_Command_Execution_Widget_scripts&amp;diff=5623"/>
		<updated>2011-10-31T03:16:40Z</updated>

		<summary type="html">&lt;p&gt;75.119.206.105: /* Enable */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Desktop Command Execution widget is one of the most useful widgets on your Maemo desktop. It can be used to show certain information (for example battery level in percentage) or as a button which can be used for example to disconnect active internet connection (you need to tap 3 times and also wait for menus to appear without this widget). Therefore it can replace many other applications/widgets/applets and you can also make something new. Here you&#039;ll find a collection of scripts that can be added to the widget. The discussion about the widget is [http://talk.maemo.org/showthread.php?t=39177 on the forum].&lt;br /&gt;
&lt;br /&gt;
Scripts are also compatible with [[Queen BeeCon Widget]] which has extended graphic and cosmetic functionality, but is far more complicated.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Making your own scripts==&lt;br /&gt;
&lt;br /&gt;
===Scripts without output===&lt;br /&gt;
&lt;br /&gt;
When there&#039;s no output (for example if you&#039;re using widget as a button and you use D-Bus call) the widget displays &amp;quot;Invalid Command&amp;quot;. This can be most easily avoided if you pipe echo &amp;quot;&amp;quot; at the end of the command. This is also usable if your script produces unwanted output (D-Bus reply for example).&lt;br /&gt;
&lt;br /&gt;
 dbus-send -options -moreoptions | echo &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Collection of D-Bus calls can be found on [[Phone control]] wiki page. The basic principle for making a script for DCEW is the same as above (D-Bus command and piping an echo).&lt;br /&gt;
&lt;br /&gt;
===Scripts with long output===&lt;br /&gt;
&lt;br /&gt;
Some scripts may create multiple lines which are too long to be displayed on a single line. The widget will not wrap these. In order to wrap them you can use the fold command:&lt;br /&gt;
 &lt;br /&gt;
 command-that-produces-long-lines | fold -s -w 80&lt;br /&gt;
&lt;br /&gt;
The 80 in that instance is the maximum length of the line, which you can change. The -s option makes fold word wrap with spaces. More information is available from the [http://unixhelp.ed.ac.uk/CGI/man-cgi?fold fold man page].&lt;br /&gt;
&lt;br /&gt;
==Scripts to display information==&lt;br /&gt;
&lt;br /&gt;
===Battery===&lt;br /&gt;
&lt;br /&gt;
All battery scripts are collected here. Pick the one which suits your needs. Examples of the output values are under each one.&lt;br /&gt;
&lt;br /&gt;
There are 2 values for full battery capacity available. First one is design charge in mAh, which is always the same (1273 mAh). The second one is the one used in these scripts and it is the full charge from last charging. With displaying this one you can also monitor battery wear level.&lt;br /&gt;
&lt;br /&gt;
Battery percentage level is calculated using first value and is therefore less accurate, that&#039;s why you cannot achieve 100% full battery, but only about 95%. After some time the full percentage will be even lower.&lt;br /&gt;
&lt;br /&gt;
But last full charge value has one disadvantage. This is that after a reboot the phone forgets this value and the value returned is 0. It shows the proper value after next charging.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Percentage, current and last full charge====&lt;br /&gt;
&lt;br /&gt;
 hal-device bme | awk &#039;/l.p/ {perc = $3}; /g.c/ {curr = $3}; /g.la/ {last = $3}; /s_c/ {isch = $3} END if (isch == &amp;quot;false&amp;quot;) {print perc&amp;quot; % (&amp;quot;curr&amp;quot;/&amp;quot;last&amp;quot; mAh)&amp;quot;} else {print &amp;quot;Charging&amp;quot;}&#039;&lt;br /&gt;
&lt;br /&gt;
Output example: &#039;&#039;&#039;83 % (1000/1200 mAh)&#039;&#039;&#039;, when charging &#039;&#039;&#039;Charging&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Percentage and current charge====&lt;br /&gt;
&lt;br /&gt;
 hal-device bme | awk &#039;/l.p/ {perc = $3}; /g.c/ {curr = $3}; /s_c/ {isch = $3} END if (isch == &amp;quot;false&amp;quot;) {print perc&amp;quot; % (&amp;quot;curr&amp;quot; mAh)&amp;quot;} else {print &amp;quot;Charging&amp;quot;}&#039;&lt;br /&gt;
&lt;br /&gt;
Output example: &#039;&#039;&#039;83 % (1000 mAh)&#039;&#039;&#039;, when charging &#039;&#039;&#039;Charging&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Percentage====&lt;br /&gt;
&lt;br /&gt;
 hal-device bme | awk &#039;/l.p/ {perc = $3}; /s_c/ {isch = $3} END if (isch == &amp;quot;false&amp;quot;) {print perc&amp;quot; %&amp;quot;} else {print &amp;quot;Chrg&amp;quot;}&#039;&lt;br /&gt;
&lt;br /&gt;
Output example: &#039;&#039;&#039;83 %&#039;&#039;&#039;, when charging &#039;&#039;&#039;Chrg&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Current and last full charge====&lt;br /&gt;
&lt;br /&gt;
 hal-device bme | awk &#039;/g.c/ {curr = $3}; /g.la/ {last = $3} END {print curr&amp;quot;/&amp;quot;last&amp;quot; mAh&amp;quot;}&#039;&lt;br /&gt;
&lt;br /&gt;
Output example: &#039;&#039;&#039;1000/1200 mAh&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Current charge====&lt;br /&gt;
&lt;br /&gt;
 hal-device bme | awk &#039;/g.c/ {print $3&amp;quot; mAh&amp;quot;}&#039;&lt;br /&gt;
&lt;br /&gt;
Output example: &#039;&#039;&#039;1000 mAh&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Last full charge====&lt;br /&gt;
&lt;br /&gt;
 hal-device bme | awk &#039;/g.la/ {print $3&amp;quot; mAh&amp;quot;}&#039;&lt;br /&gt;
&lt;br /&gt;
Output example: &#039;&#039;&#039;1200 mAh&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===IP===&lt;br /&gt;
&lt;br /&gt;
Internal IPs are obtained from the ifconfig and external IPs are obtained from the internet, because gprs0 IP which you can get with ifconfig is often from private address range, because mobile operators like to use NAT.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====External (WAN) and internal (LAN)====&lt;br /&gt;
&lt;br /&gt;
 echo WAN IP: `wget -t 2 -T 3 -q -O - api.myiptest.com | awk -F &amp;quot;\&amp;quot;&amp;quot; &#039;{print $4}&#039;`; echo LAN IP: `/sbin/ifconfig wlan0 | awk -F &amp;quot;[: ]&amp;quot; &#039;/Bc/ {print $13}&#039;`&lt;br /&gt;
&lt;br /&gt;
Output example:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WAN IP: 1.2.3.4&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;LAN IP: 192.168.1.2&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 echo WAN IP: `wget -t 2 -T 3 -q -O - api.myiptest.com | awk -F &amp;quot;\&amp;quot;&amp;quot; &#039;{print $4 &amp;quot; (&amp;quot;$12&amp;quot; &amp;quot;toupper($28)&amp;quot;)&amp;quot;}&#039;`; echo LAN IP: `/sbin/ifconfig wlan0 | awk -F &amp;quot;[: ]&amp;quot; &#039;/Bc/ {print $13}&#039;`&lt;br /&gt;
&lt;br /&gt;
Output example:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WAN IP: 1.2.3.4 (ISP CountryCode)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;LAN IP: 192.168.1.2&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 echo WAN IP: `wget -t 2 -T 3 -q -O - api.myiptest.com | awk -F &amp;quot;\&amp;quot;&amp;quot; &#039;{print $4&amp;quot; (&amp;quot;$12&amp;quot; @ &amp;quot;$20&amp;quot;, &amp;quot;toupper($28)&amp;quot;)&amp;quot;}&#039;`; echo LAN IP: `/sbin/ifconfig wlan0 | awk -F &amp;quot;[: ]&amp;quot; &#039;/Bc/ {print $13}&#039;`&lt;br /&gt;
&lt;br /&gt;
Output example:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WAN IP: 1.2.3.4 (ISP @ City, CountryCode)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;LAN IP: 192.168.1.2&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
====External (WAN)====&lt;br /&gt;
&lt;br /&gt;
 wget -t 2 -T 3 -q -O - api.myiptest.com | awk -F &amp;quot;\&amp;quot;&amp;quot; &#039;{print $4}&#039;&lt;br /&gt;
&lt;br /&gt;
Output example: &#039;&#039;&#039;1.2.3.4&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 wget -t 2 -T 3 -q -O - api.myiptest.com | awk -F &amp;quot;\&amp;quot;&amp;quot; &#039;{print $4 &amp;quot; (&amp;quot;$12&amp;quot; &amp;quot;toupper($28)&amp;quot;)&amp;quot;}&#039;&lt;br /&gt;
&lt;br /&gt;
Output example: &#039;&#039;&#039;1.2.3.4 (ISP CountryCode)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 wget -t 2 -T 3 -q -O - api.myiptest.com | awk -F &amp;quot;\&amp;quot;&amp;quot; &#039;{print $4&amp;quot; (&amp;quot;$12&amp;quot; @ &amp;quot;$20&amp;quot;, &amp;quot;toupper($28)&amp;quot;)&amp;quot;}&#039;&lt;br /&gt;
&lt;br /&gt;
Output example: &#039;&#039;&#039;1.2.3.4 (ISP @ City, CountryCode)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Internal (LAN)====&lt;br /&gt;
&lt;br /&gt;
 /sbin/ifconfig wlan0 | awk -F &amp;quot;[: ]&amp;quot; &#039;/Bc/ {print $13}&#039;&lt;br /&gt;
&lt;br /&gt;
This one displays only wlan0 IP (used for SSH, WinSCP, VNC... in LAN).&lt;br /&gt;
&lt;br /&gt;
===Disk usage===&lt;br /&gt;
&lt;br /&gt;
====rootfs (256MB /) percentage used====&lt;br /&gt;
&lt;br /&gt;
 df | awk &#039;$1 == &amp;quot;rootfs&amp;quot; {print $5}&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====rootfs (256MB /) free space====&lt;br /&gt;
&lt;br /&gt;
 df -h | awk &#039;$1 == &amp;quot;rootfs&amp;quot; {print $4}&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Internal memory for user data (27GB /home/user/MyDocs) percentage used====&lt;br /&gt;
&lt;br /&gt;
 df /home/user/MyDocs | awk &#039;/My/ {print $5}&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Internal memory for user data (27GB /home/user/MyDocs) free space====&lt;br /&gt;
&lt;br /&gt;
 df -h /home/user/MyDocs | awk &#039;/My/ {print $4}&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Internal memory for application data (2GB /home) percentage used====&lt;br /&gt;
&lt;br /&gt;
 df /home | awk &#039;/ho/ {print $5}&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Internal memory for application data (2GB /home) free space====&lt;br /&gt;
&lt;br /&gt;
 df -h /home | awk &#039;/ho/ {print $4}&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Memory card (/media/mmc1) percentage used====&lt;br /&gt;
&lt;br /&gt;
 df /media/mmc1 | awk &#039;/mm/ {print $5}&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Memory card (/media/mmc1) free space====&lt;br /&gt;
&lt;br /&gt;
 df -h /media/mmc1 | awk &#039;/mm/ {print $4}&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Cellular signal===&lt;br /&gt;
&lt;br /&gt;
====Quality====&lt;br /&gt;
&lt;br /&gt;
 dbus-send --system --print-reply --dest=com.nokia.phone.net /com/nokia/phone/net Phone.Net.get_signal_strength | awk &#039;NR==2 {print $2&amp;quot; %&amp;quot;}&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Strength====&lt;br /&gt;
&lt;br /&gt;
 dbus-send --system --print-reply --dest=com.nokia.phone.net /com/nokia/phone/net Phone.Net.get_signal_strength | awk &#039;NR==3 {print &amp;quot;-&amp;quot;$2&amp;quot; dBm&amp;quot;}&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Wi-Fi signal===&lt;br /&gt;
&lt;br /&gt;
====Quality====&lt;br /&gt;
&lt;br /&gt;
 awk -F &amp;quot;[. ]&amp;quot; &#039;/0/ {print $6&amp;quot; %&amp;quot;}&#039; /proc/net/wireless&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====RSSI====&lt;br /&gt;
&lt;br /&gt;
 awk &#039;/0/ {print $4&amp;quot; dBm&amp;quot;}&#039; /proc/net/wireless&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Noise====&lt;br /&gt;
&lt;br /&gt;
 awk -F &amp;quot;[. ]&amp;quot; &#039;/0/ {print $12&amp;quot; dBm&amp;quot;}&#039; /proc/net/wireless&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===CPU frequency===&lt;br /&gt;
&lt;br /&gt;
 awk &#039;{print $1/1000&amp;quot; MHz&amp;quot;}&#039; /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq&lt;br /&gt;
&lt;br /&gt;
====Usage of each frequency====&lt;br /&gt;
&lt;br /&gt;
 awk -v var=$(awk &#039;{sum+=$2}; END {print sum};&#039; /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state) &#039;{arr[$3]=$2}{for (i in arr) {print $1/1000 &amp;quot; mhz &amp;quot; int(arr[i]*100/var)&amp;quot;%&amp;quot;}}&#039; /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state&lt;br /&gt;
&lt;br /&gt;
===Memory usage===&lt;br /&gt;
&lt;br /&gt;
====RAM used====&lt;br /&gt;
&lt;br /&gt;
 awk &#039;/mT/ {memttl = $2}; /mF/ {memfre = $2}; /Bu/ {membff = $2}; $1 == &amp;quot;Cached:&amp;quot; {memcch = $2} END {printf (&amp;quot;%.1f MB\n&amp;quot;,(memttl-memfre-membff-memcch)/1024)}&#039; /proc/meminfo&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====RAM free====&lt;br /&gt;
&lt;br /&gt;
 awk &#039;/mF/ {memfre = $2}; /Bu/ {membff = $2}; $1 == &amp;quot;Cached:&amp;quot; {memcch = $2} END {printf (&amp;quot;%.1f MB\n&amp;quot;,(memfre+membff+memcch)/1024)}&#039; /proc/meminfo&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Swap used====&lt;br /&gt;
&lt;br /&gt;
 awk &#039;/pT/ {swpttl = $2}; /pF/ {swpfre = $2} END {printf (&amp;quot;%.1f MB\n&amp;quot;,(swpttl-swpfre)/1024)}&#039; /proc/meminfo&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Swap free====&lt;br /&gt;
&lt;br /&gt;
 awk &#039;/pF/ {printf (&amp;quot;%.1f MB\n&amp;quot;,$2/1024)}&#039; /proc/meminfo&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Total memory used====&lt;br /&gt;
&lt;br /&gt;
 awk &#039;/mT/ {memttl = $2}; /mF/ {memfre = $2}; /Bu/ {membff = $2}; $1 == &amp;quot;Cached:&amp;quot; {memcch = $2}; /pT/ {swpttl = $2}; /pF/ {swpfre = $2} END {printf (&amp;quot;%.1f MB\n&amp;quot;,(memttl+swpttl-memfre-membff-memcch-swpfre)/1024)}&#039; /proc/meminfo&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Total memory free====&lt;br /&gt;
&lt;br /&gt;
 awk &#039;/mF/ {memfre = $2}; /Bu/ {membff = $2}; $1 == &amp;quot;Cached:&amp;quot; {memcch = $2}; /pF/ {swpfre = $2} END {printf (&amp;quot;%.1f MB\n&amp;quot;,(memfre+membff+memcch+swpfre)/1024)}&#039; /proc/meminfo&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===GPRS data usage===&lt;br /&gt;
&lt;br /&gt;
You can use this with scheduled reset of the GPRS data counter to display data usage for current month. Additional info can be found on [[fcron]] wiki page.&lt;br /&gt;
&lt;br /&gt;
These scripts are now compatibile with PR1.2 (separate home and roaming counter), which means they won&#039;t work on previous versions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Home counter (combined)====&lt;br /&gt;
&lt;br /&gt;
 echo `gconftool-2 -g /system/osso/connectivity/network_type/GPRS/gprs_home_rx_bytes` `gconftool-2 -g /system/osso/connectivity/network_type/GPRS/gprs_home_tx_bytes` | awk &#039;{printf (&amp;quot;%.1f MB\n&amp;quot;,($1+$2)/1048576)}&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Home counter (separated)====&lt;br /&gt;
&lt;br /&gt;
 echo `gconftool-2 -g /system/osso/connectivity/network_type/GPRS/gprs_home_rx_bytes | awk &#039;{printf (&amp;quot;Download: %.1f MB\n&amp;quot;,$1/1048576)}&#039;`; echo `gconftool-2 -g /system/osso/connectivity/network_type/GPRS/gprs_home_tx_bytes | awk &#039;{printf (&amp;quot;Upload: %.1f MB\n&amp;quot;,$1/1048576)}&#039;`&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Roaming counter (combined)====&lt;br /&gt;
&lt;br /&gt;
 echo `gconftool-2 -g /system/osso/connectivity/network_type/GPRS/gprs_roaming_rx_bytes` `gconftool-2 -g /system/osso/connectivity/network_type/GPRS/gprs_roaming_tx_bytes` | awk &#039;{printf (&amp;quot;%.1f MB\n&amp;quot;,($1+$2)/1048576)}&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Roaming counter (separated)====&lt;br /&gt;
&lt;br /&gt;
 echo `gconftool-2 -g /system/osso/connectivity/network_type/GPRS/gprs_roaming_rx_bytes | awk &#039;{printf (&amp;quot;Download: %.1f MB\n&amp;quot;,$1/1048576)}&#039;`; echo `gconftool-2 -g /system/osso/connectivity/network_type/GPRS/gprs_roaming_tx_bytes | awk &#039;{printf (&amp;quot;Upload: %.1f MB\n&amp;quot;,$1/1048576)}&#039;`&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Time and date===&lt;br /&gt;
&lt;br /&gt;
====Date====&lt;br /&gt;
&lt;br /&gt;
 date +&amp;quot;%a, %-d.%-m.%Y&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This command will show the date in format (for example) &#039;&#039;&#039;Tue, 4.5.2010&#039;&#039;&#039;. You can define your own format (between the quotation marks). Possible options are described on [http://unixhelp.ed.ac.uk/CGI/man-cgi?date manpage].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Time in different timezones====&lt;br /&gt;
 &lt;br /&gt;
 export TZ=&amp;quot;Europe/London&amp;quot;; date +%R&lt;br /&gt;
&lt;br /&gt;
This one shows two timezones in format &#039;&#039;London: 13:04 | Denver: 06:04&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 echo &amp;quot;London:&amp;quot; `export TZ=&amp;quot;Europe/London&amp;quot;; date +%R` &amp;quot;| Denver:&amp;quot; `export TZ=&amp;quot;America/Denver&amp;quot;; date +%R`&lt;br /&gt;
&lt;br /&gt;
London and Denver are taken as an example. TZ values can be found on [[:wikipedia:List_of_tz_database_time_zones|Wikipedia]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Uptime and load===&lt;br /&gt;
&lt;br /&gt;
These scripts are formatproof meaning that they display what they&#039;re supposed to no matter what format is command &amp;quot;uptime&amp;quot; outputting. Not all scripts found are like that, because &amp;quot;uptime&amp;quot; command is a little bit complicated for scripted text processing. For example when the system is running under one hour only &amp;quot;x min&amp;quot; is shown, when it is running under one day &amp;quot;hour:min:sec&amp;quot; is shown and after that it is shown in format &amp;quot;x days, hour:min:sec&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Both====&lt;br /&gt;
&lt;br /&gt;
 uptime | sed -e &#039;s/.*up */uptime: /&#039; -e &#039;s/ average//&#039; -e &#039;s/  / /&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Uptime====&lt;br /&gt;
&lt;br /&gt;
 uptime | sed -e &#039;s/.*p *//&#039; -e &#039;s/, l.*//&#039; -e &#039;s/  / /&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Load====&lt;br /&gt;
&lt;br /&gt;
 uptime | sed &#039;s/.*e: //&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Boot reason===&lt;br /&gt;
&lt;br /&gt;
 cat /proc/bootreason&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Boot count===&lt;br /&gt;
&lt;br /&gt;
 cat /var/lib/dsme/boot_count&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Temperature===&lt;br /&gt;
&lt;br /&gt;
CPU&#039;s thermal sensors are not accessible, but there is one near the battery. This commands displays output of its readings, but IT IS NOT RELIABLE, because it doesn&#039;t always work. Sometimes the value returned is wrong or constant. It needs to be tested further.&lt;br /&gt;
&lt;br /&gt;
 cat /sys/devices/platform/omap34xx_temp/temp1_input | awk &#039;{ sub(/-/,&amp;quot;&amp;quot;); print $1&amp;quot; °C&amp;quot;}&#039;&lt;br /&gt;
&lt;br /&gt;
There is a working way now to read the correct temperature, but it is working only on a newer titan&#039;s kernels (normal, overclock, undervoltage). The bq27x00_battery module has to be loaded first.&lt;br /&gt;
&lt;br /&gt;
 echo `cat /sys/class/power_supply/bq27200-0/temp` °C&lt;br /&gt;
&lt;br /&gt;
with a comma : &lt;br /&gt;
&lt;br /&gt;
 echo `cat /sys/class/power_supply/bq27200-0/temp` °C | sed &#039;s/\B[0-9]\{1\}/&amp;amp;,/&#039;&lt;br /&gt;
&lt;br /&gt;
===Top processes===&lt;br /&gt;
&lt;br /&gt;
This script displays top &#039;&#039;N&#039;&#039; CPU consuming processes. It excludes top itself, which is quite processor intensive so you probably don&#039;t want this updating too often. Modify &#039;&#039;N=3&#039;&#039; at the start to display different number of processes.&lt;br /&gt;
&lt;br /&gt;
 N=3; top -bn 1 | grep -v top | head -n $(($N+4)) | tail -n $(($N+1)) | awk &#039;{OFS = &amp;quot;\t&amp;quot;} {print $7,$8}&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Random Number Generator===&lt;br /&gt;
&lt;br /&gt;
This script displays a random number between 0 and &#039;&#039;M&#039;&#039; (&#039;&#039;M&#039;&#039; included)&lt;br /&gt;
&lt;br /&gt;
 M=6; dd if=/dev/urandom bs=1 count=4 2&amp;gt;/dev/null | od -l | awk -v M=$M &#039;{M++;print $2&amp;lt;0?-$2%M:$2%M;exit}&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Ping a Host===&lt;br /&gt;
Preferred method. Install netcat from [http://wiki.maemo.org/Documentation/devtools/maemo5#Installation]&lt;br /&gt;
&lt;br /&gt;
 if (nc -zw1 192.168.2.1 80);then echo up;else echo down;fi&lt;br /&gt;
&lt;br /&gt;
Alternate method. Ping has a long timeout when down. Warning: it will block the desktop while running.&lt;br /&gt;
&lt;br /&gt;
 if (echo &#039;ping -c1 192.168.2.1&#039; | rootsh /bin/sh  2&amp;gt;&amp;amp;1 &amp;gt;/dev/null);then echo up;else echo down;fi&lt;br /&gt;
&lt;br /&gt;
==Scripts for buttons==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Make sure that update policy for button widgets is set only to &amp;quot;update when clicked&amp;quot;. &amp;quot;Update when switched to desktop&amp;quot;, &amp;quot;update interval&amp;quot; and &amp;quot;network presence&amp;quot; should be disabled to avoid automatic actions. Also keep in mind that widgets are executed at every boot so they can for example automatically disable Wi-Fi when phone boots.&lt;br /&gt;
&lt;br /&gt;
There is a bug in version 0.9 or lower which prevents you from using DCEW widgets as buttons, because they get activated (pressed) automatically all the time. You have to make sure DCEW is at least version 1.0, to check which version you have installed do this: dpkg -l desktop-cmd-exec.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Networking===&lt;br /&gt;
&lt;br /&gt;
====Connect/disconnect====&lt;br /&gt;
&lt;br /&gt;
 sh /path/conn-disconn.sh | echo &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;conn-disconn.sh&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 if [ `/sbin/route | awk &#039;/au/ {print $1}&#039;` = default ]; then&lt;br /&gt;
 dbus-send --system --dest=com.nokia.icd /com/nokia/icd_ui com.nokia.icd_ui.disconnect boolean:true&lt;br /&gt;
 else&lt;br /&gt;
 dbus-send --system --type=method_call --dest=com.nokia.icd /com/nokia/icd com.nokia.icd.connect string:&amp;quot;[ANY]&amp;quot; uint32:0&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Connect internet (show connections)====&lt;br /&gt;
&lt;br /&gt;
 dbus-send --system --type=method_call --dest=com.nokia.icd_ui /com/nokia/icd_ui com.nokia.icd_ui.show_conn_dlg boolean:false | echo &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Connect to any saved connection====&lt;br /&gt;
&lt;br /&gt;
 dbus-send --system --type=method_call --dest=com.nokia.icd /com/nokia/icd com.nokia.icd.connect string:&amp;quot;[ANY]&amp;quot; uint32:0 | echo &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Disconnect internet====&lt;br /&gt;
&lt;br /&gt;
 dbus-send --system --dest=com.nokia.icd /com/nokia/icd_ui com.nokia.icd_ui.disconnect boolean:true | echo &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Enable/disable Wi-Fi====&lt;br /&gt;
&lt;br /&gt;
 echo &amp;quot;/path/to/script/wifi.sh&amp;quot; | sudo gainroot | echo &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;wifi.sh script:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 out=`ifconfig wlan0`&lt;br /&gt;
 if [ $? -eq &amp;quot;0&amp;quot; ] ; then&lt;br /&gt;
 if [ `echo &amp;quot;$out&amp;quot; | grep -c RUNNING` -gt &amp;quot;0&amp;quot; ] ; then&lt;br /&gt;
 run-standalone.sh dbus-send --system --dest=com.nokia.icd /com/nokia/icd_ui com.nokia.icd_ui.disconnect boolean:true&lt;br /&gt;
 fi&lt;br /&gt;
 ifconfig wlan0 down&lt;br /&gt;
 rmmod wl12xx&lt;br /&gt;
 run-standalone.sh dbus-send --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteInfoprint string:&#039;Wi-Fi disabled&#039;&lt;br /&gt;
 exit 2&lt;br /&gt;
 else&lt;br /&gt;
 modprobe wl12xx&lt;br /&gt;
 wl1251-cal&lt;br /&gt;
 stop wlancond&lt;br /&gt;
 start wlancond&lt;br /&gt;
 ifconfig wlan0 up&lt;br /&gt;
 run-standalone.sh dbus-send --system --type=method_call --dest=com.nokia.icd_ui /com/nokia/icd_ui com.nokia.icd_ui.show_conn_dlg boolean:false&lt;br /&gt;
 exit 0&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
Don&#039;t forget to make it executable.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Wake On Lan====&lt;br /&gt;
 &lt;br /&gt;
 /path/to/script/wol.py | echo &amp;quot;&amp;quot;&lt;br /&gt;
wol.py script;&lt;br /&gt;
&lt;br /&gt;
 #! /usr/bin/python&lt;br /&gt;
 # Wake-On-LAN&lt;br /&gt;
 # Change ip range in the &amp;quot;s.sendto(msg&amp;quot; line &lt;br /&gt;
 # and the MAC of the pc to wakeup in the bottom line&lt;br /&gt;
 import struct, socket&lt;br /&gt;
 def WakeOnLan(ethernet_address):&lt;br /&gt;
  # Construct a six-byte hardware address&lt;br /&gt;
  addr_byte = ethernet_address.split(&#039;:&#039;)&lt;br /&gt;
  hw_addr = struct.pack(&#039;BBBBBB&#039;, int(addr_byte[0], 16),&lt;br /&gt;
    int(addr_byte[1], 16),&lt;br /&gt;
    int(addr_byte[2], 16),&lt;br /&gt;
    int(addr_byte[3], 16),&lt;br /&gt;
    int(addr_byte[4], 16),&lt;br /&gt;
    int(addr_byte[5], 16))&lt;br /&gt;
  # Build the Wake-On-LAN &amp;quot;Magic Packet&amp;quot;...&lt;br /&gt;
  msg = &#039;\xff&#039; * 6 + hw_addr * 16&lt;br /&gt;
  # ...and send it to the broadcast address using UDP&lt;br /&gt;
  s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)&lt;br /&gt;
  s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)&lt;br /&gt;
  s.sendto(msg, (&#039;192.168.1.255&#039;, 9))&lt;br /&gt;
  s.close()&lt;br /&gt;
 # Example use&lt;br /&gt;
 WakeOnLan(&#039;00:13:21:00:62:AE&#039;)&lt;br /&gt;
Don&#039;t forget to Chmod 755 wol.py&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Disconnect mobile network====&lt;br /&gt;
&lt;br /&gt;
 dbus-send --system --type=method_call --dest=com.nokia.phone.SSC /com/nokia/phone/SSC com.nokia.phone.SSC.set_radio boolean:false | echo &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Connect mobile network====&lt;br /&gt;
&lt;br /&gt;
 dbus-send --system --type=method_call --dest=com.nokia.phone.SSC /com/nokia/phone/SSC com.nokia.phone.SSC.set_radio boolean:true | echo &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Lock screen and keys===&lt;br /&gt;
&lt;br /&gt;
 dbus-send --system --type=method_call --dest=com.nokia.mce /com/nokia/mce/request com.nokia.mce.request.req_tklock_mode_change string:&amp;quot;locked&amp;quot; | echo &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Radio mode===&lt;br /&gt;
&lt;br /&gt;
====2G/3G====&lt;br /&gt;
&lt;br /&gt;
 sh /path/to/script/2g3g.sh | echo &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;2g3g.sh script:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 if [ `dbus-send --system --type=method_call --print-reply --dest=com.nokia.phone.net /com/nokia/phone/net Phone.Net.get_selected_radio_access_technology | awk &#039;/b/ {print $2}&#039;` -eq 1 ]; then&lt;br /&gt;
 dbus-send --system --type=method_call --dest=com.nokia.phone.net /com/nokia/phone/net Phone.Net.set_selected_radio_access_technology byte:2&lt;br /&gt;
 else&lt;br /&gt;
 dbus-send --system --type=method_call --dest=com.nokia.phone.net /com/nokia/phone/net Phone.Net.set_selected_radio_access_technology byte:1&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
When 3G or Dual mode is active, the script will switch to 2G. And when 2G is active, it will switch to 3G.&lt;br /&gt;
&lt;br /&gt;
Don&#039;t forget to make the script executable.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====2G====&lt;br /&gt;
&lt;br /&gt;
 dbus-send --system --type=method_call --dest=com.nokia.phone.net /com/nokia/phone/net Phone.Net.set_selected_radio_access_technology byte:1 | echo &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====3G====&lt;br /&gt;
&lt;br /&gt;
 dbus-send --system --type=method_call --dest=com.nokia.phone.net /com/nokia/phone/net Phone.Net.set_selected_radio_access_technology byte:2 | echo &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Dual====&lt;br /&gt;
&lt;br /&gt;
 dbus-send --system --type=method_call --dest=com.nokia.phone.net /com/nokia/phone/net Phone.Net.set_selected_radio_access_technology byte:0 | echo &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Bluetooth===&lt;br /&gt;
&lt;br /&gt;
Good to see a tealnt at work. I can&#039;t match that.&lt;br /&gt;
&lt;br /&gt;
====Disable====&lt;br /&gt;
&lt;br /&gt;
 dbus-send --system --type=method_call --dest=org.bluez $(dbus-send --system --print-reply --dest=org.bluez / org.bluez.Manager.ListAdapters | awk -F &amp;quot;\&amp;quot;&amp;quot; &#039;/at/ {print $2}&#039;) org.bluez.Adapter.SetProperty string:Powered variant:boolean:false | echo &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===Profiles===&lt;br /&gt;
&lt;br /&gt;
====General====&lt;br /&gt;
&lt;br /&gt;
 dbus-send --type=method_call --dest=com.nokia.profiled /com/nokia/profiled com.nokia.profiled.set_profile string:&amp;quot;general&amp;quot; | echo &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Silent====&lt;br /&gt;
&lt;br /&gt;
 dbus-send --type=method_call --dest=com.nokia.profiled /com/nokia/profiled com.nokia.profiled.set_profile string:&amp;quot;silent&amp;quot; | echo&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Toggle vibrating alert====&lt;br /&gt;
&lt;br /&gt;
There are far more things you can do with your profile. Please have a look at the [[Phone_control#Get_all_profile_Values|profile values at the phone control page]]. This example disables vibrating alert for the active profile.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 # Which profile is active?&lt;br /&gt;
 if \&lt;br /&gt;
 dbus-send --print-reply --type=method_call \&lt;br /&gt;
 --dest=com.nokia.profiled /com/nokia/profiled \&lt;br /&gt;
 com.nokia.profiled.get_profile | grep -q general&lt;br /&gt;
 then&lt;br /&gt;
 	# general profile is active&lt;br /&gt;
 	dbus-send --type=method_call \&lt;br /&gt;
 	--dest=com.nokia.profiled /com/nokia/profiled \&lt;br /&gt;
 	com.nokia.profiled.set_value string:&amp;quot;general&amp;quot; \&lt;br /&gt;
 	string:&amp;quot;vibrating.alert.enabled&amp;quot; string:&amp;quot;Off&amp;quot;&lt;br /&gt;
 else&lt;br /&gt;
 	# silent profile is active&lt;br /&gt;
 	dbus-send --type=method_call \&lt;br /&gt;
 	--dest=com.nokia.profiled /com/nokia/profiled \&lt;br /&gt;
 	com.nokia.profiled.set_value string:&amp;quot;silent&amp;quot; \&lt;br /&gt;
 	string:&amp;quot;vibrating.alert.enabled&amp;quot; string:&amp;quot;Off&amp;quot;&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
You get the opposite behaviour (enable vibrating alert) simply by replacing &amp;quot;Off&amp;quot; two times by &amp;quot;On&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
===Lock (secure) the device===&lt;br /&gt;
&lt;br /&gt;
 dbus-send --system --type=method_call --dest=com.nokia.system_ui /com/nokia/system_ui/request com.nokia.system_ui.request.devlock_open string:&amp;quot;com.nokia.mce&amp;quot; string:&amp;quot;/com/nokia/mce/request&amp;quot; string:&amp;quot;com.nokia.mce.request&amp;quot; string:&amp;quot;devlock_callback&amp;quot; uint32:&#039;3&#039; | echo &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Update e-mail===&lt;br /&gt;
&lt;br /&gt;
 sh /path/to/script/email.sh | echo &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;email.sh script:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The script connects to the internet and refreshes e-mail. Keep in mind that Modest e-mail client which N900 uses is very slow in this aspect and send and recive can take up to minute and a half. Make it executable.&lt;br /&gt;
&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 run-standalone.sh dbus-send --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteInfoprint string:&amp;quot;Updating e-mail...&amp;quot;&lt;br /&gt;
 run-standalone.sh dbus-send --system --type=method_call --dest=com.nokia.icd /com/nokia/icd com.nokia.icd.connect string:&amp;quot;[ANY]&amp;quot; uint32:0&lt;br /&gt;
 sleep 10&lt;br /&gt;
 run-standalone.sh dbus-send --type=method_call --dest=com.nokia.modest /com/nokia/modest com.nokia.modest.SendReceive&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Set maximum CPU frequency===&lt;br /&gt;
&lt;br /&gt;
 echo &amp;quot;echo 600000 &amp;gt; /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq&amp;quot; | sudo gainroot | echo &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Replace 600000 with desired maximum frequency. This is usable with the new overclocking kernels if you wish to manually change the maximum frequency to which processor can scale. Pay attention to the two exceptions in titan&#039;s kernels (124999 and 599000). The list of available frequencies on your device/kernel can be obtained with command:&lt;br /&gt;
&lt;br /&gt;
 awk &#039;{print $1/1000&amp;quot; MHz&amp;quot;}&#039; /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Reboot===&lt;br /&gt;
&lt;br /&gt;
 echo &amp;quot;reboot&amp;quot; | sudo gainroot | echo &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Warning: Consult forums before you try this, because currently DCEW executes some (all?) commands at startup. This will be optional in next version. Making a reboot button on current DCEW version could result in endless reboot loop.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===FM transmitter===&lt;br /&gt;
&lt;br /&gt;
====Enable/disable====&lt;br /&gt;
&lt;br /&gt;
 /usr/bin/fmtx_client -p$(if [ $(cut -d. -f1 /proc/uptime ) -lt 100 ]; then echo 0; else /usr/bin/fmtx_client | /bin/grep -q &#039;^state=enabled&#039; ; echo $? ; fi) | /usr/bin/awk -F &amp;quot;=&amp;quot; &#039;($1==&amp;quot;state&amp;quot;) {print $2}&#039;&lt;br /&gt;
&lt;br /&gt;
Note: when you reboot the device, this script waits 100 seconds before you can turn the transmitter on/off again.&lt;br /&gt;
&lt;br /&gt;
====Increase power====&lt;br /&gt;
&lt;br /&gt;
 echo &amp;quot;echo 118 &amp;gt; /sys/class/i2c-adapter/i2c-2/2-0063/power_level&amp;quot; | sudo gainroot | echo &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===DBUS call to start browser===&lt;br /&gt;
&lt;br /&gt;
 /usr/bin/browser_dbuscmd.sh load_url http://www.bbc.co.uk/iplayer/console/bbc_radio_fourfm&lt;br /&gt;
[[Category:Software]]&lt;br /&gt;
[[Category:Power users]]&lt;br /&gt;
&lt;br /&gt;
===Display a Conboy Note===&lt;br /&gt;
 python /home/user/conboy_note_to_text.py print noteid&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;conboy_note_to_text.py&#039;&#039;&#039;&lt;br /&gt;
Make sure to make this python script executable (chmod 755 /path/to/conboy_note_to_text.py). To list all notes with their title and id in xterm, just use the following commands: python /home/user/conboy_note_to_text.py list&lt;br /&gt;
&lt;br /&gt;
Source : http://khertan.net/articles/maemo/conboy_note_to_text&lt;br /&gt;
&lt;br /&gt;
Direct Script Link : http://khertan.net/_export/code/articles/maemo/conboy_note_to_text?codeblock=0&lt;br /&gt;
&lt;br /&gt;
 #!/usr/lib/python2.5&lt;br /&gt;
 &lt;br /&gt;
 from xml.dom import minidom&lt;br /&gt;
 import os.path&lt;br /&gt;
 import glob&lt;br /&gt;
 import sys&lt;br /&gt;
 import re&lt;br /&gt;
 from xml.sax.handler import ContentHandler&lt;br /&gt;
 import xml.sax&lt;br /&gt;
 &lt;br /&gt;
 class NoteList:&lt;br /&gt;
    def __init__(self,path):&lt;br /&gt;
        self.path = path&lt;br /&gt;
        self.noteList = {}&lt;br /&gt;
        for infile in glob.glob( os.path.join(self.path, &#039;*.note&#039;) ):&lt;br /&gt;
          note = Reader(os.path.basename(infile)[:-5])&lt;br /&gt;
          if note.title != None:&lt;br /&gt;
              self.noteList[note.title]=note.note_id&lt;br /&gt;
 &lt;br /&gt;
    def get_note_id_by_title(self,title):&lt;br /&gt;
        try:&lt;br /&gt;
            return self.noteList[title]&lt;br /&gt;
        except:&lt;br /&gt;
            return None&lt;br /&gt;
 &lt;br /&gt;
 class textHandler(ContentHandler):&lt;br /&gt;
    def __init__(self):&lt;br /&gt;
      ContentHandler.__init__(self)&lt;br /&gt;
      self.content = &amp;quot;&amp;quot;&lt;br /&gt;
      self.title = &amp;quot;&amp;quot;&lt;br /&gt;
      self.selector = None&lt;br /&gt;
 &lt;br /&gt;
    def startElement(self, element,attributes):&lt;br /&gt;
        if (element == &#039;note-content&#039;) and (self.selector == None):&lt;br /&gt;
            self.selector = element&lt;br /&gt;
        elif (element == &#039;title&#039;) and (self.selector == None):&lt;br /&gt;
            self.selector = element&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
    def endElement(self, element):&lt;br /&gt;
        if (element == self.selector):&lt;br /&gt;
            self.selector = None&lt;br /&gt;
 &lt;br /&gt;
    def characters(self, ch):&lt;br /&gt;
        if self.selector == &#039;note-content&#039;:&lt;br /&gt;
            self.content = self.content + unicode(ch)&lt;br /&gt;
        elif self.selector == &#039;title&#039;:&lt;br /&gt;
            self.title = self.title + unicode(ch)&lt;br /&gt;
 &lt;br /&gt;
 class Reader:&lt;br /&gt;
    def __init__(self,note_id):&lt;br /&gt;
        self.note_id = note_id&lt;br /&gt;
        self.content = None&lt;br /&gt;
        self.title = None&lt;br /&gt;
 &lt;br /&gt;
        try:&lt;br /&gt;
            parser = xml.sax.make_parser()&lt;br /&gt;
            handler = textHandler()&lt;br /&gt;
            parser.setContentHandler(handler)&lt;br /&gt;
              parser.parse(os.path.join(os.path.expanduser(&amp;quot;~&amp;quot;),&#039;.conboy&#039;,self.note_id+&#039;.note&#039;))&lt;br /&gt;
            self.content = handler.content&lt;br /&gt;
            self.title = handler.title &lt;br /&gt;
        except StandardError,e:&lt;br /&gt;
            print e&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 if __name__ == &amp;quot;__main__&amp;quot;:&lt;br /&gt;
    try:&lt;br /&gt;
        if (sys.argv[1]==&#039;print&#039;):&lt;br /&gt;
            print Reader(unicode(sys.argv[2])).content&lt;br /&gt;
        elif (sys.argv[1]==&#039;list&#039;):&lt;br /&gt;
            nlist = NoteList(&#039;/home/user/.conboy/&#039;).noteList&lt;br /&gt;
            for key in nlist.keys():&lt;br /&gt;
                print key, &#039; : &#039;, nlist[key]&lt;br /&gt;
        elif (sys.argv[1]==&#039;search&#039;):&lt;br /&gt;
            nlist = NoteList(&#039;/home/user/.conboy/&#039;)&lt;br /&gt;
            print nlist.get_note_id_by_title(sys.argv[2])&lt;br /&gt;
        else:&lt;br /&gt;
            raise&lt;br /&gt;
    except StandardError,e:&lt;br /&gt;
            print &amp;quot;&amp;quot;&amp;quot;Usage : python conboy_note_reader.py option [note_id or note title]&lt;br /&gt;
            Option : &lt;br /&gt;
                - list : list all note by title with id&lt;br /&gt;
                - print : print content of note with the given id&lt;br /&gt;
                - search : print id of the given title&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
            print e&lt;/div&gt;</summary>
		<author><name>75.119.206.105</name></author>
	</entry>
</feed>