You got a call.. with Python OSD and Sony Ericsson K300i
you will not be able to attend the calls simply because you won’t care the buzzing of the mobile phone…
This Python program will Show an On Screen Display telling ” You have a call” to divert our attention to the mobile phone. Only thing is that you should connect your Mobile with your PC using the USB cable
provided with your mobile .. or if you are a bit adventurous, try to connect your phone using bluetooth using the
bluetooth dongle.. ( /dev/rfcomm0 instead of /dev/ttyUSB0)..
For Bluetooth ….
###################
hcitool scan
Scanning …
11:22:33:44:55:66
Then modify the /etc/bluetooth/rfcomm.conf file
#
# RFCOMM configuration file.
#
rfcomm0 {
# Automatically bind the device at startup
bind no;
# Bluetooth address of the device
device 11:22:33:44:55:66;
# RFCOMM channel for the connection
channel 1;
# Description of the connection
comment “Example Bluetooth device”;
}
Then give this command
rfcomm bind /dev/rfcomm0
after running the below given python program, release the device
rfcomm release /dev/rfcomm0
###################
Then try this python program
######################################################
# mobilecall.py #
# Python program which displays the information when #
# somebody calls your mobile (here my K300i) which is #
# plugged to my pc using the usb cable. #
# ################################################### #
# Technical Details: #
# The usb device is shown as ttyUSB0 in the Linux PC #
# The serial module can be used to read and write from#
# that device. PyOSD is used to diplay the information#
# on the screen. #
# If you want, you can use the pygame module to play #
# music in your PC to inform you about the call .. #
# or dbus module to mute other music players #
# #
# Technically , this is the meanest way(or simplest) #
# to achieve this using python #
######################################################
import serial
import time
import pyosd
#import pygame
def mobilecall():
try:
# /dev/rfcomm0 in the case you are using bluetooth connectivity
s= serial.Serial(’/dev/ttyUSB0′,9600)
# This will wait till some string is pushed from phone.
# Highest probable event is ‘RING’ indication from phone
# when somebody calls you.
data = s.readline()
# PyOSD initialization and other settings..
displayer = pyosd.osd()
displayer.set_colour(’red’)
displayer.set_pos(0)
displayer.set_timeout(10)
displayer.display(’You have a call . Please pick up your mobile’)
# Uncomment this if you want to play music on receiving a call
#pygame.mixer.init()
#indi_music = pygame.mixer.Sound(’/usr/share/sounds/KDE_Startup.wav’)
#pygame.mixer.Sound.play(indi_music)
time.sleep(10)
except:
print ‘Failed to open Port’
# Pythonic way to invoke the function
if __name__== ‘__main__’:
mobilecall()
###############################################################
And here goes the output:
