<?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=213.240.181.249</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=213.240.181.249"/>
	<link rel="alternate" type="text/html" href="https://maemo.octonezd.me/index.php/Special:Contributions/213.240.181.249"/>
	<updated>2026-04-22T01:51:10Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://maemo.octonezd.me/index.php?title=Phone_control&amp;diff=31764</id>
		<title>Phone control</title>
		<link rel="alternate" type="text/html" href="https://maemo.octonezd.me/index.php?title=Phone_control&amp;diff=31764"/>
		<updated>2011-09-12T04:43:27Z</updated>

		<summary type="html">&lt;p&gt;213.240.181.249: /* Securing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ambox&lt;br /&gt;
| type = notice&lt;br /&gt;
| image= &lt;br /&gt;
| text = &#039;&#039;&#039;This page is about controlling your Nokia device.  For historical reasons this page is called &#039;&#039;&#039;phone&#039;&#039;&#039; control even though it really covers more than just the phone functions.&#039;&#039;&#039;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Recommended phone usage}}&lt;br /&gt;
&lt;br /&gt;
==D-Bus==&lt;br /&gt;
&lt;br /&gt;
These D-Bus commands can be run from terminal or as shell scripts. Useful for scheduling events with [[fcron]], executing from [[Desktop Command Execution Widget scripts|Desktop Command Execution Widget]] or [[Queen BeeCon Widget]], startup events, install scripts, etc. They should be run as:&lt;br /&gt;
&lt;br /&gt;
 run-standalone.sh SCRIPT.sh&lt;br /&gt;
 run-standalone.sh dbus-send COMMAND&lt;br /&gt;
&lt;br /&gt;
This is important to set up the environment correctly otherwise they may barf. If run as user &amp;quot;user&amp;quot; this is not needed.&lt;br /&gt;
&lt;br /&gt;
Also note that most commands don&#039;t need &amp;quot;--print-reply&amp;quot; option. Those that don&#039;t need it should be &#039;&#039;&#039;tested without it&#039;&#039;&#039; and this page should be edited.&lt;br /&gt;
&lt;br /&gt;
===Phone===&lt;br /&gt;
&lt;br /&gt;
====Open Phone application====&lt;br /&gt;
&lt;br /&gt;
 dbus-send --type=method_call --dest=com.nokia.HildonDesktop.AppMgr /com/nokia/HildonDesktop/AppMgr com.nokia.HildonDesktop.AppMgr.LaunchApplication string:&amp;quot;rtcom-call-ui&amp;quot;&lt;br /&gt;
&lt;br /&gt;
====Make a phone call====&lt;br /&gt;
&lt;br /&gt;
 dbus-send --system --type=method_call --print-reply --dest=com.nokia.csd.Call /com/nokia/csd/call com.nokia.csd.Call.CreateWith string:&amp;quot;$NUMBER&amp;quot; uint32:0&lt;br /&gt;
&lt;br /&gt;
Change $NUMBER to phone number you want to call.&lt;br /&gt;
&lt;br /&gt;
====End current phone call====&lt;br /&gt;
&lt;br /&gt;
 dbus-send --system --print-reply --dest=com.nokia.csd.Call /com/nokia/csd/call com.nokia.csd.Call.Release&lt;br /&gt;
&lt;br /&gt;
This will release/end/hangup/reject the current call (or possibly all calls if more then one call is active) or do nothing if no calls are active.&lt;br /&gt;
&lt;br /&gt;
====Answer current phone call====&lt;br /&gt;
&lt;br /&gt;
 dbus-send --system --print-reply --dest=com.nokia.csd.Call /com/nokia/csd/call/1 com.nokia.csd.Call.Instance.Answer&lt;br /&gt;
&lt;br /&gt;
This will answer/pickup the current (first) call. &lt;br /&gt;
&lt;br /&gt;
If you answer the call immediately as you receive the Call Coming D-Bus message the phone seems to be in a specific call state where answering yields a &amp;lt;code&amp;gt;com.nokia.csd.Call.Error.NotAllowed&amp;lt;/code&amp;gt; exception.&lt;br /&gt;
&lt;br /&gt;
You need to answer the call after a delay of e.g. 1 s.&lt;br /&gt;
&lt;br /&gt;
Another (probably better) approach is to register to the CallStatus D-Bus message (&amp;lt;code&amp;gt;com.nokia.csd.Call&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;/com/nokia/csd/call/1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;com.nokia.csd.Call.Instance.CallStatus&amp;lt;/code&amp;gt;) and wait for a call status &amp;gt;= 2 (=&amp;lt;code&amp;gt;CSD_CALL_STATUS_COMING&amp;lt;/code&amp;gt;) after the &amp;quot;Coming&amp;quot; message.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Set Call forwarding====&lt;br /&gt;
&lt;br /&gt;
call forward unanswered calls after 20 sec to 0731234567&lt;br /&gt;
 dbus-send --system --type=method_call --print-reply --dest=com.nokia.csd.SS /com/nokia/csd/ss com.nokia.csd.SS.DivertActivate uint32:5 string:&amp;quot;0731234567&amp;quot; uint32:20&lt;br /&gt;
&lt;br /&gt;
====Get [[:wikipedia:International_Mobile_Equipment_Identity|IMEI]]====&lt;br /&gt;
&lt;br /&gt;
 dbus-send --system --type=method_call --print-reply --dest=com.nokia.phone.SIM /com/nokia/phone/SIM/security Phone.Sim.Security.get_imei|awk -F &amp;quot;\&amp;quot;&amp;quot; &#039;/g/ {print $2}&#039;&lt;br /&gt;
&lt;br /&gt;
====Get [[:wikipedia:International_Mobile_Subscriber_Identity|IMSI]]====&lt;br /&gt;
&lt;br /&gt;
 dbus-send --system --type=method_call --print-reply --dest=com.nokia.phone.SIM /com/nokia/phone/SIM Phone.Sim.get_imsi|awk -F &amp;quot;\&amp;quot;&amp;quot; &#039;/g/ {print $2}&#039;&lt;br /&gt;
&lt;br /&gt;
====Get SIM status====&lt;br /&gt;
&lt;br /&gt;
 dbus-send --system --print-reply --dest=com.nokia.phone.SIM /com/nokia/phone/SIM Phone.Sim.get_sim_status&lt;br /&gt;
&lt;br /&gt;
====Get cellular signal 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&lt;br /&gt;
&lt;br /&gt;
First line is percentage, second is dBm, third unknown.&lt;br /&gt;
&lt;br /&gt;
====Get cellular registration status====&lt;br /&gt;
&lt;br /&gt;
 dbus-send --system --print-reply --dest=com.nokia.phone.net /com/nokia/phone/net Phone.Net.get_registration_status&lt;br /&gt;
&lt;br /&gt;
====Turn loudspeaker on====&lt;br /&gt;
&lt;br /&gt;
 dbus-send --type=method_call --dest=com.nokia.osso_hp_ls_controller /com/nokia/osso_hp_ls_controller com.nokia.osso_hp_ls_controller.loudspeaker.force_loudspeaker_on&lt;br /&gt;
&lt;br /&gt;
(These loudspeaker ones don&#039;t work on my N900. If I add --print-reply I get &amp;quot;Error org.freedesktop.DBus.Error.ServiceUnknown: The name com.nokia.osso_hp_ls_controller was not provided by any .service files&amp;quot;.)&lt;br /&gt;
&lt;br /&gt;
====Turn loudspeaker off====&lt;br /&gt;
&lt;br /&gt;
 dbus-send --type=method_call --dest=com.nokia.osso_hp_ls_controller /com/nokia/osso_hp_ls_controller com.nokia.osso_hp_ls_controller.loudspeaker.force_loudspeaker_off&lt;br /&gt;
&lt;br /&gt;
====Turn loudspeaker on (N900)====&lt;br /&gt;
&lt;br /&gt;
 dbus-send --type=method_call --dest=org.maemo.Playback.Manager /org/maemo/Playback/Manager org.maemo.Playback.Manager.RequestPrivacyOverride boolean:true&lt;br /&gt;
&lt;br /&gt;
====Turn loudspeaker off (N900)====&lt;br /&gt;
 dbus-send --type=method_call --dest=org.maemo.Playback.Manager /org/maemo/Playback/Manager org.maemo.Playback.Manager.RequestPrivacyOverride boolean:false&lt;br /&gt;
&lt;br /&gt;
====Turn mute on (N900)====&lt;br /&gt;
&lt;br /&gt;
 dbus-send --type=method_call --dest=org.maemo.Playback.Manager /org/maemo/Playback/Manager org.maemo.Playback.Manager.RequestMute boolean:true&lt;br /&gt;
&lt;br /&gt;
====Turn mute off (N900)====&lt;br /&gt;
 dbus-send --type=method_call --dest=org.maemo.Playback.Manager /org/maemo/Playback/Manager org.maemo.Playback.Manager.RequestMute boolean:false&lt;br /&gt;
&lt;br /&gt;
====Turn bluetooth override on (N900)====&lt;br /&gt;
&lt;br /&gt;
 dbus-send --type=method_call --dest=org.maemo.Playback.Manager /org/maemo/Playback/Manager org.maemo.Playback.Manager.RequestBluetoothOverride boolean:true&lt;br /&gt;
&lt;br /&gt;
====Turn bluetooth override off (N900)====&lt;br /&gt;
 dbus-send --type=method_call --dest=org.maemo.Playback.Manager /org/maemo/Playback/Manager org.maemo.Playback.Manager.RequestBluetoothOverride boolean:false&lt;br /&gt;
&lt;br /&gt;
====Start vibrating====&lt;br /&gt;
&lt;br /&gt;
 dbus-send --system --print-reply --dest=com.nokia.mce /com/nokia/mce/request com.nokia.mce.request.req_vibrator_pattern_activate string:PatternIncomingCall&lt;br /&gt;
&lt;br /&gt;
====Stop vibrating====&lt;br /&gt;
&lt;br /&gt;
 dbus-send --system --print-reply --dest=com.nokia.mce /com/nokia/mce/request com.nokia.mce.request.req_vibrator_pattern_deactivate string:PatternIncomingCall&lt;br /&gt;
&lt;br /&gt;
===Profiles===&lt;br /&gt;
&lt;br /&gt;
====Set 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;&lt;br /&gt;
&lt;br /&gt;
====Set 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;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Query current profile====&lt;br /&gt;
&lt;br /&gt;
 dbus-send --type=method_call --print-reply --dest=com.nokia.profiled /com/nokia/profiled com.nokia.profiled.get_profile&lt;br /&gt;
&lt;br /&gt;
====List all profiles====&lt;br /&gt;
&lt;br /&gt;
 dbus-send --type=method_call --print-reply --dest=com.nokia.profiled /com/nokia/profiled com.nokia.profiled.get_profiles|awk -F &amp;quot;\&amp;quot;&amp;quot; &#039;/g/ {print $2}&#039;&lt;br /&gt;
&lt;br /&gt;
====Get all profile Values====&lt;br /&gt;
&lt;br /&gt;
You can modify any profile value, eg. clock alarm enabled, im alert volume, keypad sound level, touchscreen sound level, ... To find out which keys exist, to what value they are set and what values can be given you can use the following command. (For the profile &amp;quot;silent&amp;quot; just put &amp;quot;silent&amp;quot; at the end instead of &amp;quot;general&amp;quot;.)&lt;br /&gt;
&lt;br /&gt;
 dbus-send --type=method_call --print-reply --dest=com.nokia.profiled /com/nokia/profiled com.nokia.profiled.get_values string:&amp;quot;general&amp;quot;&lt;br /&gt;
&lt;br /&gt;
The returned value is an array of struct. Each struct has 3 strings: key, value, type. Type can be eg. &amp;quot;INTEGER 0-2&amp;quot; saying that the values 0, 1 and 2 are correct values for this key.&lt;br /&gt;
&lt;br /&gt;
====Set a profile value====&lt;br /&gt;
&lt;br /&gt;
To modify the above mentioned profile values you need this method. The method takes three parameters, all strings: profile, key and value. Profile can be &amp;quot;general&amp;quot; or &amp;quot;silent&amp;quot;, key is one of the keys from the above (get all profile values), value can be set to anything allowed by &amp;quot;type&amp;quot; from the above method.&lt;br /&gt;
&lt;br /&gt;
To enable vibrating alert for the profile &amp;quot;general&amp;quot; your script would look like this:&lt;br /&gt;
&lt;br /&gt;
 dbus-send --type=method_call --dest=com.nokia.profiled /com/nokia/profiled com.nokia.profiled.set_value string:&amp;quot;general&amp;quot; string:&amp;quot;vibrating.alert.enabled&amp;quot; string:&amp;quot;On&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===LED===&lt;br /&gt;
&lt;br /&gt;
====Activate LEDs====&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_led_pattern_activate string:&amp;quot;PatternCommunicationIM&amp;quot;&lt;br /&gt;
&lt;br /&gt;
====Deactivate LEDs====&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_led_pattern_deactivate string:&amp;quot;PatternCommunicationIM&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===Messaging===&lt;br /&gt;
&lt;br /&gt;
====New e-mail====&lt;br /&gt;
&lt;br /&gt;
 dbus-send --type=method_call --dest=com.nokia.modest /com/nokia/modest com.nokia.modest.MailTo string:&amp;quot;mailto:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
====Send and receive e-mail====&lt;br /&gt;
&lt;br /&gt;
It works, but it takes up to 2 minutes for modest to start refreshing and after that it depends on the speed of the connection how fast it is going to be completed, usually up to 5 seconds, 2G can be a bit slower.&lt;br /&gt;
&lt;br /&gt;
 dbus-send --type=method_call --dest=com.nokia.modest /com/nokia/modest com.nokia.modest.SendReceive&lt;br /&gt;
&lt;br /&gt;
====Set presence====&lt;br /&gt;
&lt;br /&gt;
 dbus-send --type=method_call --print-reply --dest=org.freedesktop.Telepathy.MissionControl /org/freedesktop/Telepathy/MissionControl org.freedesktop.Telepathy.MissionControl.SetPresence uint32:2 string:&amp;quot;I&#039;m here&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Note: This method does not work in Maemo 5. Workaround: http://talk.maemo.org/showthread.php?t=55686&lt;br /&gt;
&lt;br /&gt;
====Change peak_schedule settings====&lt;br /&gt;
&lt;br /&gt;
Check:&lt;br /&gt;
 run-standalone.sh gconftool-2 -R /apps/activesync&lt;br /&gt;
&lt;br /&gt;
Set (check if yours is named ActiveSyncAccount1):&lt;br /&gt;
 run-standalone.sh gconftool-2 --set /apps/activesync/ActiveSyncAccount1/schedule/peak_schedule --type=int 15&lt;br /&gt;
Where the last number is one of the following (as standard in GUI):&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;0&#039;&#039;&#039; = Always on&lt;br /&gt;
* &#039;&#039;&#039;-1&#039;&#039;&#039; = Manual&lt;br /&gt;
* &#039;&#039;&#039;15&#039;&#039;&#039; = Every 15 minutes&lt;br /&gt;
* &#039;&#039;&#039;30&#039;&#039;&#039; = Every 30 minutes&lt;br /&gt;
* &#039;&#039;&#039;60&#039;&#039;&#039; = Every hour&lt;br /&gt;
* &#039;&#039;&#039;240&#039;&#039;&#039; = Every 4 hours&lt;br /&gt;
* &#039;&#039;&#039;720&#039;&#039;&#039; = Every 12 hours&lt;br /&gt;
&lt;br /&gt;
===Media player===&lt;br /&gt;
&lt;br /&gt;
====Open file in media player====&lt;br /&gt;
&lt;br /&gt;
 dbus-send --print-reply --dest=com.nokia.mediaplayer /com/nokia/mediaplayer com.nokia.mediaplayer.mime_open string:&amp;quot;file:///$1&amp;quot;&lt;br /&gt;
&lt;br /&gt;
====Pause what&#039;s currently playing====&lt;br /&gt;
&lt;br /&gt;
 dbus-send --dest=com.nokia.mafw.renderer.Mafw-Gst-Renderer-Plugin.gstrenderer /com/nokia/mafw/renderer/gstrenderer com.nokia.mafw.renderer.pause&lt;br /&gt;
&lt;br /&gt;
====Stop what&#039;s currently playing====&lt;br /&gt;
&lt;br /&gt;
 dbus-send --dest=com.nokia.mafw.renderer.Mafw-Gst-Renderer-Plugin.gstrenderer /com/nokia/mafw/renderer/gstrenderer com.nokia.mafw.renderer.stop&lt;br /&gt;
&lt;br /&gt;
====Play what&#039;s currently selected====&lt;br /&gt;
&lt;br /&gt;
 dbus-send --dest=com.nokia.mafw.renderer.Mafw-Gst-Renderer-Plugin.gstrenderer /com/nokia/mafw/renderer/gstrenderer com.nokia.mafw.renderer.play&lt;br /&gt;
&lt;br /&gt;
====Unpause what&#039;s currently selected====&lt;br /&gt;
&lt;br /&gt;
 dbus-send --dest=com.nokia.mafw.renderer.Mafw-Gst-Renderer-Plugin.gstrenderer /com/nokia/mafw/renderer/gstrenderer com.nokia.mafw.renderer.resume&lt;br /&gt;
&lt;br /&gt;
====Play next mediafile====&lt;br /&gt;
&lt;br /&gt;
 dbus-send --dest=com.nokia.mafw.renderer.Mafw-Gst-Renderer-Plugin.gstrenderer /com/nokia/mafw/renderer/gstrenderer com.nokia.mafw.renderer.next&lt;br /&gt;
&lt;br /&gt;
====Play previous mediafile====&lt;br /&gt;
&lt;br /&gt;
 dbus-send --dest=com.nokia.mafw.renderer.Mafw-Gst-Renderer-Plugin.gstrenderer /com/nokia/mafw/renderer/gstrenderer com.nokia.mafw.renderer.previous&lt;br /&gt;
&lt;br /&gt;
===Notifications===&lt;br /&gt;
&lt;br /&gt;
====Send notification (orange one line popup)====&lt;br /&gt;
&lt;br /&gt;
 dbus-send --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteInfoprint string:&amp;quot;NOTIFICATION&amp;quot;&lt;br /&gt;
&lt;br /&gt;
====Send dialog notification (orange multi line popup requiring user interaction)====&lt;br /&gt;
&lt;br /&gt;
 dbus-send --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteDialog string:&amp;quot;QUESTION?&amp;quot; uint32:0 string:&amp;quot;OK&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Not sure what string &amp;quot;OK&amp;quot; does, but it is needed and can be anything.&lt;br /&gt;
&lt;br /&gt;
===Securing===&lt;br /&gt;
&lt;br /&gt;
====Lock====&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;&lt;br /&gt;
&lt;br /&gt;
====Unlock====&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_close 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;0&#039;&lt;br /&gt;
&lt;br /&gt;
====Query Devlock State====&lt;br /&gt;
&lt;br /&gt;
  dbus-send --system --type=method_call --dest=&amp;quot;com.nokia.mce&amp;quot; --print-reply &amp;quot;/com/nokia/mce/request&amp;quot; com.nokia.mce.request.get_devicelock_mode |awk -F &amp;quot;\&amp;quot;&amp;quot; &#039;/g/ {print $2}&#039;&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;&lt;br /&gt;
&lt;br /&gt;
====Unlock screen and keys====&lt;br /&gt;
&lt;br /&gt;
This command will unlock and illuminate the screen (useful when accessing the phone externally through [http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html PuTTY])&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;unlocked&amp;quot;&lt;br /&gt;
&lt;br /&gt;
====Query lock state of screen and keys====&lt;br /&gt;
&lt;br /&gt;
Will return &#039;&#039;locked&#039;&#039; or &#039;&#039;unlocked&#039;&#039; depending on lock state&lt;br /&gt;
 dbus-send --system --type=method_call --dest=&amp;quot;com.nokia.mce&amp;quot; --print-reply &amp;quot;/com/nokia/mce/request&amp;quot; com.nokia.mce.request.get_tklock_mode|awk -F &amp;quot;\&amp;quot;&amp;quot; &#039;/g/ {print $2}&#039;&lt;br /&gt;
&lt;br /&gt;
===Networking===&lt;br /&gt;
&lt;br /&gt;
====Enable ICD log====&lt;br /&gt;
There are two methods to enable ICD logs&lt;br /&gt;
&lt;br /&gt;
1. Print to the syslog:&lt;br /&gt;
   (1)Use the following cmd &lt;br /&gt;
   (2)$ syslogd&lt;br /&gt;
   (3)$ icd2 –l0&lt;br /&gt;
   (4)The log will print to the /var/log/syslog&lt;br /&gt;
2. Print to the standard output  &lt;br /&gt;
   (1)Get the source code of icd2&lt;br /&gt;
   (2)Add the begging of source code of “support/osso-log.h” &amp;quot;#define OSSOLOG_STDOUT&amp;quot;&lt;br /&gt;
   (3)$ icd2 –l0&lt;br /&gt;
   (4)The log will print to the standard output&lt;br /&gt;
&lt;br /&gt;
====Connect to specific 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;IAP_ID&amp;quot; uint32:0&lt;br /&gt;
&lt;br /&gt;
IAP_ID is internet access point identifier and can be obtained with the following command:&lt;br /&gt;
&lt;br /&gt;
 gconftool -R /system/osso/connectivity/IAP&lt;br /&gt;
&lt;br /&gt;
Find lines which matches /system/osso/connectivity/IAP/&amp;lt;IAP_ID&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For GPRS connections replace &amp;quot;@32@&amp;quot; with a space in IAP_ID string.&lt;br /&gt;
&lt;br /&gt;
Keep in mind that phone has to be disconnected in order to connect via this call.&lt;br /&gt;
If not, an error message will occur if you add --print-reply to the dbus-send command.&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&lt;br /&gt;
&lt;br /&gt;
====Disconnect internet====&lt;br /&gt;
&lt;br /&gt;
=====ICD2=====&lt;br /&gt;
&lt;br /&gt;
 dbus-send --print-reply --system --dest=com.nokia.icd2 /com/nokia/icd2 com.nokia.icd2.disconnect_req uint32:0x8000&lt;br /&gt;
&lt;br /&gt;
=====ICD=====&lt;br /&gt;
&lt;br /&gt;
 dbus-send --system --dest=com.nokia.icd /com/nokia/icd_ui com.nokia.icd_ui.disconnect boolean:true&lt;br /&gt;
&lt;br /&gt;
On [[Maemo 5/PR1.2|PR1.2]] :&lt;br /&gt;
Error org.freedesktop.DBus.Error.UnknownMethod: Method &amp;quot;disconnect&amp;quot; with signature &amp;quot;b&amp;quot; on interface &amp;quot;com.nokia.icd_ui&amp;quot; doesn&#039;t exist&lt;br /&gt;
&lt;br /&gt;
====Connect (show change connection UI)====&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&lt;br /&gt;
&lt;br /&gt;
If &amp;quot;boolean:true&amp;quot; at the end, one-line notification saying &amp;quot;No saved connections available&amp;quot; appears. Maybe affects more than that? Most likely, boolean:true leads to using saved connections if there are any, and boolean:false forces to display the connection dialog.&lt;br /&gt;
&lt;br /&gt;
====Enable cellular radio====&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&lt;br /&gt;
&lt;br /&gt;
====Disable cellular radio====&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&lt;br /&gt;
&lt;br /&gt;
===Radio mode===&lt;br /&gt;
&lt;br /&gt;
====Current Mode====&lt;br /&gt;
&lt;br /&gt;
 dbus-send --system --print-reply --dest=com.nokia.phone.net /com/nokia/phone/net Phone.Net.get_radio_access_technology&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&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&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&lt;br /&gt;
&lt;br /&gt;
===Bluetooth===&lt;br /&gt;
&lt;br /&gt;
====Identify adapter path====&lt;br /&gt;
&lt;br /&gt;
You need to know adapter path in order to send D-Bus call to the right place. You can get it with entering this command into the terminal:&lt;br /&gt;
&lt;br /&gt;
 dbus-send --system --print-reply --dest=org.bluez / org.bluez.Manager.ListAdapters | awk -F&#039;&amp;quot;&#039; &#039;/at/ {print $2}&#039;&lt;br /&gt;
or&lt;br /&gt;
 dbus-send --system --print-reply --dest=org.bluez / org.bluez.Manager.DefaultAdapter | awk -F&#039;&amp;quot;&#039; &#039;/at/ {print $2}&#039;&lt;br /&gt;
&lt;br /&gt;
====Identify Properties====&lt;br /&gt;
&lt;br /&gt;
 dbus-send --system --print-reply --type=method_call --dest=org.bluez $(dbus-send --system --print-reply --dest=org.bluez / org.bluez.Manager.DefaultAdapter | awk -F&#039;&amp;quot;&#039; &#039;/at/ {print $2}&#039;) org.bluez.Adapter.GetProperties&lt;br /&gt;
&lt;br /&gt;
====Enable====&lt;br /&gt;
&lt;br /&gt;
Using the adapter path value returned with first command, for example &#039;&#039;/org/bluez/906/hci0&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
 dbus-send --system --type=method_call --dest=org.bluez /org/bluez/906/hci0 org.bluez.Adapter.SetProperty string:Powered variant:boolean:true&lt;br /&gt;
&lt;br /&gt;
This one automatically inserts adapter path:&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.DefaultAdapter | awk -F&#039;&amp;quot;&#039; &#039;/at/ {print $2}&#039;) org.bluez.Adapter.SetProperty string:Powered variant:boolean:true&lt;br /&gt;
&lt;br /&gt;
====Disable====&lt;br /&gt;
&lt;br /&gt;
 dbus-send --system --type=method_call --dest=org.bluez /org/bluez/906/hci0 org.bluez.Adapter.SetProperty string:Powered variant:boolean:false&lt;br /&gt;
&lt;br /&gt;
With auto-discovery of adapter path:&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.DefaultAdapter | awk -F&#039;&amp;quot;&#039; &#039;/at/ {print $2}&#039;) org.bluez.Adapter.SetProperty string:Powered variant:boolean:false&lt;br /&gt;
&lt;br /&gt;
====Connect to specific device====&lt;br /&gt;
&lt;br /&gt;
 devmac=00:11:22:33:44:55&lt;br /&gt;
 service=AudioSink&lt;br /&gt;
 &lt;br /&gt;
 adapter=$(dbus-send --system --print-reply --dest=org.bluez / org.bluez.Manager.DefaultAdapter | awk -F&#039;&amp;quot;&#039; &#039;/at/ {print $2}&#039;)&lt;br /&gt;
 device=$(dbus-send --system --print-reply --dest=org.bluez ${adapter} org.bluez.Adapter.FindDevice string:${devmac} | awk -F&#039;&amp;quot;&#039; &#039;/at/ {print $2}&#039;)&lt;br /&gt;
 dbus-send --system --type=method_call --print-reply --dest=org.bluez ${device} org.bluez.${service}.Connect&lt;br /&gt;
&lt;br /&gt;
Change the AudoSink to any service and the devmac to the MAC of bluetooth device.&lt;br /&gt;
&lt;br /&gt;
===Check for updates===&lt;br /&gt;
&lt;br /&gt;
 dbus-send --type=method_call --dest=com.nokia.hildon_application_manager /com/nokia/hildon_application_manager com.nokia.hildon_application_manager.check_for_updates&lt;br /&gt;
&lt;br /&gt;
===Open link in browser===&lt;br /&gt;
&lt;br /&gt;
 dbus-send --system --type=method_call --dest=com.nokia.osso_browser /com/nokia/osso_browser/request com.nokia.osso_browser.load_url string:&amp;quot;google.com&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===Open a pdf file with the default pdf reader application===&lt;br /&gt;
&lt;br /&gt;
 dbus-send --print-reply --dest=com.nokia.osso_pdfviewer /com/nokia/osso_pdfviewer com.nokia.osso_pdfviewer.mime_open string:/home/user/MyDocs/.documents/file_name.pdf&lt;br /&gt;
&lt;br /&gt;
===Open a file with the default notes application===&lt;br /&gt;
&lt;br /&gt;
 dbus-send --print-reply --dest=com.nokia.osso_notes /com/nokia/osso_notes com.nokia.osso_notes.mime_open string:/home/user/MyDocs/.documents/file_name&lt;br /&gt;
&lt;br /&gt;
===Open the default notes application===&lt;br /&gt;
&lt;br /&gt;
 dbus-send --print-reply --dest=com.nokia.osso_notes /com/nokia/osso_notes com.nokia.osso_notes.top_application&lt;br /&gt;
&lt;br /&gt;
=== Open folder ===&lt;br /&gt;
&lt;br /&gt;
 dbus-send --print-reply --dest=com.nokia.osso_filemanager /com/nokia/osso_filemanager com.nokia.osso_filemanager.open_folder string:/home/user/MyDocs/&lt;br /&gt;
&lt;br /&gt;
===Set volume===&lt;br /&gt;
&lt;br /&gt;
 dbus-send --type=method_call --dest=com.nokia.mafw.renderer.Mafw-Gst-Renderer-Plugin.gstrenderer /com/nokia/mafw/renderer/gstrenderer com.nokia.mafw.extension.set_extension_property string:volume variant:uint32:50&lt;br /&gt;
&lt;br /&gt;
The value can be between 0 and 100.&lt;br /&gt;
&lt;br /&gt;
===Get volume===&lt;br /&gt;
&lt;br /&gt;
 dbus-send --print-reply --type=method_call --dest=com.nokia.mafw.renderer.Mafw-Gst-Renderer-Plugin.gstrenderer /com/nokia/mafw/renderer/gstrenderer com.nokia.mafw.extension.get_extension_property string:volume|awk &#039;/nt/ {print $3}&#039;&lt;br /&gt;
&lt;br /&gt;
===Reboot===&lt;br /&gt;
&lt;br /&gt;
 dbus-send --system --type=method_call --print-reply --dest=com.nokia.mce &amp;quot;/com/nokia/mce/request&amp;quot; com.nokia.mce.request.req_reboot&lt;br /&gt;
This is same as rebooting from power key menu (needs uncommenting in certain XML file to appear) and has been identified as insecure way to reboot the device (no filesystem synchronization, etc.). Better command is to simply enter &amp;quot;reboot&amp;quot; in root terminal.&lt;br /&gt;
&lt;br /&gt;
===Shutdown===&lt;br /&gt;
&lt;br /&gt;
 dbus-send --system --type=method_call --print-reply --dest=com.nokia.mce &amp;quot;/com/nokia/mce/request&amp;quot; com.nokia.mce.request.req_shutdown&lt;br /&gt;
See warning at reboot D-Bus call (needs testing).&lt;br /&gt;
&lt;br /&gt;
===Show dashboard===&lt;br /&gt;
&lt;br /&gt;
 dbus-send /com/nokia/hildon_desktop com.nokia.hildon_desktop.exit_app_view&lt;br /&gt;
&lt;br /&gt;
===Other===&lt;br /&gt;
&lt;br /&gt;
====D-Bus Scripts====&lt;br /&gt;
&lt;br /&gt;
You can also use [[DbusScripts|dbus-scripts]] to execute any command when various actions are triggered on D-Bus.&lt;br /&gt;
&lt;br /&gt;
====Panucci (pause)====&lt;br /&gt;
&lt;br /&gt;
 dbus-send --type=method_call --dest=org.panucci.panucciInterface /panucciInterface org.panucci.panucciInterface.playPause&lt;br /&gt;
&lt;br /&gt;
====Device Orientation====&lt;br /&gt;
&lt;br /&gt;
 dbus-send --system --print-reply --dest=com.nokia.mce /com/nokia/mce/request com.nokia.mce.request.get_device_orientation&lt;br /&gt;
&lt;br /&gt;
==GConf==&lt;br /&gt;
&lt;br /&gt;
===Reset GPRS data counter===&lt;br /&gt;
&lt;br /&gt;
The commands are PR1.2 compliant and do not work on previous versions.&lt;br /&gt;
&lt;br /&gt;
 gconftool-2 -u /system/osso/connectivity/network_type/GPRS/gprs_home_rx_bytes&lt;br /&gt;
 gconftool-2 -u /system/osso/connectivity/network_type/GPRS/gprs_home_tx_bytes&lt;br /&gt;
 gconftool-2 -s /system/osso/connectivity/network_type/GPRS/gprs_home_reset_time --type=string $(date +%s)&lt;br /&gt;
&lt;br /&gt;
==Command line==&lt;br /&gt;
&lt;br /&gt;
===Enable FM Transmitter===&lt;br /&gt;
&lt;br /&gt;
 /usr/bin/fmtx_client -p 1&lt;br /&gt;
&lt;br /&gt;
===Disable FM Transmitter===&lt;br /&gt;
&lt;br /&gt;
 /usr/bin/fmtx_client -p 0&lt;br /&gt;
&lt;br /&gt;
==GStreamer==&lt;br /&gt;
&lt;br /&gt;
===Take a picture with front camera===&lt;br /&gt;
&lt;br /&gt;
 gst-launch v4l2src device=/dev/video1 num-buffers=1 ! ffmpegcolorspace ! jpegenc ! filesink location=frontcam.jpg&lt;br /&gt;
&lt;br /&gt;
===Shoot photo after 10 seconds===&lt;br /&gt;
&lt;br /&gt;
The camera application must be off for it to work. And of course the camera shutter must be open...gst-launch comes with gstreamer-tools (or gst-launch-0.10 and gstreamer0.10-tools)&lt;br /&gt;
&lt;br /&gt;
 /bin/sleep 10 ; /usr/bin/gst-launch v4l2camsrc device=/dev/video0 num-buffers=1 \! video/x-raw-yuv,width=2592,height=1968  \! ffmpegcolorspace \! jpegenc \! filesink location=/home/user/MyDocs/DCIM/photo.jpg&lt;br /&gt;
&lt;br /&gt;
To shoot from the front camera, change &#039;&#039;&#039;/dev/video0&#039;&#039;&#039; to &#039;&#039;&#039;/dev/video1&#039;&#039;&#039; and the proper resolution:&lt;br /&gt;
&lt;br /&gt;
 /bin/sleep 10 ; /usr/bin/gst-launch v4l2camsrc device=/dev/video1 num-buffers=1 \! video/x-raw-yuv,width=640,height=480  \! ffmpegcolorspace \! jpegenc \! filesink location=/home/user/MyDocs/DCIM/photo.jpg&lt;br /&gt;
&lt;br /&gt;
Other way:&lt;br /&gt;
&lt;br /&gt;
 /bin/sleep 10; /usr/bin/gst-launch v4l2camsrc ! ffmpegcolorspace ! jpegenc ! identity error-after=1 ! filesink location=/home/user/MyDocs/DCIM/photo.jpg&lt;br /&gt;
&lt;br /&gt;
==Python==&lt;br /&gt;
&lt;br /&gt;
===Make a phone call via the cellular network===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
import dbus&lt;br /&gt;
def place_call(number):&lt;br /&gt;
  bus = dbus.SystemBus()&lt;br /&gt;
  csd_call = dbus.Interface(bus.get_object(&#039;com.nokia.csd&#039;,&lt;br /&gt;
                                           &#039;/com/nokia/csd/call&#039;),&lt;br /&gt;
                                           &#039;com.nokia.csd.Call&#039;)&lt;br /&gt;
  csd_call.CreateWith(str(number), dbus.UInt32(0))&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Make a phone call via SIP ===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
#!/usr/bin/python&lt;br /&gt;
&lt;br /&gt;
import dbus&lt;br /&gt;
import sys&lt;br /&gt;
&lt;br /&gt;
# Get the target phone number (or SIP address) from the command line&lt;br /&gt;
TARGET = sys.argv[1];&lt;br /&gt;
&lt;br /&gt;
# Configure the telepathy path to the SofiaSIP account that we wish to use.&lt;br /&gt;
# Use &amp;quot;mc-tool list&amp;quot; (from the libmissioncontrol-utils package) to see your accounts.&lt;br /&gt;
SIP_ACCOUNT = &#039;sofiasip/sip/_31234567_40sipgate_2eco_2euk0&#039;&lt;br /&gt;
&lt;br /&gt;
# This gets us a connnection to the session bus&lt;br /&gt;
bus = dbus.SessionBus()&lt;br /&gt;
&lt;br /&gt;
# This sets up a path to the SIP account within telepathy.&lt;br /&gt;
PATH = &#039;/org/freedesktop/Telepathy/Account/&#039;&lt;br /&gt;
PATH += SIP_ACCOUNT&lt;br /&gt;
&lt;br /&gt;
# This sets up a proxy object as a &amp;quot;handle&amp;quot; to the AccountManager of our target account&lt;br /&gt;
account = bus.get_object(&#039;org.freedesktop.Telepathy.AccountManager&#039;, PATH)&lt;br /&gt;
&lt;br /&gt;
# This launches the actual SIP call with a method call to EnsureChannel on that object&lt;br /&gt;
account.EnsureChannel( \&lt;br /&gt;
        dbus.Dictionary({&lt;br /&gt;
                dbus.String(u&#039;org.freedesktop.Telepathy.Channel.TargetHandleType&#039;): dbus.UInt32(1),&lt;br /&gt;
                dbus.String(u&#039;org.freedesktop.Telepathy.Channel.ChannelType&#039;): dbus.String(u&#039;org.freedesktop.Telepathy.Channel.Type.StreamedMedia&#039;),&lt;br /&gt;
                dbus.String(u&#039;org.freedesktop.Telepathy.Channel.TargetID&#039;): dbus.String(TARGET),&lt;br /&gt;
        }, signature=&#039;sv&#039;),&lt;br /&gt;
        dbus.UInt64(0),&lt;br /&gt;
        dbus.String(&#039;&#039;),&lt;br /&gt;
        dbus_interface=&#039;com.nokia.Account.Interface.ChannelRequests&#039;)&lt;br /&gt;
&lt;br /&gt;
sys.exit(0)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Send SMS===&lt;br /&gt;
&lt;br /&gt;
ssms.py using new QtMobility bindings by ossipena:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
# -*- coding: utf-8 -*-&lt;br /&gt;
&lt;br /&gt;
#ssms Ossipena/TimoP&lt;br /&gt;
#send smses from command line&lt;br /&gt;
#licence : Do whatever you want&lt;br /&gt;
#deps:&lt;br /&gt;
#pyside-qt4&lt;br /&gt;
#pyside-mobility&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;imports&#039;&#039;&#039;&lt;br /&gt;
from QtMobility.Messaging import *&lt;br /&gt;
from PySide.QtCore import *&lt;br /&gt;
import sys&lt;br /&gt;
from PyQt4 import QtCore&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
app = QCoreApplication(sys.argv)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;get number and name&#039;&#039;&#039;&lt;br /&gt;
stringit = sys.argv&lt;br /&gt;
numpertemp = str(stringit[1:2])&lt;br /&gt;
mesits = str(stringit[2:])[2:-2]&lt;br /&gt;
&lt;br /&gt;
num = str(numpertemp[2:-2])&lt;br /&gt;
&lt;br /&gt;
if (mesits == &amp;quot;&amp;quot;):&lt;br /&gt;
  print &amp;quot;Usage:&amp;quot;&lt;br /&gt;
  print &amp;quot;python ssms.py 01234567 &#039;message text here&#039;&amp;quot;&lt;br /&gt;
  sys.exit(69)&lt;br /&gt;
else:&lt;br /&gt;
  print &amp;quot;number is &amp;quot; + str(num)&lt;br /&gt;
  print &amp;quot;message is &amp;quot; + str(mesits)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;define message to be sent&#039;&#039;&#039;&lt;br /&gt;
numperi = QtCore.QString(num)&lt;br /&gt;
&lt;br /&gt;
numper = QMessageAddress(QMessageAddress.Phone, numperi)&lt;br /&gt;
mesitsi = QMessage()&lt;br /&gt;
mesitsi.setType(QMessage.Sms)&lt;br /&gt;
mesitsi.setTo(numper)&lt;br /&gt;
mesitsi.setBody(mesits)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;send message&#039;&#039;&#039;&lt;br /&gt;
sender = QMessageService()&lt;br /&gt;
if (sender.send(mesitsi)):&lt;br /&gt;
  print &amp;quot;success&amp;quot;&lt;br /&gt;
else:&lt;br /&gt;
  print &amp;quot;fail&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From:&lt;br /&gt;
http://talk.maemo.org/showpost.php?p=548948&amp;amp;postcount=52&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
#!/usr/bin/env python2.5&lt;br /&gt;
&lt;br /&gt;
import pexpect&lt;br /&gt;
import time&lt;br /&gt;
from subprocess import *&lt;br /&gt;
&lt;br /&gt;
child = pexpect.spawn(&#039;pnatd&#039;);&lt;br /&gt;
child.send(&#039;at\r&#039;);&lt;br /&gt;
time.sleep(0.25);&lt;br /&gt;
child.send(&#039;at+cmgf=1\r&#039;);&lt;br /&gt;
time.sleep(0.25);&lt;br /&gt;
child.send(&#039;at+cmgs=&amp;quot;+XXXXXXX&amp;quot;\r&#039;);&lt;br /&gt;
child.send(&#039;SMSTEXTSMSTEXTSMSTEXT&#039;);&lt;br /&gt;
child.send(chr(26));&lt;br /&gt;
child.send(chr(26));&lt;br /&gt;
child.sendeof();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There&#039;s also a python script that uses D-Bus instead from http://talk.maemo.org/showpost.php?p=558430&amp;amp;postcount=57:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
#!/usr/bin/env python2.5          &lt;br /&gt;
import sched, time                &lt;br /&gt;
import dbus                       &lt;br /&gt;
import gobject                    &lt;br /&gt;
from dbus.mainloop.glib import DBusGMainLoop&lt;br /&gt;
&lt;br /&gt;
def octify(str):&lt;br /&gt;
        &#039;&#039;&#039;     &lt;br /&gt;
        Returns a list of octet bytes representing&lt;br /&gt;
        each char of the input str.               &lt;br /&gt;
        &#039;&#039;&#039;                                       &lt;br /&gt;
&lt;br /&gt;
        bytes = map(ord, str)&lt;br /&gt;
        bitsconsumed = 0     &lt;br /&gt;
        referencebit = 7     &lt;br /&gt;
        octets = []          &lt;br /&gt;
&lt;br /&gt;
        while len(bytes):&lt;br /&gt;
                byte = bytes.pop(0)&lt;br /&gt;
                byte = byte &amp;gt;&amp;gt; bitsconsumed&lt;br /&gt;
                                           &lt;br /&gt;
                try:                       &lt;br /&gt;
                        nextbyte = bytes[0]&lt;br /&gt;
                        bitstocopy = (nextbyte &amp;amp; (0xff &amp;gt;&amp;gt; referencebit)) &amp;lt;&amp;lt; referencebit&lt;br /&gt;
                        octet = (byte | bitstocopy)                                     &lt;br /&gt;
&lt;br /&gt;
                except:&lt;br /&gt;
                        octet = (byte | 0x00)&lt;br /&gt;
&lt;br /&gt;
                if bitsconsumed != 7:&lt;br /&gt;
                        octets.append(byte | bitstocopy)&lt;br /&gt;
                        bitsconsumed += 1               &lt;br /&gt;
                        referencebit -= 1               &lt;br /&gt;
                else:                                   &lt;br /&gt;
                        bitsconsumed = 0                &lt;br /&gt;
                        referencebit = 7                &lt;br /&gt;
&lt;br /&gt;
        return octets&lt;br /&gt;
&lt;br /&gt;
def semi_octify(str):&lt;br /&gt;
        &#039;&#039;&#039;          &lt;br /&gt;
        Expects a string containing two digits.&lt;br /&gt;
        Returns an octet -                     &lt;br /&gt;
        first nibble in the octect is the first&lt;br /&gt;
        digit and the second nibble represents &lt;br /&gt;
        the second digit.                      &lt;br /&gt;
        &#039;&#039;&#039;                                    &lt;br /&gt;
        try:                                   &lt;br /&gt;
                digit_1 = int(str[0])          &lt;br /&gt;
                digit_2 = int(str[1])          &lt;br /&gt;
                octet = (digit_2 &amp;lt;&amp;lt; 4) | digit_1&lt;br /&gt;
        except:                                 &lt;br /&gt;
                octet = (1 &amp;lt;&amp;lt; 4) | digit_1      &lt;br /&gt;
&lt;br /&gt;
        return octet&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def deoctify(arr):&lt;br /&gt;
&lt;br /&gt;
        referencebit = 1&lt;br /&gt;
        doctect = []    &lt;br /&gt;
        bnext = 0x00    &lt;br /&gt;
&lt;br /&gt;
        for i in arr:&lt;br /&gt;
&lt;br /&gt;
                bcurr = ((i &amp;amp; (0xff &amp;gt;&amp;gt; referencebit)) &amp;lt;&amp;lt; referencebit) &amp;gt;&amp;gt; 1&lt;br /&gt;
                bcurr = bcurr | bnext                                      &lt;br /&gt;
&lt;br /&gt;
                if referencebit != 7:&lt;br /&gt;
                        doctect.append( bcurr )&lt;br /&gt;
                        bnext = (i &amp;amp; (0xff &amp;lt;&amp;lt; (8 - referencebit)) ) &amp;gt;&amp;gt; 8 - referencebit&lt;br /&gt;
                        referencebit += 1                                              &lt;br /&gt;
                else:                                                                  &lt;br /&gt;
                        doctect.append( bcurr )                                        &lt;br /&gt;
                        bnext = (i &amp;amp; (0xff &amp;lt;&amp;lt; (8 - referencebit)) ) &amp;gt;&amp;gt; 8 - referencebit&lt;br /&gt;
                        doctect.append( bnext )                                        &lt;br /&gt;
                        bnext = 0x00                                                   &lt;br /&gt;
                        referencebit = 1                                               &lt;br /&gt;
&lt;br /&gt;
        return &#039;&#039;.join([chr(i) for i in doctect])&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def createPDUmessage(number, msg):&lt;br /&gt;
        &#039;&#039;&#039;                       &lt;br /&gt;
        Returns a list of bytes to represent a valid PDU message&lt;br /&gt;
        &#039;&#039;&#039;                                                     &lt;br /&gt;
        numlength = len(number)                                 &lt;br /&gt;
        if (numlength % 2) == 0:                                &lt;br /&gt;
                rangelength = numlength                         &lt;br /&gt;
        else:                                                   &lt;br /&gt;
                number = number + &#039;F&#039;                           &lt;br /&gt;
                rangelength = len(number)                       &lt;br /&gt;
&lt;br /&gt;
        octifiednumber = [ semi_octify(number[i:i+2]) for i in range(0,rangelength,2) ]&lt;br /&gt;
        octifiedmsg = octify(msg)                                                      &lt;br /&gt;
        HEADER = 1                                                                     &lt;br /&gt;
        FIRSTOCTETOFSMSDELIVERMSG = 10                                                 &lt;br /&gt;
        ADDR_TYPE = 129 #unknown format                                                &lt;br /&gt;
        number_length = len(number)                                                    &lt;br /&gt;
        msg_length = len(msg)                                                          &lt;br /&gt;
        pdu_message = [HEADER, FIRSTOCTETOFSMSDELIVERMSG, number_length, ADDR_TYPE]    &lt;br /&gt;
        pdu_message.extend(octifiednumber)                                             &lt;br /&gt;
        pdu_message.append(0)                                                          &lt;br /&gt;
        pdu_message.append(0)                                                          &lt;br /&gt;
        pdu_message.append(msg_length)                                                 &lt;br /&gt;
        pdu_message.extend(octifiedmsg)                                                &lt;br /&gt;
        return pdu_message                                                             &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def sendmessage(number, message):&lt;br /&gt;
&lt;br /&gt;
        bus = dbus.SystemBus()&lt;br /&gt;
        smsobject = bus.get_object(&#039;com.nokia.phone.SMS&#039;, &#039;/com/nokia/phone/SMS/ba212ae1&#039;)&lt;br /&gt;
        smsiface = dbus.Interface(smsobject, &#039;com.nokia.csd.SMS.Outgoing&#039;)&lt;br /&gt;
        arr = dbus.Array(createPDUmessage(number.replace(&#039;+&#039;, &#039;00&#039;), message))&lt;br /&gt;
&lt;br /&gt;
        msg = dbus.Array([arr])&lt;br /&gt;
        smsiface.Send(msg,&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def callback(pdumsg, msgcenter, somestring, sendernumber):&lt;br /&gt;
&lt;br /&gt;
        msglength = int(pdumsg[18])&lt;br /&gt;
        msgarray = pdumsg[19:len(pdumsg)]&lt;br /&gt;
&lt;br /&gt;
        msg = deoctify(msgarray)&lt;br /&gt;
&lt;br /&gt;
        if msg &amp;gt; 0:&lt;br /&gt;
               print &#039;New message received from %s&#039; % sendernumber&lt;br /&gt;
               print &#039;Message length %d&#039; % msglength&lt;br /&gt;
               print &#039;Message: %s&#039; % msg&lt;br /&gt;
&lt;br /&gt;
               if msg == &amp;quot;ping&amp;quot;:&lt;br /&gt;
                       print &amp;quot;Sending reply: pong&amp;quot;&lt;br /&gt;
                       sendmessage(sendernumber.replace(&amp;quot;+&amp;quot;,&amp;quot;00&amp;quot;), &amp;quot;pong&amp;quot;)&lt;br /&gt;
               else:&lt;br /&gt;
                       print &amp;quot;Unknown command&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def listen():&lt;br /&gt;
        DBusGMainLoop(set_as_default=True)&lt;br /&gt;
        bus = dbus.SystemBus() #should connect to system bus instead of session because the former is where the incoming signals come from&lt;br /&gt;
        bus.add_signal_receiver(callback, path=&#039;/com/nokia/phone/SMS&#039;, dbus_interface=&#039;Phone.SMS&#039;, signal_name=&#039;IncomingSegment&#039;)&lt;br /&gt;
        gobject.MainLoop().run()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if __name__ == &#039;__main__&#039;:&lt;br /&gt;
  import time&lt;br /&gt;
  &lt;br /&gt;
  def schedule_task(schedule, fn, *args):&lt;br /&gt;
      import sched&lt;br /&gt;
      s = sched.scheduler(time.time, time.sleep)&lt;br /&gt;
      startTime = time.mktime(time.strptime(schedule, &#039;%b %d %H:%M %Y&#039;))&lt;br /&gt;
      s.enterabs(startTime, 0, fn, args)&lt;br /&gt;
      s.run()&lt;br /&gt;
&lt;br /&gt;
  import getopt, sys&lt;br /&gt;
  try:  &lt;br /&gt;
    opts, args = getopt.getopt(sys.argv[1:],&amp;quot;hlt:&amp;quot;, [&amp;quot;help&amp;quot;,&amp;quot;listen&amp;quot;,&amp;quot;time=&amp;quot;])&lt;br /&gt;
&lt;br /&gt;
  except getopt.GetoptError, err:&lt;br /&gt;
    # print help information and exit:&lt;br /&gt;
    print str(err) # will print something like &amp;quot;option -a not recognized&amp;quot;&lt;br /&gt;
    usage()&lt;br /&gt;
    sys.exit(2)  &lt;br /&gt;
  listening = False &lt;br /&gt;
  timeofday = &#039;&#039;&lt;br /&gt;
  for opt, arg in opts:&lt;br /&gt;
    if opt in (&amp;quot;-h&amp;quot;, &amp;quot;--help&amp;quot;):&lt;br /&gt;
      usage()                     &lt;br /&gt;
      sys.exit()                  &lt;br /&gt;
    elif opt in (&amp;quot;-l&amp;quot;, &amp;quot;--listen&amp;quot;):&lt;br /&gt;
      listening = True                 &lt;br /&gt;
    elif opt in (&amp;quot;-t&amp;quot;, &amp;quot;--time&amp;quot;):&lt;br /&gt;
      timeofday = arg                           &lt;br /&gt;
    else:&lt;br /&gt;
      assert False, &amp;quot;unhandled option&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  number = args[0]           &lt;br /&gt;
  msg = args[1]&lt;br /&gt;
  if msg != &#039;&#039;:&lt;br /&gt;
    if timeofday == &#039;&#039;:&lt;br /&gt;
        sendmessage(number, msg)&lt;br /&gt;
    else:&lt;br /&gt;
        today = time.strftime(&#039;%b %d x %Y&#039;, time.localtime())&lt;br /&gt;
        schedule = today.replace(&#039;x&#039;, timeofday)&lt;br /&gt;
        schedule_task(schedule, sendmessage, number, msg)&lt;br /&gt;
  if listening:&lt;br /&gt;
    listen()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Send dialog notification (orange multi line popup requiring user interaction)===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
import dbus&lt;br /&gt;
def show_notification_dialog(message, mode=&amp;quot;single&amp;quot;):&lt;br /&gt;
  bus = dbus.SystemBus()&lt;br /&gt;
  iface = dbus.Interface(bus.get_object(&#039;org.freedesktop.Notifications&#039;,&lt;br /&gt;
                                        &#039;/org/freedesktop/Notifications&#039;),&lt;br /&gt;
                                        &#039;org.freedesktop.Notifications&#039;)&lt;br /&gt;
  if mode == &amp;quot;single&amp;quot;:&lt;br /&gt;
      iface.SystemNoteInfoprint(message)&lt;br /&gt;
  elif mode == &amp;quot;multiline&amp;quot;:&lt;br /&gt;
      iface.SystemNoteDialog(str(message), dbus.UInt32(0), &#039;Ok&#039;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This function allows you to show notification either with multiline (on Maemo pre-5 it will show a dialog with an &amp;quot;Ok&amp;quot; button) or single line (tiny notifications hiding automatically).&lt;br /&gt;
&lt;br /&gt;
===Take a screenshot===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
import gtk.gdk&lt;br /&gt;
&lt;br /&gt;
w = gtk.gdk.get_default_root_window()&lt;br /&gt;
sz = w.get_size()&lt;br /&gt;
print &amp;quot;The size of the window is %d x %d&amp;quot; % sz&lt;br /&gt;
pb = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB,False,8,sz[0],sz[1])&lt;br /&gt;
pb = pb.get_from_drawable(w,w.get_colormap(),0,0,0,0,sz[0],sz[1])&lt;br /&gt;
if (pb != None):&lt;br /&gt;
  pb.save(&amp;quot;screenshot.png&amp;quot;,&amp;quot;png&amp;quot;)&lt;br /&gt;
  print &amp;quot;Screenshot saved to screenshot.png.&amp;quot;&lt;br /&gt;
else:&lt;br /&gt;
  print &amp;quot;Unable to get the screenshot.&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Credits: took code from [http://stackoverflow.com/questions/69645/take-a-screenshot-via-a-python-script-linux here].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There is also a way using PyQt:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
import sys&lt;br /&gt;
import time&lt;br /&gt;
from PyQt4.QtGui import QPixmap, QApplication&lt;br /&gt;
app = QApplication(sys.argv)&lt;br /&gt;
file = &amp;quot;/home/user/MyDocs/.images/Screenshots/Screenshot-&amp;quot;+time.strftime(&amp;quot;%Y%m%d&amp;quot;)+&amp;quot;-&amp;quot;+time.strftime(&amp;quot;%H%M%S&amp;quot;)+&amp;quot;.png&amp;quot;&lt;br /&gt;
QPixmap.grabWindow(QApplication.desktop().winId()).save(file, &#039;png&#039;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Make an &amp;quot;Email Style&amp;quot; notification dialog===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
import dbus&lt;br /&gt;
&lt;br /&gt;
bus = dbus.SessionBus()&lt;br /&gt;
proxy = bus.get_object(&#039;org.freedesktop.Notifications&#039;, &#039;/org/freedesktop/Notifications&#039;)&lt;br /&gt;
interface = dbus.Interface(proxy,dbus_interface=&#039;org.freedesktop.Notifications&#039;)&lt;br /&gt;
interface.Notify(&#039;Notification&#039;, 0, &#039;control_bluetooth_paired&#039;, &#039;Testing 123&#039;, &#039;Hello World&#039;, [], {}, 0)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Credits: MohammadAG (on irc).&lt;br /&gt;
&lt;br /&gt;
[[Category:Power users]]&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>213.240.181.249</name></author>
	</entry>
	<entry>
		<id>https://maemo.octonezd.me/index.php?title=DbusScripts&amp;diff=5473</id>
		<title>DbusScripts</title>
		<link rel="alternate" type="text/html" href="https://maemo.octonezd.me/index.php?title=DbusScripts&amp;diff=5473"/>
		<updated>2011-09-09T05:37:02Z</updated>

		<summary type="html">&lt;p&gt;213.240.181.249: add wait for dbus, otherwise it may fail&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://www.cobb.uk.net/770/#dbus-scripts dbus-scripts] is a daemon that can execute a command when various actions occurs on D-Bus. Some D-Bus signals you can watch for are :&lt;br /&gt;
&lt;br /&gt;
* keyboard slide&lt;br /&gt;
* battery full, low or empty&lt;br /&gt;
* connection or disconnection from a network&lt;br /&gt;
* sms or phone call arriving&lt;br /&gt;
* desktop started (ie. after boot is completed)&lt;br /&gt;
* bnep or usb network started or stopped (use to configure or run firewalls etc)&lt;br /&gt;
&lt;br /&gt;
You can find dbus-scripts in [[extras-devel]] (so be careful, your [[Nokia N900|N900]] could crash).&lt;br /&gt;
&lt;br /&gt;
There&#039;s some documentation in the [http://www.cobb.uk.net/770/dbus-scripts-example dbus-scripts config file]&lt;br /&gt;
&lt;br /&gt;
There&#039;s also a configurator program [http://maemo.org/packages/view/dbus-scripts-settings/ dbus-scripts-settings] written by Matan Ziv-Av. You can use dbus-scripts-settings settings to configure dbus-scripts or just to browse. &lt;br /&gt;
Thanks to Graham and Matan.&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
&lt;br /&gt;
=== Basic configuration ===&lt;br /&gt;
&lt;br /&gt;
Configuration files for dbus-scripts are in &amp;lt;code&amp;gt;/etc/dbus-scripts.d&amp;lt;/code&amp;gt; and you can find some documentation in &amp;lt;code&amp;gt;/etc/dbus-scripts.d/dbus-scripts-example&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
  # Example of dbus-scripts control file&lt;br /&gt;
  #&lt;br /&gt;
  # Each line of these files represents a filter to call a script.&lt;br /&gt;
  # Tokens are separated by white space.&lt;br /&gt;
  # First token on line is the script to execute.&lt;br /&gt;
  # Subsequent tokens are filters to match arguments from dbus message.&lt;br /&gt;
  # Filters are matched like shell wildcards (using fnmatch(3)).&lt;br /&gt;
  # If a filter is specified (even if it is *), the corresponding argument&lt;br /&gt;
  # must be present in order to get a match.&lt;br /&gt;
  #&lt;br /&gt;
  # First argument is sender&lt;br /&gt;
  # Second argument is destination&lt;br /&gt;
  # For SIGNAL and METHOD_CALL, third argument is interface&lt;br /&gt;
  # For SIGNAL and METHOD_CALL, fourth argument is member&lt;br /&gt;
  # Other arguments depend on the message&lt;br /&gt;
  #&lt;br /&gt;
  # Example: to act on WLAN interface state changes use:&lt;br /&gt;
  #/some/script * * com.nokia.icd status_changed * WLAN_INFRA&lt;br /&gt;
  # In /some/script, $5 will be the interface name and $7 the new state (IDLE, CONNECTED, etc.)&lt;br /&gt;
&lt;br /&gt;
* this rule will match all wlan network events&lt;br /&gt;
&lt;br /&gt;
  /some/script * * com.nokia.icd status_changed * WLAN_INFRA&lt;br /&gt;
&lt;br /&gt;
* this one will match all events for wlan network id of 91f493fb-7c89-4fc6-ac2c-b822923dde45, it&#039;s mine&lt;br /&gt;
&lt;br /&gt;
You can find the wlan id with the command&lt;br /&gt;
 gconftool-2 -R /system/osso/connectivity/IAP&lt;br /&gt;
&lt;br /&gt;
  /some/script * * com.nokia.icd status_changed 91f493fb-7c89-4fc6-ac2c-b822923dde45 WLAN_INFRA&lt;br /&gt;
&lt;br /&gt;
* this one will match only the CONNECTED (wifi works) dbus event for my wlan network :&lt;br /&gt;
&lt;br /&gt;
  /some/script * * com.nokia.icd status_changed 91f493fb-7c89-4fc6-ac2c-b822923dde45 WLAN_INFRA CONNECTED&lt;br /&gt;
&lt;br /&gt;
=== dbus-scripts-settings ===&lt;br /&gt;
&lt;br /&gt;
There&#039;s also a configurator program [http://maemo.org/packages/view/dbus-scripts-settings/dbus-scripts-settings] written by Matan Ziv-Av. You can use dbus-scripts-settings settings to configure dbus-scripts or just to browse. &lt;br /&gt;
&lt;br /&gt;
:As of 2010-07-16, dbus-scripts-settings is missing a dependency on package &#039;gnome-python-dev&#039;. If the program crashes and at command line you get the error &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
Traceback (most recent call last):&lt;br /&gt;
  File &amp;quot;/usr/bin/dbus-scripts-settings&amp;quot;, line 5, in &amp;lt;module&amp;gt;&lt;br /&gt;
    from gnome import gconf&lt;br /&gt;
ImportError: No module named gnome&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:then the fix is to install gnome-python-dev. [[User:magick777|magick777]] 14:09, 16 July 2010 (UTC)&lt;br /&gt;
&lt;br /&gt;
=== dbus-scripts daemon options ===&lt;br /&gt;
&lt;br /&gt;
==== Running dbus-scripts on the session bus ====&lt;br /&gt;
&lt;br /&gt;
By default, the dbus-scripts daemon listens on the system message bus, which reports system events but not those from the user session. If you want to access events such as an application being launched, you&#039;ll need to configure the daemon to listen to the session bus as well. You&#039;ll probably want to run a second instance of dbus-scripts without breaking the one on the system bus.&lt;br /&gt;
&lt;br /&gt;
Ignore &amp;lt;code&amp;gt;/etc/init.d/dbus-scripts&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;/etc/default/dbus-scripts&amp;lt;/code&amp;gt; as these would seem to have been superseded by upstart. Make a copy of &amp;lt;code&amp;gt;/etc/event.d/dbus-scripts&amp;lt;/code&amp;gt; as &amp;lt;code&amp;gt;/etc/event.d/dbus-scripts-session&amp;lt;/code&amp;gt; and edit it so your &amp;lt;code&amp;gt;/etc/event.d/dbus-scripts-session&amp;lt;/code&amp;gt; will look like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
Nokia-N900:~# cat /etc/event.d/dbus-scripts &lt;br /&gt;
description &amp;quot;dbus-scripts-session&amp;quot;&lt;br /&gt;
author &amp;quot;Graham Cobb &amp;lt;g+770@cobb.uk.net&amp;gt;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
start on started hildon-desktop&lt;br /&gt;
stop on stopping hildon-desktop&lt;br /&gt;
&lt;br /&gt;
console none&lt;br /&gt;
&lt;br /&gt;
pre-start script&lt;br /&gt;
        /usr/bin/run-standalone.sh /usr/sbin/waitdbus session&lt;br /&gt;
end script&lt;br /&gt;
&lt;br /&gt;
exec run-standalone.sh /usr/sbin/dbus-scripts --session&lt;br /&gt;
&lt;br /&gt;
respawn&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and you can then configure dbus-scripts with statements such as&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#:Browser launched&lt;br /&gt;
/usr/bin/onbrowser * * com.nokia.HildonDesktop.AppMgr LaunchApplication browser&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to react to, in this example, the browser being started.&lt;br /&gt;
&lt;br /&gt;
==== The incredibly useful --debug flag ====&lt;br /&gt;
&lt;br /&gt;
The --debug flag is essential for looking at what&#039;s going on if you plan to write your own scripts. Run &amp;quot;dbus-scripts --debug&amp;quot; in a terminal and then perform whatever actions on the phone, to see all the events you can process using dbus-scripts. To see events on the session bus, make that &amp;quot;dbus-scripts --debug --session&amp;quot; (but you will need to run it through &amp;lt;code&amp;gt;run-standalone.sh&amp;lt;/code&amp;gt;). For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo dbus-scripts --debug&lt;br /&gt;
sudo /usr/bin/run-standalone.sh dbus-scripts --debug --session&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Usage, tips and tricks ==&lt;br /&gt;
&lt;br /&gt;
dbus-scripts does not reread edited configuration automatically. After editing (or creating/removing) a configuration file, you need to restart it.&lt;br /&gt;
&lt;br /&gt;
On N900 it can easily be done with&lt;br /&gt;
 killall dbus-scripts&lt;br /&gt;
since it is then restarted by upstart. On 770/N800/N810, use&lt;br /&gt;
 /etc/init.d/dbus-scripts restart&lt;br /&gt;
&lt;br /&gt;
The package dbus-scripts-settings contains a script &amp;lt;code&amp;gt;logit.sh&amp;lt;/code&amp;gt; which simply logs its parameters to the file &amp;lt;code&amp;gt;/media/mmc1/logit.log&amp;lt;/code&amp;gt;. If you want to find out if some event generates D-Bus events, and what configuration line to use for it, create a file in &amp;lt;code&amp;gt;/etc/dbus-scripts.d/&amp;lt;/code&amp;gt; containing:&lt;br /&gt;
&lt;br /&gt;
 /usr/bin/logit.sh *&lt;br /&gt;
&lt;br /&gt;
And generate the event. Reading the log file will show you all the D-Bus activity. &lt;br /&gt;
&lt;br /&gt;
== Limitations ==&lt;br /&gt;
&lt;br /&gt;
For the moment dbus-scripts will only pass simple D-Bus type arguments like string, boolean and int32 et uint32 to your scripts. You will miss variant, array and all other complex type arguments. So if you want to play, for example, with text of received SMS, you can&#039;t yet use dbus-scripts as the text is an array of bytes.&lt;br /&gt;
&lt;br /&gt;
== Some scripts ==&lt;br /&gt;
&lt;br /&gt;
Here are some things you can do, if you have others, add them. Those examples aren&#039;t rocket science and I&#039;ve stolen some ideas from here and there on web.&lt;br /&gt;
&lt;br /&gt;
=== when connect on my wifi home network register only SIP and turn on noisy ring ===&lt;br /&gt;
&lt;br /&gt;
When I come back home I want my SIP call redirected to my mobile phone and the phone ring turn on and when I leave I want my ring turn off so I wait for D-Bus event on my home wifi network and register/unregister SIP and turn on/off the ring.&lt;br /&gt;
&lt;br /&gt;
I use this dbus-scripts config file :&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;/etc/dbus-scripts.d/athome&#039;&#039;&#039;&lt;br /&gt;
  /home/user/bin/athome * * com.nokia.icd status_changed * WLAN_INFRA&lt;br /&gt;
&lt;br /&gt;
and this script to register/unregister SIP and turn on/off the ring.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;/home/user/bin/athome&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
#!/usr/bin/python&lt;br /&gt;
&lt;br /&gt;
import dbus&lt;br /&gt;
import sys&lt;br /&gt;
import re&lt;br /&gt;
import telepathy&lt;br /&gt;
&lt;br /&gt;
wifi = &#039;91f493fb-7c89-4fc6-ac2c-b822923dde45&#039;&lt;br /&gt;
&lt;br /&gt;
# /home/user/bin/w32g * * com.nokia.icd status_changed * WLAN_INFRA *&lt;br /&gt;
&lt;br /&gt;
wifi_id,state = sys.argv[5],sys.argv[7]&lt;br /&gt;
&lt;br /&gt;
# if we are not on the good wifi network we do nothing and exit&lt;br /&gt;
if wifi and not re.search(wifi_id, wifi, re.IGNORECASE):&lt;br /&gt;
   sys.exit(0)&lt;br /&gt;
&lt;br /&gt;
bus = dbus.SessionBus()&lt;br /&gt;
account = bus.get_object(&#039;org.freedesktop.Telepathy.AccountManager&#039;,&lt;br /&gt;
                         &#039;/org/freedesktop/Telepathy/Account/sofiasip/sip/_309517129090&#039;)&lt;br /&gt;
profile = bus.get_object(&#039;com.nokia.profiled&#039;, &#039;/com/nokia/profiled&#039;)&lt;br /&gt;
&lt;br /&gt;
def change_state(prof, presence_const, presence_text):&lt;br /&gt;
   profile.set_profile(prof, dbus_interface=&#039;com.nokia.profiled&#039;)&lt;br /&gt;
   account.Set(&#039;org.freedesktop.Telepathy.Account&#039;, &#039;RequestedPresence&#039;, \&lt;br /&gt;
               dbus.Struct(( dbus.UInt32( presence_const) ,  presence_text, &amp;quot;&amp;quot;), signature=&#039;uss&#039;),&lt;br /&gt;
               dbus_interface=&#039;org.freedesktop.DBus.Properties&#039;)&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
if state == &amp;quot;CONNECTED&amp;quot;:&lt;br /&gt;
   print &amp;quot;available&amp;quot;&lt;br /&gt;
   change_state(&#039;general&#039;, telepathy.constants.CONNECTION_PRESENCE_TYPE_AVAILABLE, &#039;available&#039;)&lt;br /&gt;
elif state == &amp;quot;IDLE&amp;quot;:&lt;br /&gt;
   print &amp;quot;offline&amp;quot;&lt;br /&gt;
   change_state(&#039;silent&#039;, telepathy.constants.CONNECTION_PRESENCE_TYPE_OFFLINE, &#039;offline&#039;)&lt;br /&gt;
else:&lt;br /&gt;
   sys.exit(&amp;quot;Usage: %s (start|stop)&amp;quot; %  sys.argv[0])&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== turn to 2g when connected to wifi network ===&lt;br /&gt;
&lt;br /&gt;
There&#039;s already an [[Fcron#Auto_2G_with_WiFi|alternative method with fcron]]. Here is a D-Bus method :&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;/etc/dbus-scripts.d/w32g&#039;&#039;&#039;&lt;br /&gt;
 /home/user/bin/w32g.py * * com.nokia.icd status_changed * WLAN_INFRA&lt;br /&gt;
&lt;br /&gt;
Installation documentation is at the beginning of the script and configuration documentation is at the beginning of the configuration file:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;/home/user/bin/w32g.py&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
#!/usr/bin/python&lt;br /&gt;
&lt;br /&gt;
import sys&lt;br /&gt;
import os&lt;br /&gt;
import ConfigParser&lt;br /&gt;
import re&lt;br /&gt;
&lt;br /&gt;
# You need to install dbus-scripts (BE CAREFUL, it&#039;s a devel package)&lt;br /&gt;
# &lt;br /&gt;
# as root you need to create a file /etc/sudoers.d/w32g&lt;br /&gt;
# with this line :&lt;br /&gt;
#   user ALL = NOPASSWD: /bin/ping&lt;br /&gt;
# and run the command update-sudoers because only root can use ping&lt;br /&gt;
# &lt;br /&gt;
# always as root and you need to create another file&lt;br /&gt;
# /etc/dbus-scripts/w32g with the following line : &lt;br /&gt;
#&lt;br /&gt;
#   /home/user/bin/w32g * * com.nokia.icd status_changed * WLAN_INFRA *&lt;br /&gt;
#&lt;br /&gt;
# and copy this script in /home/user/bin/w32g&lt;br /&gt;
&lt;br /&gt;
conf_file = &#039;/home/user/.w32g.conf&#039;&lt;br /&gt;
&lt;br /&gt;
config = { &#039;message_on_idle&#039;: &#039;3G cellular mode set&#039;,&lt;br /&gt;
  &#039;message_on_connected&#039;: &#039;2G (GSM) cellular mode set&#039;,&lt;br /&gt;
  &#039;connection_test&#039;: &#039;sudo /bin/ping -c 1 www.google.com&#039;,&lt;br /&gt;
  &#039;change_on_idle&#039;: &#039;true&#039;,&lt;br /&gt;
  &#039;change_to_dual&#039;: &#039;true&#039;,&lt;br /&gt;
  &#039;wifi&#039;: &#039;&#039;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
config_parser = ConfigParser.SafeConfigParser()&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    config_parser.read(conf_file)&lt;br /&gt;
    for item in config_parser.items(&#039;w32g&#039;):&lt;br /&gt;
        config[ item[0] ] = item[1]&lt;br /&gt;
except ConfigParser.NoSectionError:&lt;br /&gt;
    pass&lt;br /&gt;
&lt;br /&gt;
def to_bool(string):&lt;br /&gt;
    if re.search(&#039;true&#039;, string, re.IGNORECASE):&lt;br /&gt;
        return True&lt;br /&gt;
&lt;br /&gt;
config[&#039;change_on_idle&#039;] = to_bool(config[&#039;change_on_idle&#039;])&lt;br /&gt;
config[&#039;change_to_dual&#039;] = to_bool(config[&#039;change_to_dual&#039;])&lt;br /&gt;
&lt;br /&gt;
wifi_id,state = sys.argv[5],sys.argv[7]&lt;br /&gt;
&lt;br /&gt;
# if we are not on the good wifi network we do nothing and exit&lt;br /&gt;
if config[&#039;wifi&#039;] and not re.search(wifi_id, config[&#039;wifi&#039;], re.IGNORECASE):&lt;br /&gt;
    sys.exit(0)&lt;br /&gt;
&lt;br /&gt;
dbus_wifi = &amp;quot;dbus-send --system --type=method_call --print-reply --dest=com.nokia.phone.net /com/nokia/phone/net Phone.Net.set_selected_radio_access_technology&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
dbus_notif = &amp;quot;dbus-send --system --type=method_call --print-reply --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteInfoprint&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
if state == &#039;CONNECTED&#039;:&lt;br /&gt;
    # we verified that the connection works&lt;br /&gt;
    if config[&#039;connection_test&#039;]:&lt;br /&gt;
        ret = os.system(config[&#039;connection_test&#039;]);&lt;br /&gt;
    else:&lt;br /&gt;
        ret = 0&lt;br /&gt;
    if ret == 0:&lt;br /&gt;
        os.system(dbus_wifi + &amp;quot; byte:1&amp;quot;);&lt;br /&gt;
        os.system(dbus_notif + &amp;quot; string:&#039;&amp;quot; + config[&#039;message_on_connected&#039;] + &amp;quot;&#039;&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
elif state == &#039;IDLE&#039; and config[&#039;change_on_idle&#039;]:&lt;br /&gt;
    dual = &amp;quot;2&amp;quot;&lt;br /&gt;
    if config[&#039;change_to_dual&#039;]: dual = &amp;quot;0&amp;quot;&lt;br /&gt;
    print dual&lt;br /&gt;
    os.system(dbus_wifi + &amp;quot; byte:&amp;quot; + dual);&lt;br /&gt;
    os.system(dbus_notif + &amp;quot; string:&#039;&amp;quot; + config[&#039;message_on_idle&#039;] + &amp;quot;&#039;&amp;quot;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;/home/user/.w32g.conf&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[w32g]&lt;br /&gt;
&lt;br /&gt;
### the comment reflect the default configuration&lt;br /&gt;
### true is true (case insensitive), everything else is false&lt;br /&gt;
&lt;br /&gt;
### the command used to test the wifi connection before downgrading to 2g&lt;br /&gt;
### if you don&#039;t want to do test just delete after =&lt;br /&gt;
# connection_test = sudo /bin/ping -c 1 www.google.com&lt;br /&gt;
&lt;br /&gt;
### notification message when going to 3g&lt;br /&gt;
# message_on_idle = 3G cellular mode set&lt;br /&gt;
### notification message when going to 2g&lt;br /&gt;
# message_on_connected = 2G (GSM) cellular mode set&lt;br /&gt;
&lt;br /&gt;
### shall we go back to 3g when wlan disconnect ?&lt;br /&gt;
#### if you want to have false just delete after =&lt;br /&gt;
# change_on_idle = true&lt;br /&gt;
### shall we go back to dual or 3g ?&lt;br /&gt;
# change_to_dual = true&lt;br /&gt;
&lt;br /&gt;
### if you want go to 2g only when connected to some wlan you can add their wlan id here&lt;br /&gt;
### you can find the wlan id using the command &lt;br /&gt;
### gconftool-2 -R /system/osso/connectivity/IAP&lt;br /&gt;
### For example :&lt;br /&gt;
### wifi = 91f493fb-7c89-4fc6-ac2c-b822923dde45 9ee5dd55-9a32-4ee9-9131-c464ad31d907&lt;br /&gt;
# wifi =&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Enable tethering when connecting to Bluetooth PAN ===&lt;br /&gt;
&lt;br /&gt;
Tethering is a bit of a hassle in Maemo. Most people refer to JoikuSpot, which is definitely the most comfortable solution, but it&#039;s not free. So, why not use builtin (or easily installable) functionality to use the N900 as a modem?&lt;br /&gt;
&lt;br /&gt;
For this script to work, you need to have at least bluetooth-dun and iptables installed. Possibly other packages too, please test and correct.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;/etc/dbus-scripts.d/tethering&#039;&#039;&#039;&lt;br /&gt;
 /usr/bin/tethering.sh * * org.freedesktop.Hal.Manager DeviceAdded&lt;br /&gt;
 /usr/bin/tethering.sh * * org.freedesktop.Hal.Manager DeviceRemoved&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;/usr/bin/tethering.sh&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
#&lt;br /&gt;
# /usr/bin/tethering.sh&lt;br /&gt;
#&lt;br /&gt;
# Enable tethering on USB network and Bluetooth PAN.&lt;br /&gt;
#&lt;br /&gt;
# Note that the INETDEV must be up and running when this script is&lt;br /&gt;
# started, or forwarding will not be enabled.&lt;br /&gt;
# Having tethering on multiple devices concurrently is possible,&lt;br /&gt;
# but forwarding will be disabled once the first device disconnetcs.&lt;br /&gt;
# A better check is necessary.&lt;br /&gt;
#&lt;br /&gt;
# Put this into /etc/dbus-scripts/tethering :&lt;br /&gt;
# /usr/bin/tethering.sh * * org.freedesktop.Hal.Manager DeviceAdded&lt;br /&gt;
# /usr/bin/tethering.sh * * org.freedesktop.Hal.Manager DeviceRemoved&lt;br /&gt;
#&lt;br /&gt;
# dbus-scripts doesn&#039;t give us the event path, so we have to use a more&lt;br /&gt;
# convoluted method of getting the network interface.&lt;br /&gt;
#&lt;br /&gt;
&lt;br /&gt;
EVENT=&amp;quot;$4&amp;quot;&lt;br /&gt;
UDI=&amp;quot;$5&amp;quot;&lt;br /&gt;
HALDEV=&amp;quot;$(echo $UDI | sed &#039;s#.*/\([0-9a-zA-Z_]*\)#\1#&#039;)&amp;quot;&lt;br /&gt;
LOG=&amp;quot;/tmp/tethering.log&amp;quot;&lt;br /&gt;
INETDEV=&amp;quot;gprs0&amp;quot;&lt;br /&gt;
RUNFILE=&amp;quot;/var/run/tethering.$HALDEV.pid&amp;quot;&lt;br /&gt;
IFACEFILE=&amp;quot;/var/run/tethering.$HALDEV.iface&amp;quot;&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;$EVENT&amp;quot; = &amp;quot;DeviceAdded&amp;quot; ]; then&lt;br /&gt;
	IFACE=$(hal-get-property --udi $UDI --key net.interface)&lt;br /&gt;
	case $IFACE in&lt;br /&gt;
		bnep0 )&lt;br /&gt;
			IF_ADDRESS=192.168.254.254&lt;br /&gt;
			IF_RANGE=192.168.254.1,192.168.254.254&lt;br /&gt;
		;;&lt;br /&gt;
	 	usb0 )&lt;br /&gt;
			IF_ADDRESS=192.168.253.254&lt;br /&gt;
			IF_RANGE=192.168.253.1,192.168.253.254&lt;br /&gt;
		;;&lt;br /&gt;
		* )&lt;br /&gt;
			exit 0&lt;br /&gt;
		;;&lt;br /&gt;
	esac&lt;br /&gt;
&lt;br /&gt;
	echo &amp;quot;$(date) Enabling tethering on interface $IFACE&amp;quot; &amp;gt;&amp;gt; $LOG&lt;br /&gt;
	echo &amp;quot;$IFACE&amp;quot; &amp;gt; $IFACEFILE&lt;br /&gt;
	ifconfig &amp;quot;$IFACE&amp;quot; &amp;quot;$IF_ADDRESS&amp;quot;&lt;br /&gt;
	/sbin/modprobe ipt_MASQUERADE&lt;br /&gt;
	/usr/sbin/iptables -t nat -A POSTROUTING -o $INETDEV -j MASQUERADE&lt;br /&gt;
	start-stop-daemon -S -p &amp;quot;$RUNFILE&amp;quot; -m -b -x /usr/sbin/dnsmasq -- -k -I lo -i &amp;quot;$IFACE&amp;quot; -a $IF_ADDRESS -z -F $IF_RANGE,3600&lt;br /&gt;
	echo 1 &amp;gt; /proc/sys/net/ipv4/conf/$IFACE/forwarding&lt;br /&gt;
	echo 1 &amp;gt; /proc/sys/net/ipv4/conf/$INETDEV/forwarding&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;$EVENT&amp;quot; = &amp;quot;DeviceRemoved&amp;quot; ]; then&lt;br /&gt;
	if [ ! -f &amp;quot;$IFACEFILE&amp;quot; ]; then&lt;br /&gt;
		exit 0&lt;br /&gt;
	fi&lt;br /&gt;
	IFACE=&amp;quot;$(cat $IFACEFILE)&amp;quot;&lt;br /&gt;
	rm &amp;quot;$IFACEFILE&amp;quot;&lt;br /&gt;
	echo &amp;quot;$(date) Disabling tethering on device $IFACE&amp;quot; &amp;gt;&amp;gt; $LOG&lt;br /&gt;
	echo 0 &amp;gt; /proc/sys/net/ipv4/conf/$INETDEV/forwarding&lt;br /&gt;
	start-stop-daemon -K -p &amp;quot;$RUNFILE&amp;quot; -x /usr/sbin/dnsmasq&lt;br /&gt;
	/usr/sbin/iptables -t nat -D POSTROUTING -o $INETDEV -j MASQUERADE&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
