Wiki Ubuntu-it

Indice
Partecipa
FAQ
Wiki Blog
------------------
Ubuntu-it.org
Forum
Chiedi
Chat
Cerca
Planet
  • Pagina non alterabile
  • Informazioni
  • Allegati
  • attachment:skype-notify.py di InternetRete/Telefonia/Skype

Allegato "skype-notify.py"

Scarica

   1 #!/usr/bin/env python
   2 #	Python script to make Skype use notify-osd
   3 
   4 # Copyright (c) 2009, Lightbreeze
   5 
   6 # 
   7 # This program is free software: you can redistribute it and/or modify
   8 # it under the terms of the GNU General Public License as published by
   9 # the Free Software Foundation, either version 3 of the License, or
  10 # (at your option) any later version.
  11 #
  12 # This program is distributed in the hope that it will be useful,
  13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15 # GNU General Public License for more details.
  16 #
  17 # You should have received a copy of the GNU General Public License
  18 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
  19 #
  20 #
  21 # to use this script: Open Skype -> Open the menu and press 'Options' or press Ctrl-O
  22 # -> hit the 'Advanced' button and check 'Execute the following script on _any_ event'
  23 # -> paste: python /path/to/skype-notify.py -e"%type" -n"%sname" -f"%fname" -p"%fpath" -m"%smessage" -s%fsize -u%sskype
  24 # -> disable or enable the notifications you want to receive.
  25 
  26 # TODO: add sound if it is not synchronising; add indicator-applet presence; add buddy photo in IM
  27 import pynotify
  28 import sys
  29 from optparse import OptionParser
  30 
  31 # for indicator-applet: import indicate
  32 # for sound: import gst
  33 
  34 class NotifyForSkype:
  35 	def __init__(self):
  36 		# Initiate pynotify
  37 		if not pynotify.init("Skype Notifier"):
  38 		    sys.exit(-1)
  39 
  40 		# Add argument parser options
  41 		parser = OptionParser()
  42 		parser.add_option("-e", "--event", dest="type", help="type of SKYPE_EVENT")
  43 		parser.add_option("-n", "--sname", dest="sname", help="display-name of contact")
  44 		parser.add_option("-u", "--skype", dest="sskype", help="skype-username of contact")
  45 		parser.add_option("-m", "--smessage", dest="smessage", help="message body", metavar="FILE")
  46 		parser.add_option("-p", "--path", dest="fpath", help="path to file")
  47 		parser.add_option("-s", "--size", dest="fsize", help="incoming file size")
  48 		parser.add_option("-f", "--filename", dest="fname", help="file name", metavar="FILE")
  49 		(o, args) = parser.parse_args()
  50 
  51 		print(args)
  52 		print(sys.argv)
  53 		print(o.type)
  54 		
  55 		# If event type x show notification (summary, body, icon)
  56 		# Summary should not be None
  57 		if o.type == 'SkypeLogin': self.showNotification("Skype","You have logged into Skype with {contact}".format(contact=o.sname),"skype")
  58 		elif o.type == 'SkypeLogout': self.showNotification("You have logged out of Skype",None,"user-offline")
  59 		elif o.type == 'SkypeLoginFailed': self.showNotification("Skype login failed",None,"user-offline")
  60 		elif o.type == 'CallConnecting': self.showNotification("Dailing... {contact}".format(contact=o.sname),None,"skype") #some of these should be merged and update to the same bubble: Call Connecting -> CallRingingOut -> Call Asnwered
  61 		elif o.type == 'CallRingingIn': self.showNotification("Brring..","{contact} is calling you".format(contact=o.sname),"skype")
  62 		elif o.type == 'CallRingingOut': self.showNotification("Dididi.. dididi...","You are calling {contact}".format(contact=o.sname),"skype") #merge ^^ see above
  63 		elif o.type == 'CallAnswered': self.showNotification("Call Answered",None,"skype")
  64 		elif o.type == 'VoicemailReceived': self.showNotification(o.sname,"Voicemail Received","skype")
  65 		elif o.type == 'VoicemailSent': self.showNotification("Voicemail Sent",None,"skype")
  66 		elif o.type == 'ContactOnline': self.showNotification("{contact} is now online".format(contact=o.sname),None,"skype")
  67 		elif o.type == 'ContactOffline': self.showNotification("{contact} is now offline".format(contact=o.sname),None,"user-offline")
  68 		elif o.type == 'ContactDeleted': self.showNotification("Contact Deleted", "{contact} has been deleted from your contact list".format(contact=o.sname),"skype")
  69 		elif o.type == 'ChatIncomingInitial': self.showNotification("{contact}".format(contact=o.sname),o.smessage,"notification-message-IM")
  70 		elif o.type == 'ChatIncoming': self.showNotification("{contact}".format(contact=o.sname),o.smessage,"notification-message-IM")
  71 		elif o.type == 'ChatOutgoing': self.showNotification("{contact}".format(contact=o.sname),o.smessage,"notification-message-IM")
  72 		elif o.type == 'ChatJoined': self.showNotification("{contact} joined chat".format(contact=o.sname),o.smessage,"emblem-people")
  73 		elif o.type == 'ChatParted': self.showNotification("{contact} left chat".format(contact=o.sname),o.smessage,None)
  74 		elif o.type == 'TransferComplete': self.showNotification("Transfer Complete","{filename} saved to {path}{filename}".format(filename=o.fname,path=o.fpath),"gtk-save")
  75 		elif o.type == 'TransferFailed': self.showNotification("Transfer Failed","{filename}".format(filename=o.fname),"gtk-close")
  76 		elif o.type == 'Birthday': self.showNotification("{contact} has a birthday Tomorrow".format(contact=o.sname),None,"appointment-soon")
  77 
  78 	def showNotification(self, summary, message, ikon):
  79 		'''takes a title sumamry and a message to display the email notification. Returns the created notification object'''
  80 		if summary == None: summary = " "		
  81 		n = pynotify.Notification(summary, message, ikon)
  82 		n.show()
  83 		print("showNotification..")
  84 		return n
  85 
  86 cm = NotifyForSkype()

Allegati

Per riferirsi agli allegati di una pagina, usare attachment:NOME_FILE, come mostrato qui sotto nell'elenco degli allegati. NON usare l'URL che si trova in corrispondenza del collegamento [scarica], potrebbe cambiare in futuro.
  • [scarica | mostra] (10/05/2007 16.08.51, 55.3 KB) [[attachment:qt.png]]
  • [scarica | mostra] (13/11/2009 12.27.59, 5.1 KB) [[attachment:skype-notify.py]]
  • [scarica | mostra] (13/11/2009 12.26.48, 5.1 KB) [[attachment:skypenotify]]
 All files | Selected Files: delete move to page copy to page

Non รจ consentito inserire allegati su questa pagina.