Phone control

This page is about controlling your Nokia device. For historical reasons this page is called phone control even though it really covers more than just the phone functions.

Please be aware that the recommended way to use the phone functionality is Telepathy:


[edit] D-Bus

These D-Bus commands can be run from terminal or as shell scripts. Useful for scheduling events with alarmed or fcron, executing from Desktop Command Execution Widget or Queen BeeCon Widget, startup events, install scripts, etc. They should be run as: dbus-send COMMAND

This is important to set up the environment correctly otherwise they may barf. If run as user "user" this is not needed.

Also note that most commands don't need "--print-reply" option. Those that don't need it should be tested without it and this page should be edited.

[edit] Phone

[edit] Open Phone application

dbus-send --type=method_call /com/nokia/HildonDesktop/AppMgr string:"rtcom-call-ui"

[edit] Make a phone call

dbus-send --system --type=method_call --print-reply /com/nokia/csd/call string:"$NUMBER" uint32:0

Change $NUMBER to phone number you want to call.

[edit] End current phone call

dbus-send --system --print-reply /com/nokia/csd/call

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.

[edit] Answer current phone call

dbus-send --system --print-reply /com/nokia/csd/call/1

This will answer/pickup the current (first) call.

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 exception.

You need to answer the call after a delay of e.g. 1 s.

Another (probably better) approach is to register to the CallStatus D-Bus message (, /com/nokia/csd/call/1, and wait for a call status >= 2 (=CSD_CALL_STATUS_COMING) after the "Coming" message.

[edit] Call "starhash code"

For example *100#.

dbus-send --system --type=method_call /com/nokia/CallUI string:"*100#"

[edit] Activate call forwarding

Forward all ('unconditional') calls to e.g. +12223456789

dbus-send --system --type=method_call --print-reply /com/nokia/csd/ss uint32:0 string:"+12223456789" uint32:


dbus-send --system --type=method_call --print-reply /com/nokia/csd/ss uint32:1 string:"+12223456789" uint32:

Forward calls when 'busy' to e.g. +12223456789

dbus-send --system --type=method_call --print-reply /com/nokia/csd/ss uint32:2 string:"+12223456789" uint32:

Forward unanswered calls to e.g. +12223456789 (leaving the last uint32: empty will use the last stored waiting time)

dbus-send --system --type=method_call --print-reply /com/nokia/csd/ss uint32:3 string:"+12223456789" uint32:

Forward unanswered calls, when 'no answer' after 25 sec to e.g. +12223456789 (if you want to set this value explicitly; valid values: 5, 10, 15, 20, 25, 30)

dbus-send --system --type=method_call --print-reply /com/nokia/csd/ss uint32:3 string:"+12223456789" uint32:25

Forward calls when you are 'out of reach' (no network, shut off, ...) to e.g. +12223456789

dbus-send --system --type=method_call --print-reply /com/nokia/csd/ss uint32:4 string:"+12223456789" uint32:

Forward calls when 'not available' (busy, no answer, out of reach) to e.g. +12223456789

dbus-send --system --type=method_call --print-reply /com/nokia/csd/ss uint32:5 string:"+12223456789" uint32:

--peterleinchen 23:00, 15 December 2011 (UTC)

many thanks to the pre-contributor (I have searched for a long time to have the possibility to switch forwarding script based)

[edit] Cancel call forwarding

dbus-send --system --type=method_call --print-reply
/com/nokia/csd/ss uint32:x string: uint32:

Valid values for "x", pls see also above. 0 unconditional

1 unconditional

2 busy

3 no answer (after xx sec)

4 out of reach

5 not available (busy, no answer, out of reach)

--peterleinchen 23:00, 15 December 2011 (UTC)

[edit] Get IMEI

dbus-send --system --type=method_call --print-reply /com/nokia/phone/SIM/security Phone.Sim.Security.get_imei|awk -F "\"" '/g/ {print $2}'

[edit] Get IMSI

dbus-send --system --type=method_call --print-reply /com/nokia/phone/SIM Phone.Sim.get_imsi|awk -F "\"" '/g/ {print $2}'

[edit] Get ICCID

dbus-send --system --type=method_call --print-reply /com/nokia/phone/SSC|awk -F "\"" '/g/ {print $2}'

[edit] Get SIM status

dbus-send --system --print-reply /com/nokia/phone/SIM Phone.Sim.get_sim_status

[edit] Get cellular signal strength

dbus-send --system --print-reply /com/nokia/phone/net Phone.Net.get_signal_strength

First line is percentage, second is dBm, third unknown.

[edit] Get cellular registration status

dbus-send --system --print-reply /com/nokia/phone/net Phone.Net.get_registration_status

[edit] Turn loudspeaker on

dbus-send --type=method_call /com/nokia/osso_hp_ls_controller

(These loudspeaker ones don't work on my N900. If I add --print-reply I get "Error org.freedesktop.DBus.Error.ServiceUnknown: The name was not provided by any .service files".)

[edit] Turn loudspeaker off

dbus-send --type=method_call /com/nokia/osso_hp_ls_controller

[edit] Turn loudspeaker on (N900)

dbus-send --type=method_call --dest=org.maemo.Playback.Manager /org/maemo/Playback/Manager org.maemo.Playback.Manager.RequestPrivacyOverride boolean:true

[edit] Turn loudspeaker off (N900)

dbus-send --type=method_call --dest=org.maemo.Playback.Manager /org/maemo/Playback/Manager org.maemo.Playback.Manager.RequestPrivacyOverride boolean:false

[edit] Turn mute on (N900)

dbus-send --type=method_call --dest=org.maemo.Playback.Manager /org/maemo/Playback/Manager org.maemo.Playback.Manager.RequestMute boolean:true

[edit] Turn mute off (N900)

dbus-send --type=method_call --dest=org.maemo.Playback.Manager /org/maemo/Playback/Manager org.maemo.Playback.Manager.RequestMute boolean:false

[edit] Turn bluetooth override on (N900)

dbus-send --type=method_call --dest=org.maemo.Playback.Manager /org/maemo/Playback/Manager org.maemo.Playback.Manager.RequestBluetoothOverride boolean:true

[edit] Turn bluetooth override off (N900)

dbus-send --type=method_call --dest=org.maemo.Playback.Manager /org/maemo/Playback/Manager org.maemo.Playback.Manager.RequestBluetoothOverride boolean:false

[edit] Start Vibrating Incoming Call

dbus-send --system --print-reply /com/nokia/mce/request string:PatternIncomingCall

PatternXXX according to definition in /etc/mce/mce.ini

[edit] Stop Vibrating Incoming Call

dbus-send --system --print-reply /com/nokia/mce/request string:PatternIncomingCall

[edit] Vibration Single Shot

dbus-send --system --print-reply /com/nokia/mce/request int32:255 int32:1000

First int is power, second is duration in milliseconds

[edit] Profiles

[edit] Set General

dbus-send --type=method_call /com/nokia/profiled string:"general"

[edit] Set Silent

dbus-send --type=method_call /com/nokia/profiled string:"silent"

[edit] Query current profile

dbus-send --type=method_call --print-reply /com/nokia/profiled

[edit] List all profiles

dbus-send --type=method_call --print-reply /com/nokia/profiled|awk -F "\"" '/g/ {print $2}'

[edit] Get all profile Values

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 "silent" just put "silent" at the end instead of "general".)

dbus-send --type=method_call --print-reply /com/nokia/profiled string:"general"

The returned value is an array of struct. Each struct has 3 strings: key, value, type. Type can be eg. "INTEGER 0-2" saying that the values 0, 1 and 2 are correct values for this key.

[edit] Set a profile value

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 "general" or "silent", key is one of the keys from the above (get all profile values), value can be set to anything allowed by "type" from the above method.

To enable vibrating alert for the profile "general" your script would look like this:

dbus-send --type=method_call /com/nokia/profiled string:"general" string:"vibrating.alert.enabled" string:"On"

[edit] LED

[edit] Activate LEDs

dbus-send --system --type=method_call /com/nokia/mce/request string:"PatternCommunicationIM"

[edit] Deactivate LEDs

dbus-send --system --type=method_call /com/nokia/mce/request string:"PatternCommunicationIM"

[edit] Set brightness of backlight LEDs

dbus-send --print-reply --system --dest=org.freedesktop.Hal /org/freedesktop/Hal/devices/computer_backlight org.freedesktop.Hal.Device.LaptopPanel.SetBrightness int32:$brightness

(where $brightness is 0...255)

[edit] Messaging

[edit] New e-mail

dbus-send --type=method_call /com/nokia/modest string:"mailto:"

[edit] Send and receive e-mail

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.

dbus-send --type=method_call /com/nokia/modest

[edit] Set presence

dbus-send --type=method_call --print-reply --dest=org.freedesktop.Telepathy.MissionControl /org/freedesktop/Telepathy/MissionControl org.freedesktop.Telepathy.MissionControl.SetPresence uint32:2 string:"I'm here"

Note: This method does not work in Maemo 5. Workaround:

[edit] Change peak_schedule settings

Check: gconftool-2 -R /apps/activesync

Set (check if yours is named ActiveSyncAccount1): gconftool-2 --set /apps/activesync/ActiveSyncAccount1/schedule/peak_schedule --type=int 15

Where the last number is one of the following (as standard in GUI):

  • 0 = Always on
  • -1 = Manual
  • 15 = Every 15 minutes
  • 30 = Every 30 minutes
  • 60 = Every hour
  • 240 = Every 4 hours
  • 720 = Every 12 hours

[edit] Media player

[edit] Open file in media player

dbus-send --print-reply /com/nokia/mediaplayer string:"file:///$1"

[edit] Pause what's currently playing

dbus-send /com/nokia/mafw/renderer/gstrenderer

[edit] Stop what's currently playing

dbus-send /com/nokia/mafw/renderer/gstrenderer

[edit] Play what's currently selected

dbus-send /com/nokia/mafw/renderer/gstrenderer

[edit] Unpause what's currently selected

dbus-send /com/nokia/mafw/renderer/gstrenderer

[edit] Play next mediafile

dbus-send /com/nokia/mafw/renderer/gstrenderer

[edit] Play previous mediafile

dbus-send /com/nokia/mafw/renderer/gstrenderer

[edit] Notifications

[edit] Send notification (orange one line popup)

dbus-send --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteInfoprint string:"NOTIFICATION"

[edit] Send notification (orange multiple line popup)

dbus-send --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteInfoprint string:"NOTE line 1
line 2
. . .
line n"

--peterleinchen 00:22, 4 January 2012 (UTC)

[edit] Send dialog notification (orange multi line popup, requiring user interaction)

dbus-send --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteDialog string:"QUESTION?" uint32:0 string:"OK"

Not sure what string "OK" does, but it is needed and can be anything.

It does nothing here and is not explicitly needed, pls. see below command and also section.

dbus-send --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteDialog string:"QUESTION?" uint32: string:

[edit] Send dialog notification (black/white with floating bar and confirmation button, requiring user action)

dbus-send --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteDialog string:"QUESTION?" uint32:4 string:"OK"

String "OK" is the text for the button. --peterleinchen 21:29, 3 January 2012 (UTC)

[edit] Send email/SMS style notification


[edit] Securing

[edit] Security Device Lock (with lockcode)

dbus-send --system --type=method_call /com/nokia/system_ui/request string:"" string:"/com/nokia/mce/request" string:"" string:"devlock_callback" uint32:'3'

The next method is a 2nd - surprisingly shorter - way to enter device lock mode. Its benefit is that it even disables the device power button menu:

dbus-send --system --type=method_call /com/nokia/mce/request int32:0

[edit] Unlock (pop up lockcode requester?)

dbus-send --system --type=method_call /com/nokia/system_ui/request string:"" string:"/com/nokia/mce/request" string:"" string:"devlock_callback" uint32:'0'

Next method is a 2nd, more direct way to stop device lock mode.

dbus-send --system --type=method_call /com/nokia/mce/request int32:2

[edit] Query Devlock State

 dbus-send --system --type=method_call --dest="" --print-reply "/com/nokia/mce/request" |awk -F "\"" '/g/ {print $2}'

[edit] Lock screen and keys (slider lockswitch)

dbus-send --system --type=method_call /com/nokia/mce/request string:"locked"

[edit] Unlock screen and keys

This command will unlock and illuminate the screen (useful when accessing the phone externally through PuTTY)

dbus-send --system --type=method_call /com/nokia/mce/request string:"unlocked"

[edit] Query lock state of screen and keys

Will return locked or unlocked depending on lock state

dbus-send --system --type=method_call --dest="" --print-reply "/com/nokia/mce/request"|awk -F "\"" '/g/ {print $2}'

[edit] Networking

[edit] Enable ICD log

There are two methods to enable ICD logs

1. Print to the syslog:

  (1)Use the following cmd 
  (2)$ syslogd
  (3)$ icd2 –l0
  (4)The log will print to the /var/log/syslog

2. Print to the standard output

  (1)Get the source code of icd2
  (2)Add the begging of source code of “support/osso-log.h” "#define OSSOLOG_STDOUT"
  (3)$ icd2 –l0
  (4)The log will print to the standard output

[edit] Connect to specific saved connection

dbus-send --system --type=method_call /com/nokia/icd string:"IAP_ID" uint32:0

IAP_ID is internet access point identifier and can be obtained with the following command:

gconftool -R /system/osso/connectivity/IAP

Find lines which matches /system/osso/connectivity/IAP/<IAP_ID>

For GPRS connections replace "@32@" with a space in IAP_ID string.

Keep in mind that phone has to be disconnected in order to connect via this call. If not, an error message will occur if you add --print-reply to the dbus-send command.

[edit] Connect to any saved connection

dbus-send --system --type=method_call /com/nokia/icd string:"[ANY]" uint32:0

[edit] Disconnect internet

[edit] ICD2
dbus-send --print-reply --system /com/nokia/icd2 uint32:0x8000
[edit] ICD
dbus-send --system /com/nokia/icd_ui boolean:true

On PR1.2 : Error org.freedesktop.DBus.Error.UnknownMethod: Method "disconnect" with signature "b" on interface "" doesn't exist

[edit] Connect (show change connection UI)

dbus-send --system --type=method_call /com/nokia/icd_ui boolean:false

If "boolean:true" at the end, one-line notification saying "No saved connections available" 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.

[edit] Enable cellular radio

dbus-send --system --type=method_call /com/nokia/phone/SSC boolean:true

[edit] Disable cellular radio

dbus-send --system --type=method_call /com/nokia/phone/SSC boolean:false

[edit] Change device mode

String possibility "offline","flight","normal"

dbus-send --system --type=method_call /com/nokia/mce/request string:offline

[edit] Query device mode

dbus-send --system --type=method_call --print-reply /com/nokia/mce/request | awk -F "\"" '/g/ {print $2}'

[edit] Radio mode

[edit] Current Mode

dbus-send --system --print-reply /com/nokia/phone/net Phone.Net.get_radio_access_technology

[edit] 2G

dbus-send --system --type=method_call /com/nokia/phone/net Phone.Net.set_selected_radio_access_technology byte:1

[edit] 3G

dbus-send --system --type=method_call /com/nokia/phone/net Phone.Net.set_selected_radio_access_technology byte:2

[edit] Dual

dbus-send --system --type=method_call /com/nokia/phone/net Phone.Net.set_selected_radio_access_technology byte:0

[edit] Bluetooth

[edit] Identify adapter path

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:

dbus-send --system --print-reply --dest=org.bluez / org.bluez.Manager.ListAdapters | awk -F'"' '/at/ {print $2}'


dbus-send --system --print-reply --dest=org.bluez / org.bluez.Manager.DefaultAdapter | awk -F'"' '/at/ {print $2}'

[edit] Identify Properties

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'"' '/at/ {print $2}') org.bluez.Adapter.GetProperties

