Created
December 31, 2014 14:18
-
-
Save scorpp/7a3311991c75803cd611 to your computer and use it in GitHub Desktop.
Skype: mute\unmute current call
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python2 | |
import sys | |
import traceback | |
import re | |
import dbus | |
import dbus.service | |
#for event loop | |
import gobject | |
from dbus.mainloop.glib import DBusGMainLoop | |
####################################################### | |
#catching the events | |
class Callback_obj(dbus.service.Object): | |
def __init__(self, bus, object_path): | |
dbus.service.Object.__init__(self, bus, object_path, bus_name='com.Skype.API') | |
@dbus.service.method(dbus_interface='com.Skype.API') | |
def Notify(self, message_text): | |
pass | |
###################################################### | |
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) | |
#connect to the session | |
session_bus = dbus.SessionBus() | |
#connect to Skype | |
skype = session_bus.get_object('com.Skype.API', '/com/Skype') | |
#ok lets hit up skype now! | |
answer = skype.Invoke('NAME PythonManageCall') | |
if answer != 'OK': | |
sys.exit('Could not bind to Skype client') | |
answer = skype.Invoke('PROTOCOL 5') | |
if (answer != 'PROTOCOL 5'): | |
sys.exit('Could not agree on protocol!') | |
#tie up the events to the skype | |
skype_callback = Callback_obj(session_bus, '/com/Skype/Client') | |
print 'Connected to the Skype system!\n' | |
answer = skype.Invoke('SEARCH ACTIVECALLS') #get calls going on right now! | |
if(re.search(r'CALLS [0-9]+', answer)): # see if there was a call | |
callNum = re.search(r'CALLS ([0-9]+)', answer).group(1) | |
callStatus = skype.Invoke('GET CALL ' + callNum + ' STATUS') | |
print callStatus | |
muteStatus = skype.Invoke('GET MUTE') | |
print muteStatus | |
if(muteStatus == 'MUTE OFF'): | |
print 'ON' | |
skype.Invoke('SET MUTE ON') | |
else: | |
print 'OFF' | |
skype.Invoke('SET MUTE OFF') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment