Skip to content

Instantly share code, notes, and snippets.

@scorpp
Created December 31, 2014 14:19
Show Gist options
  • Select an option

  • Save scorpp/2542aa2ca55433c66446 to your computer and use it in GitHub Desktop.

Select an option

Save scorpp/2542aa2ca55433c66446 to your computer and use it in GitHub Desktop.

Revisions

  1. scorpp created this gist Dec 31, 2014.
    22 changes: 22 additions & 0 deletions skype-toggle.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    #!/usr/bin/python2
    import dbus
    import os

    remote_bus = dbus.SessionBus()

    out_connection = remote_bus.get_object('com.Skype.API', '/com/Skype')

    out_connection.Invoke('NAME SkypeToggler')
    out_connection.Invoke('PROTOCOL 5')
    wnd_state = out_connection.Invoke('GET WINDOWSTATE')

    if 'WINDOWSTATE NORMAL' == wnd_state:
    print 'Hide'
    out_connection.Invoke('MINIMIZE')
    elif 'WINDOWSTATE HIDDEN' == wnd_state:
    print 'Show'
    out_connection.Invoke('FOCUS')
    wId = os.popen('wmctrl -lp | grep Skype | sort -n | head -n 1 | awk \'{print $1}\' | xargs wmctrl -i').read()
    #print wId
    #print 'wmctrl -ia ' + wId
    #os.system('wmctrl -ia ' + wId)