[edit] Enable

Using the adapter path value returned with first command, for example /org/bluez/906/hci0.

dbus-send --system --type=method_call --dest=org.bluez /org/bluez/906/hci0 org.bluez.Adapter.SetProperty string:Powered variant:boolean:true

This one automatically inserts adapter path:

dbus-send --system --type=method_call --dest=org.bluez $(dbus-send --system --print-reply --dest=org.bluez / org.bluez.Manager.DefaultAdapter | awk -F'"' '/at/ {print $2}') org.bluez.Adapter.SetProperty string:Powered variant:boolean:true

[edit] Disable

dbus-send --system --type=method_call --dest=org.bluez /org/bluez/906/hci0 org.bluez.Adapter.SetProperty string:Powered variant:boolean:false

With auto-discovery of adapter path:

dbus-send --system --type=method_call --dest=org.bluez $(dbus-send --system --print-reply --dest=org.bluez / org.bluez.Manager.DefaultAdapter | awk -F'"' '/at/ {print $2}') org.bluez.Adapter.SetProperty string:Powered variant:boolean:false

[edit] Connect to specific device


adapter=$(dbus-send --system --print-reply --dest=org.bluez / org.bluez.Manager.DefaultAdapter | awk -F'"' '/at/ {print $2}')
device=$(dbus-send --system --print-reply --dest=org.bluez ${adapter} org.bluez.Adapter.FindDevice string:${devmac} | awk -F'"' '/at/ {print $2}')
dbus-send --system --type=method_call --print-reply --dest=org.bluez ${device} org.bluez.${service}.Connect