exit 0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Set MSN (pecan) to stay offline when disconnected ===&lt;br /&gt;
&lt;br /&gt;
Since MSN allows only one client connection at a time, signing into MSN from the N900 disconnects it on my desktop PC, and vice versa. &lt;br /&gt;
&lt;br /&gt;
Pidgin on my desktop PC handles this gracefully by disabling the account until I manually connect it. msn-pecan, on the other hand, helpfully auto-reconnects on its own authority and fails to respect my disabling auto-connect via mc-tool; if the requested status remains as &amp;quot;available&amp;quot;, it reconnects, and that disconnects Pidgin on my desktop again. Grr. &lt;br /&gt;
&lt;br /&gt;
You need an instance of dbus-scripts &#039;&#039;&#039;on the session bus&#039;&#039;&#039; for this one (see above), then you can do the following:&lt;br /&gt;
&lt;br /&gt;
==== /etc/dbus-scripts.d/dbus-scripts-settings ====&lt;br /&gt;
&amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#:MSN (pecan) disconnected (session bus)&lt;br /&gt;
/usr/bin/offmsn * * org.freedesktop.DBus ReleaseName org.freedesktop.Telepathy.Connection.pecan.msn_pecan.*&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
==== /usr/bin/offmsn ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
# If we got disconnected from MSN (eg by signing in via Pidgin on desktop PC) then set it offline until further notice&lt;br /&gt;
mc-tool list | grep &amp;quot;pecan/msn&amp;quot; | awk {&#039;print &amp;quot;mc-tool request &amp;quot;$1&amp;quot; offline&amp;quot;&#039;} | sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Links to other scripts ==&lt;br /&gt;
&lt;br /&gt;
=== automatically register on public wifi network when connected ===&lt;br /&gt;
&lt;br /&gt;
You can find a script [http://talk.maemo.org/showpost.php?p=555757&amp;amp;postcount=6 in this post on tmo]&lt;br /&gt;
&lt;br /&gt;
== Thanks ==&lt;br /&gt;
&lt;br /&gt;
Thanks to Graham Cobb for dbus-scripts and Matan for dbus-scripts-settings&lt;br /&gt;
&lt;br /&gt;
[[Category:Software]]&lt;br /&gt;
[[Category:Power users]]&lt;/div&gt;</summary>
		<author><name>213.240.181.249</name></author>
	</entry>
	<entry>
		<id>https://maemo.octonezd.me/index.php?title=LED_patterns&amp;diff=14107</id>
		<title>LED patterns</title>
		<link rel="alternate" type="text/html" href="https://maemo.octonezd.me/index.php?title=LED_patterns&amp;diff=14107"/>
		<updated>2010-02-20T19:09:31Z</updated>

		<summary type="html">&lt;p&gt;213.240.181.249: /* Community-Made Patterns */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== N800 ==&lt;br /&gt;
&lt;br /&gt;
The N800 has a single-colour (blue) LED behind the dpad.&lt;br /&gt;
&lt;br /&gt;
== N810 ==&lt;br /&gt;
&lt;br /&gt;
The N810 has an RGB LED.&lt;br /&gt;
&lt;br /&gt;
== N900 ==&lt;br /&gt;
&lt;br /&gt;
=== File Location ===&lt;br /&gt;
&lt;br /&gt;
The file defining patterns can be found in&lt;br /&gt;
 /etc/mce/mce.ini&lt;br /&gt;
&lt;br /&gt;
An application ([http://talk.maemo.org/showthread.php?t=27818 mcedit]) for modifying LED patterns was written for the n8x0, but this will not work with the n900 due to the new mce.ini format.&lt;br /&gt;
&lt;br /&gt;
=== Pattern Format ===&lt;br /&gt;
The patterns are broken down as follows:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;tt&amp;gt;PatternName=Priority;ScreenOn;Timeout;LEDsToMap;Engine1Pattern;Engine2Pattern&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Priority ====&lt;br /&gt;
&lt;br /&gt;
0-255, 0 is highest, 255 is lowest.&lt;br /&gt;
&lt;br /&gt;
Since currently only a single pattern at a time can be displayed, this is used to assign importance to the LED patterns. Although only a single LED pattern can be displayed at any time, multiple patterns may be active, the pattern with the highest priority being displayed.&lt;br /&gt;
&lt;br /&gt;
A common example of this is where the n900 is on charge, the battery is full (starting PatternBatteryFull with a priority of 40), and an SMS message is received (PatternCommunicationSMS with a priority of 30). On receipt of the SMS, the LED begins to display the flashing blue led of an SMS. Once that SMS has been dismissed, the green LED of the full battery notification is again displayed.&lt;br /&gt;
&lt;br /&gt;
==== ScreenOn ====&lt;br /&gt;
&lt;br /&gt;
* 0: only show pattern when the display is off&lt;br /&gt;
* 1: show pattern even when the display is on&lt;br /&gt;
* 2: only show pattern when the display is off, including acting dead&lt;br /&gt;
* 3: show pattern even when the display is on, including acting dead&lt;br /&gt;
* 4: only show pattern if the display is off, or if in acting dead&lt;br /&gt;
* 5: always show pattern, even if LED disabled&lt;br /&gt;
&lt;br /&gt;
==== TimeOut ====&lt;br /&gt;
&lt;br /&gt;
This is the time-out of the LED pattern in seconds. 0 for infinite, i.e. until the notification is dismissed.&lt;br /&gt;
&lt;br /&gt;
If this is set to 20, the pattern will display for 20 seconds, and then stop.&lt;br /&gt;
&lt;br /&gt;
==== LEDsToMap ====&lt;br /&gt;
&lt;br /&gt;
There are two engines that can be used to make custom LED patterns.&amp;lt;ref name=&amp;quot;engines&amp;quot;&amp;gt;Actually there are three, but the third engine is used exclusively for the keyboard LED.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
r, g, or b maps the corresponding colour channel to Engine 1.&lt;br /&gt;
&lt;br /&gt;
R, G, or B maps the corresponding colour channel to Engine 2.&lt;br /&gt;
&lt;br /&gt;
For example, &amp;quot;rG&amp;quot; maps the red channel to Engine 1, and the green channel to Engine 2.&lt;br /&gt;
&lt;br /&gt;
You should avoid mapping the same channel to both engines, for example &amp;quot;rR&amp;quot;, &amp;quot;gG&amp;quot; or &amp;quot;bB&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Engine Pattern ====&lt;br /&gt;
&lt;br /&gt;
This is a series of text that describes the speed and intensity of changes in the LED(s) beign managed by that particular engine. See below for a breakdown of the patterns. Each can be at most 16 commands long.&lt;br /&gt;
&lt;br /&gt;
=== Lysti Format Engine Patterns and Commands ===&lt;br /&gt;
&lt;br /&gt;
The LED patterns are of the form&lt;br /&gt;
:&amp;lt;tt&amp;gt;9d8040007f007f0040ff7f007f000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Breaking this down for ease of reading we get a list of 8 commands, each of which is four characters long.&lt;br /&gt;
:&amp;lt;tt&amp;gt;9d80 4000 7f00 7f00 40ff 7f00 7f00 0000&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== 9d80 - Refresh Engine Multiplexor ====&lt;br /&gt;
&lt;br /&gt;
This is to be used as the first command of every pattern). If this is excluded from the pattern, the led won&#039;t flash.&lt;br /&gt;
&lt;br /&gt;
==== 40xx - Set channel brightness ====&lt;br /&gt;
&lt;br /&gt;
Where xx are two hexadecimal digits, e.g. 00 (for a brightness of 0) or ff (for a brightness of 255).&lt;br /&gt;
&lt;br /&gt;
==== xxyy - Adjust channel brightness ====&lt;br /&gt;
&lt;br /&gt;
Increment or decrement the channel brightness over a period of time (xx) and a number of steps (yy).&lt;br /&gt;
&lt;br /&gt;
Where xx and yy are hexadecimal digits&lt;br /&gt;
&lt;br /&gt;
xx - Time (per step?)&lt;br /&gt;
&lt;br /&gt;
yy - Number of steps&lt;br /&gt;
&lt;br /&gt;
The following rules apply to these:&lt;br /&gt;
* If xx is even, the steps are increment steps and brightness will increase.&lt;br /&gt;
* If xx is odd, the steps are decrement steps and brightness will decrease.&lt;br /&gt;
* If xx is between 02 and 3f, a short step time is used (granularity 0.49ms)&lt;br /&gt;
* If xx is between 42 and 7f, a long step time is used (granularity 15.6ms)&lt;br /&gt;
* yy can be any value between 00 and ff (0 to 255)&lt;br /&gt;
* Pauses can be achieved by using 00 steps, e.g. 7f00 where, where the 7f is how long each step takes and 00 is how many increment steps to take.&lt;br /&gt;
&lt;br /&gt;
The mce.ini instructions (/etc/mce/mce.ini) also state that &lt;br /&gt;
:Two consecutive increment/decrement sequences are needed to cover the entire range from 0-255&lt;br /&gt;
However I believe this is a throwback to the older patterns, and the full range of 00 to ff is available in a single step for the number of steps, since whether these are increment or decrement steps are now handled through use of even or odd xx values.&lt;br /&gt;
&lt;br /&gt;
==== 0000 - Jump to start ====&lt;br /&gt;
&lt;br /&gt;
Jump to the start of the pattern for this channel. You will see this at the end of most repeating patterns.&lt;br /&gt;
&lt;br /&gt;
This command may not actually be needed to make the pattern repeat. If this is removed, the pattern will repeat anyway, although it&#039;s useful to have it there as an explicit command to repeat for clarity. If you wanted a pattern to run once and then terminate you would use the c000 command.&lt;br /&gt;
&lt;br /&gt;
==== c000 - End pattern execution ====&lt;br /&gt;
&lt;br /&gt;
The pattern is terminated without repeating. It is important to note here that although that pattern has stopped, it is still active until the Timeout time has passed. As a consequence of this any higher priority patterns (patterns with a lower priority value, since 0 is the highest and 255 is the lowest) will not be displayed until the pattern has fully expired. In the case that the timeout is 0, it will not display until the notification is dismissed.&lt;br /&gt;
&lt;br /&gt;
==== Sending and receiving engine triggers ====&lt;br /&gt;
&lt;br /&gt;
Further complexity in patterns can be added through use of triggers. This is especially useful if we want to synchronise the two engines in time, for example to wait until the LED has turned red before turning it immediately to green. Rather than waste time with steps doing nothing, we can simply wait for a trigger to be received from the other engine.&lt;br /&gt;
&lt;br /&gt;
The following pattern does exactly that:&lt;br /&gt;
:&amp;lt;tt&amp;gt;PatternTest=29;1;0;rG;9d80400008ffe0044000c000;9d80e08040ffc000&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== e002, e004, e008 - Send engine trigger =====&lt;br /&gt;
&lt;br /&gt;
e002 - Send trigger to engine 1&lt;br /&gt;
&lt;br /&gt;
e004 - Send trigger to engine 2&lt;br /&gt;
&lt;br /&gt;
e008 - Send trigger to engine 3 (used by keyboard backlight)&lt;br /&gt;
&lt;br /&gt;
A signal is sent from the current engine to signal another engine.&lt;br /&gt;
&lt;br /&gt;
Although the trigger information for engine 3 is listed we have no control over the keyboard LED, so it has no effect. Attempting to add a pattern for engine 3 after the pattern for engine 2 causes the pattern to no longer function.&lt;br /&gt;
&lt;br /&gt;
===== e080, e100, e200 - Wait for engine trigger =====&lt;br /&gt;
&lt;br /&gt;
e080 - Wait for trigger from engine 1&lt;br /&gt;
&lt;br /&gt;
e100 - Wait for trigger from engine 2&lt;br /&gt;
&lt;br /&gt;
e200 - Wait for trigger from engine 3 (used by keyboard backlight)&lt;br /&gt;
&lt;br /&gt;
Although the trigger information for engine 3 is listed we have no control over the keyboard LED, so it has no effect. Attempting to add a pattern for engine 3 after the pattern for engine 2 causes the pattern to no longer function.&lt;br /&gt;
&lt;br /&gt;
=== Default LED Patterns for Nokia N900 ===&lt;br /&gt;
&lt;br /&gt;
 PatternError=0;5;0;r;9d8040007f007f0040ff7f007f000000;9d800000&lt;br /&gt;
 PatternDeviceOn=254;0;0;rgb;9d804000422043207f100000;9d800000&lt;br /&gt;
 PatternDeviceSoftOff=253;0;0;rg;9d804000423f433f7f100000;9d800000&lt;br /&gt;
 PatternPowerOn=9;3;0;rgb;9d80400042ff02ffc000;9d800000&lt;br /&gt;
 PatternPowerOff=10;3;0;rgb;9d80400001ff43ff7f007f00c000;9d800000&lt;br /&gt;
 PatternCommunicationCall=30;1;0;b;9d80400002ff03ff02ff03ff71080000;9d800000&lt;br /&gt;
 PatternCommunicationIM=30;1;0;b;9d80400002ff03ff02ff03ff71080000;9d800000&lt;br /&gt;
 PatternCommunicationSMS=30;1;0;b;9d80400002ff03ff02ff03ff71080000;9d800000&lt;br /&gt;
 PatternCommunicationEmail=30;1;0;b;9d80400002ff03ff02ff03ff71080000;9d800000&lt;br /&gt;
 PatternCommonNotification=30;1;0;b;9d80400002ff03ff02ff03ff71080000;9d800000&lt;br /&gt;
 PatternWebcamActive=20;1;0;r;9d80400004ffc0000000;9d800000&lt;br /&gt;
 PatternBatteryCharging=50;4;0;rg;9d804000427f0d7f7f007f0042000000;9d800000&lt;br /&gt;
 PatternBatteryFull=40;4;0;g;9d80407f0000;9d800000&lt;br /&gt;
&lt;br /&gt;
=== Community-Made Patterns ===&lt;br /&gt;
&#039;&#039;Please note that these patterns should all be on one line.&#039;&#039;&lt;br /&gt;
&#039;&#039;They can also be used for any notification.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
A traffic-light battery charging pattern, courtesy of [http://talk.maemo.org/showthread.php?p=512430#post512430 blue_led]&lt;br /&gt;
 PatternBatteryCharging=50;4;0;Rg;9d80407f7f00e0047f0040007f007f007f00407f7f00e0047f007f000000;9d804000e080407fe0800000&lt;br /&gt;
&lt;br /&gt;
A police-siren style pattern, idea by [http://talk.maemo.org/showthread.php?p=499305#post499305 mihapodb].&lt;br /&gt;
 PatternCommunicationEmail=30;1;0;rB;9d8040ff7f00e00440007f000000;9d80e08040ff7f0040000000&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Cehteh&#039;s patterns with some comments&lt;br /&gt;
&lt;br /&gt;
Slow dark glowing in cyan, never goes fully off, so you can locate the device in the dark:&lt;br /&gt;
 PatternDeviceOn=254;0;0;gb;9d804001620863087f007f007f007f007f007f007f007f007f007f007f000000;9d800000&lt;br /&gt;
&lt;br /&gt;
Similar to the above but gets brighter in yellow:&lt;br /&gt;
 PatternBatteryCharging=50;3;0;rg;9d804001427f0d7f7f007f0042000000;9d800000&lt;br /&gt;
&lt;br /&gt;
Same as PatternDeviceOn, but white:&lt;br /&gt;
 PatternBatteryFull=40;3;0;rgb;9d804001620863087f007f007f007f007f007f007f007f007f007f007f000000;9d800000&lt;br /&gt;
&lt;br /&gt;
White, bright flashing, must be enabled in &#039;LEDPatterns=&#039;:&lt;br /&gt;
 PatternExample=42;1;30;rgb;9d8040007f007f0040ff42000000;9d800000&lt;br /&gt;
&lt;br /&gt;
=== Step by step instructions ===&lt;br /&gt;
&lt;br /&gt;
* Open terminal&lt;br /&gt;
* Gain [[Root access]]&lt;br /&gt;
* Make a backup (not necessary!) from original mce.ini -file, for example:&lt;br /&gt;
 cp /etc/mce/mce.ini /etc/mce/mce.ini_old&lt;br /&gt;
* Open /etc/mce/mce.ini with a text editor (nano, vim, leafpad...)&lt;br /&gt;
* Search for a line:&lt;br /&gt;
 [LEDPatternLystiRX51]&lt;br /&gt;
* Make your changes to the lines below&lt;br /&gt;
* Save&lt;br /&gt;
* Restart mce -process. Either reboot or type to terminal:&lt;br /&gt;
 initctl stop mce; sleep 2; initctl start mce&lt;br /&gt;
&lt;br /&gt;
Please note: restarting mce several times in 2 minutes will cause the n900 to think there is a problem with mce, and not restart it. The initctl program will inform you of this. When it does, simply wait a while before trying again.&lt;br /&gt;
&lt;br /&gt;
=== Low Level ===&lt;br /&gt;
&lt;br /&gt;
The N900 has a LP5521&amp;lt;ref name=&amp;quot;lp5521-spec&amp;quot;&amp;gt;http://www.national.com/pf/LP/LP5521.html&amp;lt;/ref&amp;gt;  &amp;lt;ref name=&amp;quot;lp5521-driver&amp;quot;&amp;gt;http://mxr.maemo.org/fremantle/source/kernel/drivers/i2c/chips/lp5521.c&amp;lt;/ref&amp;gt; programmable three channel controller LED Driver which handles the leds.&lt;br /&gt;
(actually it has a LP5523 it seems &amp;lt;ref name=&amp;quot;lp5523-spec&amp;quot;&amp;gt;http://www.national.com/pf/LP/LP5523.html&amp;lt;/ref&amp;gt; &amp;lt;ref name=&amp;quot;leds-lp5523-driver&amp;quot;&amp;gt;http://mxr.maemo.org/fremantle/source/kernel/drivers/leds/leds-lp5523.c&amp;lt;/ref&amp;gt;, which has 3 engines like LP5521 but can drive 9 LEDs via a multiplexer)&lt;br /&gt;
&lt;br /&gt;
The controller can be programmed via &amp;quot;/sys/class/i2c-adapter/i2c-2/2-0032&amp;quot; (FIXME: is this stable?). In that directory there are three files corresponding to the three channels: engine1_mode, engine2_mode and engine3_mode. Each file &amp;quot;stores&amp;quot; one of &amp;quot;run&amp;quot;, &amp;quot;load&amp;quot;, &amp;quot;disabled&amp;quot; (it seems that there is another mode &amp;quot;direct&amp;quot; but it doesn&#039;t work):&lt;br /&gt;
* run: The program runs&lt;br /&gt;
* disabled: The channel is disabled - not running&lt;br /&gt;
* load: In that state, there are two more files in that directory: &lt;br /&gt;
** engine1_leds is in the form &amp;quot;0000rgb00&amp;quot; (9 digits), where rgb control which leds should participate&lt;br /&gt;
** engine1_load accepts a string as specified above (e.g. 9d804000427f0d7f7f007f0042000000).&lt;br /&gt;
After that, when the state is changed to &amp;quot;run&amp;quot;, the program will be ran by the controller. &lt;br /&gt;
&lt;br /&gt;
In order for the leds to work, the led_current of the appropriate leds need to be set to non-zero values. This is accomplished by writing to files leds:lp5523:[bgr]/led_current under the same directory. Perhaps (?) not or values are suitable.&lt;br /&gt;
&lt;br /&gt;
NOTE: There must be a delay (how much? The specs of LP5521 mentions it) between writes to sysfs files.&lt;br /&gt;
&lt;br /&gt;
{{Reflist}}&lt;br /&gt;
&lt;br /&gt;
[[Category:N900 Hardware]]&lt;br /&gt;
[[Category:Power users]]&lt;/div&gt;</summary>
		<author><name>213.240.181.249</name></author>
	</entry>
</feed>