The Following User Says Thank You to qwerty12 For This Useful Post: | ||
![]() |
2010-06-25
, 14:37
|
|
Posts: 1,090 |
Thanked: 476 times |
Joined on Jan 2010
@ Ingolstadt, Germany
|
#62
|
![]() |
2010-06-25
, 19:32
|
|
Posts: 1,090 |
Thanked: 476 times |
Joined on Jan 2010
@ Ingolstadt, Germany
|
#63
|
#!/usr/bin/env python def cb (Notification=None, action=None, Data=None): pass def my_func(account, sender, message, conversation, flags): if bus.pidginbus.PurpleConversationHasFocus(conversation) == 0: buddy = bus.pidginbus.PurpleFindBuddy(account,str(sender.split("@")[0])) name = bus.pidginbus.PurpleBuddyGetAlias(buddy) #icon = bus.pidginbus.PurpleBuddyGetIcon(buddy) #icon_path = bus.pidginbus.PurpleBuddyIconGetFullPath(icon) conv = str(conversation) msg = message.replace("\n"," ") msg = "\""+msg if len(msg) > 32: msg = msg[:32]+"...\"" print name, "("+sender+") said \""+message+"\"" #with icon at", icon_path, "in conv", conv # it's only commented out for test-reasons because i only try it on ubuntu and console with print pynotify.init(os.path.splitext(os.path.basename(sys.argv[0]))[0]) n = pynotify.Notification(name+" ("+sender+")",msg,"pidgin") # ------------------------- # maybe the next two lines can be used for bringing the conversation window to the foreground # when the notification is being clicked by the user # if that is not possible: comment them out or delete them (no use for them) n.set_hint_string("dbus-callback-default","im.pidgin.purple.PurpleService /im/pidgin/purple/PurpleObject im.pidgin.purple.PurpleInterface purple_conversation_present int32:"+conv) # n.set_hint_string("dbus-callback-default","com.nokia.osso_browser /com/nokia/osso_browser com.nokia.osso_browser open_new_window string:\"callto://666\"") n.add_action("default", "im", cb) n.set_timeout(3000) # or do i have to make an "add_action" for the notification? # maybe i can just put three NULL arguments there ^^ # ------------------------ n.show() import os import sys import gobject, dbus import pynotify from dbus.mainloop.glib import DBusGMainLoop dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) bus = dbus.SessionBus() obj = bus.get_object("im.pidgin.purple.PurpleService", "/im/pidgin/purple/PurpleObject") bus.pidginbus = dbus.Interface(obj, "im.pidgin.purple.PurpleInterface") bus.add_signal_receiver(my_func, dbus_interface="im.pidgin.purple.PurpleInterface", signal_name="ReceivedImMsg") loop = gobject.MainLoop() loop.run()
The Following User Says Thank You to b666m For This Useful Post: | ||
![]() |
2010-06-26
, 10:54
|
|
Posts: 1,090 |
Thanked: 476 times |
Joined on Jan 2010
@ Ingolstadt, Germany
|
#64
|
#!/usr/bin/env python def cb (Notification=None, action=None, Data=None): pass def my_func(account, sender, message, conversation, flags): if bus.pidginbus.PurpleConversationHasFocus(conversation) == 0: name = str(sender.split("@")[0]) buddy = bus.pidginbus.PurpleFindBuddy(account,name) alias = bus.pidginbus.PurpleBuddyGetAlias(buddy) #icon = bus.pidginbus.PurpleBuddyGetIcon(buddy) #icon_path = bus.pidginbus.PurpleBuddyIconGetFullPath(icon) proto = bus.pidginbus.PurpleAccountGetProtocolName(account) #proid = bus.pidginbus.PurpleAccountGetProtocolId(account) conv = str(conversation) if alias == "": alias = name msg = message if proto == "XMPP": msg = msg[6:-7] elif proto == "MSN": col = msg.find("COLOR") if col > -1: msg = msg[col+16:-14] msg = msg.replace("\n"," ") msg = "\""+msg if len(msg) > 32: msg = msg[:33]+"...\"" else: msg = msg+"\"" #print alias, "("+sender+") said \""+message+"\" in proto", proto, proid #with icon at", icon_path, "in conv", conv # it's only commented out for test-reasons because i only try it on ubuntu and console with print pynotify.init(os.path.splitext(os.path.basename(sys.argv[0]))[0]) n = pynotify.Notification(alias+" ("+proto+")",msg,"pidgin") # ------------------------- # maybe the next two lines can be used for bringing the conversation window to the foreground # when the notification is being clicked by the user # if that is not possible: comment them out or delete them (no use for them) n.set_hint_string("dbus-callback-default","im.pidgin.purple.PurpleService /im/pidgin/purple/PurpleObject im.pidgin.purple.PurpleInterface purple_conversation_present int32:"+conv) # n.set_hint_string("dbus-callback-default","com.nokia.osso_browser /com/nokia/osso_browser com.nokia.osso_browser open_new_window string:\"callto://666\"") n.add_action("default", "im", cb) n.set_timeout(3000) # or do i have to make an "add_action" for the notification? # maybe i can just put three NULL arguments there ^^ # ------------------------ n.show() import os import sys import gobject, dbus import pynotify from dbus.mainloop.glib import DBusGMainLoop dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) bus = dbus.SessionBus() obj = bus.get_object("im.pidgin.purple.PurpleService", "/im/pidgin/purple/PurpleObject") bus.pidginbus = dbus.Interface(obj, "im.pidgin.purple.PurpleInterface") bus.add_signal_receiver(my_func, dbus_interface="im.pidgin.purple.PurpleInterface", signal_name="ReceivedImMsg") loop = gobject.MainLoop() loop.run()
The Following 3 Users Say Thank You to b666m For This Useful Post: | ||
![]() |
2010-06-27
, 18:49
|
|
Posts: 1,090 |
Thanked: 476 times |
Joined on Jan 2010
@ Ingolstadt, Germany
|
#65
|
![]() |
2010-06-28
, 07:29
|
Posts: 47 |
Thanked: 21 times |
Joined on Jan 2010
|
#66
|
![]() |
2010-06-28
, 10:17
|
|
Posts: 4,274 |
Thanked: 5,358 times |
Joined on Sep 2007
@ Looking at y'all and sighing
|
#67
|
mhm... is it a good idea to start a script on bootup which checks if pidgin is running every X seconds with the "sleep X" command in between?
or will "sleep" drain the battery faster? :/
(:
The Following User Says Thank You to qwerty12 For This Useful Post: | ||
![]() |
2010-06-28
, 14:06
|
|
Posts: 1,090 |
Thanked: 476 times |
Joined on Jan 2010
@ Ingolstadt, Germany
|
#68
|
Could you create a short tutorial on how to use ur script? Would love to test it!
Also, do you know of something to make pidgin vibrate? thats one thing i'm still missing!
Thanks for you're work!
I really think you'd be best off just making it a Pidgin plugin. Yes, one can only be made in C but I'll help with the DBus-GLib
The Following 2 Users Say Thank You to b666m For This Useful Post: | ||
![]() |
2010-06-28
, 14:10
|
|
Posts: 1,309 |
Thanked: 1,187 times |
Joined on Nov 2008
|
#69
|
![]() |
2010-06-28
, 16:15
|
|
Posts: 1,090 |
Thanked: 476 times |
Joined on Jan 2010
@ Ingolstadt, Germany
|
#70
|
Are you guys sure you don't ought to create a new thread for this app or hack or plugin or what it is you're making? Or maybe change the thread title a bit.
dbus-send --session --type=method_call --print-reply --dest=im.pidgin.purple.PurpleService /im/pidgin/purple/PurpleObject im.pidgin.purple.PurpleInterface.PurpleConversatio nPresent int32:2889 works here
Will get back to you with the PythonNotification conversion soon.