Change the AudioSink to any service and the devmac to the MAC of bluetooth device.

[edit] Check for updates

dbus-send --type=method_call /com/nokia/hildon_application_manager

[edit] Open link in browser

dbus-send --system --type=method_call /com/nokia/osso_browser/request string:""

[edit] Open a pdf file with the default pdf reader application

dbus-send --print-reply /com/nokia/osso_pdfviewer string:/home/user/MyDocs/.documents/file_name.pdf

[edit] Open a file with the default notes application

dbus-send --print-reply /com/nokia/osso_notes string:/home/user/MyDocs/.documents/file_name

[edit] Open the default notes application

dbus-send --print-reply /com/nokia/osso_notes

[edit] Open folder

dbus-send --print-reply /com/nokia/osso_filemanager string:/home/user/MyDocs/

[edit] Set volume

dbus-send --type=method_call /com/nokia/mafw/renderer/gstrenderer string:volume variant:uint32:50

The value can be between 0 and 100.

[edit] Get volume

dbus-send --print-reply --type=method_call /com/nokia/mafw/renderer/gstrenderer string:volume|awk '/nt/ {print $3}'

[edit] Reboot

dbus-send --system --type=method_call --print-reply "/com/nokia/mce/request"

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 "reboot" in root terminal.

[edit] Shutdown

dbus-send --system --type=method_call --print-reply "/com/nokia/mce/request"

See warning at reboot D-Bus call (needs testing).

[edit] Show dashboard

dbus-send /com/nokia/hildon_desktop

[edit] Other

[edit] D-Bus Scripts

You can also use dbus-scripts to execute any command when various actions are triggered on D-Bus.

[edit] Panucci (pause)

dbus-send --type=method_call --dest=org.panucci.panucciInterface /panucciInterface org.panucci.panucciInterface.playPause

[edit] Device Orientation

dbus-send --system --print-reply /com/nokia/mce/request

[edit] GConf

[edit] Reset GPRS data counter

The commands are PR1.2 compliant and do not work on previous versions.

gconftool-2 -u /system/osso/connectivity/network_type/GPRS/gprs_home_rx_bytes
gconftool-2 -u /system/osso/connectivity/network_type/GPRS/gprs_home_tx_bytes
gconftool-2 -s /system/osso/connectivity/network_type/GPRS/gprs_home_reset_time --type=string $(date +%s)

[edit] Command line

[edit] Enable FM Transmitter

/usr/bin/fmtx_client -p 1

[edit] Disable FM Transmitter

/usr/bin/fmtx_client -p 0

[edit] GStreamer

[edit] Take a picture with front camera

gst-launch v4l2src device=/dev/video1 num-buffers=1 ! ffmpegcolorspace ! jpegenc ! filesink location=frontcam.jpg

[edit] Shoot photo after 10 seconds

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)

/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

To shoot from the front camera, change /dev/video0 to /dev/video1 and the proper resolution:

/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

Other way:

/bin/sleep 10; /usr/bin/gst-launch v4l2camsrc ! ffmpegcolorspace ! jpegenc ! identity error-after=1 ! filesink location=/home/user/MyDocs/DCIM/photo.jpg

[edit] Python

[edit] Make a phone call via the cellular network

import dbus
def place_call(number):
  bus = dbus.SystemBus()
  csd_call = dbus.Interface(bus.get_object('',
  csd_call.CreateWith(str(number), dbus.UInt32(0))

[edit] Make a phone call via SIP

import dbus
import sys
# Get the target phone number (or SIP address) from the command line
TARGET = sys.argv[1];
# Configure the telepathy path to the SofiaSIP account that we wish to use.
# Use "mc-tool list" (from the libmissioncontrol-utils package) to see your accounts.
SIP_ACCOUNT = 'sofiasip/sip/_31234567_40sipgate_2eco_2euk0'
# This gets us a connnection to the session bus
bus = dbus.SessionBus()
# This sets up a path to the SIP account within telepathy.
PATH = '/org/freedesktop/Telepathy/Account/'
# This sets up a proxy object as a "handle" to the AccountManager of our target account
account = bus.get_object('org.freedesktop.Telepathy.AccountManager', PATH)
# This launches the actual SIP call with a method call to EnsureChannel on that object
account.EnsureChannel( \
                dbus.String(u'org.freedesktop.Telepathy.Channel.TargetHandleType'): dbus.UInt32(1),
                dbus.String(u'org.freedesktop.Telepathy.Channel.ChannelType'): dbus.String(u'org.freedesktop.Telepathy.Channel.Type.StreamedMedia'),
                dbus.String(u'org.freedesktop.Telepathy.Channel.TargetID'): dbus.String(TARGET),
        }, signature='sv'),

[edit] Send SMS using new QtMobility bindings by ossipena:

#!/usr/bin/env python
# -*- coding: utf-8 -*-
#ssms Ossipena/TimoP
#send smses from command line
#licence : Do whatever you want
from QtMobility.Messaging import *
from PySide.QtCore import *
import sys
from PyQt4 import QtCore
app = QCoreApplication(sys.argv)
'''get number and name'''
stringit = sys.argv
numpertemp = str(stringit[1:2])
mesits = str(stringit[2:])[2:-2]
num = str(numpertemp[2:-2])
if (mesits == ""):
  print "Usage:"
  print "python 01234567 'message text here'"
  print "number is " + str(num)
  print "message is " + str(mesits)
'''define message to be sent'''
numperi = QtCore.QString(num)
numper = QMessageAddress(QMessageAddress.Phone, numperi)
mesitsi = QMessage()
'''send message'''
sender = QMessageService()
if (sender.send(mesitsi)):
  print "success"
  print "fail"


#!/usr/bin/env python2.5
import pexpect
import time
from subprocess import *
child = pexpect.spawn('pnatd');

There's also a python script that uses D-Bus instead from

#!/usr/bin/env python2.5          
import sched, time                
import dbus                       
import gobject                    
from dbus.mainloop.glib import DBusGMainLoop
def octify(str):
        Returns a list of octet bytes representing
        each char of the input str.               
        bytes = map(ord, str)
        bitsconsumed = 0     
        referencebit = 7     
        octets = []          
        while len(bytes):
                byte = bytes.pop(0)
                byte = byte >> bitsconsumed
                        nextbyte = bytes[0]
                        bitstocopy = (nextbyte & (0xff >> referencebit)) << referencebit
                        octet = (byte | bitstocopy)                                     
                        octet = (byte | 0x00)
                if bitsconsumed != 7:
                        octets.append(byte | bitstocopy)
                        bitsconsumed += 1               
                        referencebit -= 1               
                        bitsconsumed = 0                
                        referencebit = 7                
        return octets
def semi_octify(str):
        Expects a string containing two digits.
        Returns an octet -                     
        first nibble in the octect is the first
        digit and the second nibble represents 
        the second digit.                      
                digit_1 = int(str[0])          
                digit_2 = int(str[1])          
                octet = (digit_2 << 4) | digit_1
                octet = (1 << 4) | digit_1      
        return octet
def deoctify(arr):
        referencebit = 1
        doctect = []    
        bnext = 0x00    
        for i in arr:
                bcurr = ((i & (0xff >> referencebit)) << referencebit) >> 1
                bcurr = bcurr | bnext                                      
                if referencebit != 7:
                        doctect.append( bcurr )
                        bnext = (i & (0xff << (8 - referencebit)) ) >> 8 - referencebit
                        referencebit += 1                                              
                        doctect.append( bcurr )                                        
                        bnext = (i & (0xff << (8 - referencebit)) ) >> 8 - referencebit
                        doctect.append( bnext )                                        
                        bnext = 0x00                                                   
                        referencebit = 1                                               
        return ''.join([chr(i) for i in doctect])
def createPDUmessage(number, msg):
        Returns a list of bytes to represent a valid PDU message
        numlength = len(number)                                 
        if (numlength % 2) == 0:                                
                rangelength = numlength                         
                number = number + 'F'                           
                rangelength = len(number)                       
        octifiednumber = [ semi_octify(number[i:i+2]) for i in range(0,rangelength,2) ]
        octifiedmsg = octify(msg)                                                      
        HEADER = 1                                                                     
        FIRSTOCTETOFSMSDELIVERMSG = 10                                                 
        ADDR_TYPE = 129 #unknown format                                                
        number_length = len(number)                                                    
        msg_length = len(msg)                                                          
        pdu_message = [HEADER, FIRSTOCTETOFSMSDELIVERMSG, number_length, ADDR_TYPE]    
        return pdu_message                                                             
def sendmessage(number, message):
        bus = dbus.SystemBus()
        smsobject = bus.get_object('', '/com/nokia/phone/SMS/ba212ae1')
        smsiface = dbus.Interface(smsobject, '')
        arr = dbus.Array(createPDUmessage(number.replace('+', '00'), message))
        msg = dbus.Array([arr])
def callback(pdumsg, msgcenter, somestring, sendernumber):
        msglength = int(pdumsg[18])
        msgarray = pdumsg[19:len(pdumsg)]
        msg = deoctify(msgarray)
        if msg > 0:
               print 'New message received from %s' % sendernumber
               print 'Message length %d' % msglength
               print 'Message: %s' % msg
               if msg == "ping":
                       print "Sending reply: pong"
                       sendmessage(sendernumber.replace("+","00"), "pong")
                       print "Unknown command"
def listen():
        bus = dbus.SystemBus() #should connect to system bus instead of session because the former is where the incoming signals come from
        bus.add_signal_receiver(callback, path='/com/nokia/phone/SMS', dbus_interface='Phone.SMS', signal_name='IncomingSegment')
if __name__ == '__main__':
  import time
  def schedule_task(schedule, fn, *args):
      import sched
      s = sched.scheduler(time.time, time.sleep)
      startTime = time.mktime(time.strptime(schedule, '%b %d %H:%M %Y'))
      s.enterabs(startTime, 0, fn, args)
  import getopt, sys
    opts, args = getopt.getopt(sys.argv[1:],"hlt:", ["help","listen","time="])
  except getopt.GetoptError, err:
    # print help information and exit:
    print str(err) # will print something like "option -a not recognized"
  listening = False 
  timeofday = ''
  for opt, arg in opts:
    if opt in ("-h", "--help"):
    elif opt in ("-l", "--listen"):
      listening = True                 
    elif opt in ("-t", "--time"):
      timeofday = arg                           
      assert False, "unhandled option"
  number = args[0]           
  msg = args[1]
  if msg != '':
    if timeofday == '':
        sendmessage(number, msg)
        today = time.strftime('%b %d x %Y', time.localtime())
        schedule = today.replace('x', timeofday)
        schedule_task(schedule, sendmessage, number, msg)
  if listening:

[edit] Send dialog notification (orange multi line popup requiring user interaction)

import dbus
def show_notification_dialog(message, mode="single"):
  bus = dbus.SystemBus()
  iface = dbus.Interface(bus.get_object('org.freedesktop.Notifications',
  if mode == "single":
  elif mode == "multiline":
      iface.SystemNoteDialog(str(message), dbus.UInt32(0), 'Ok')

This function allows you to show notification either with multiline (on Maemo pre-5 it will show a dialog with an "Ok" button) or single line (tiny notifications hiding automatically).

[edit] Take a screenshot

import gtk.gdk
w = gtk.gdk.get_default_root_window()
sz = w.get_size()
print "The size of the window is %d x %d" % sz
pb = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB,False,8,sz[0],sz[1])
pb = pb.get_from_drawable(w,w.get_colormap(),0,0,0,0,sz[0],sz[1])
if (pb != None):"screenshot.png","png")
  print "Screenshot saved to screenshot.png."
  print "Unable to get the screenshot."

Credits: took code from here.

There is also a way using PyQt:

import sys
import time
from PyQt4.QtGui import QPixmap, QApplication
app = QApplication(sys.argv)
file = "/home/user/MyDocs/.images/Screenshots/Screenshot-"+time.strftime("%Y%m%d")+"-"+time.strftime("%H%M%S")+".png"
QPixmap.grabWindow(QApplication.desktop().winId()).save(file, 'png')

[edit] Make an "Email Style" notification dialog

import dbus
bus = dbus.SessionBus()
proxy = bus.get_object('org.freedesktop.Notifications', '/org/freedesktop/Notifications')
interface = dbus.Interface(proxy,dbus_interface='org.freedesktop.Notifications')
interface.Notify('Notification', 0, 'control_bluetooth_paired', 'Testing 123', 'Hello World', [], {}, 0)

Credits: MohammadAG (on irc).