Skip to content

Instantly share code, notes, and snippets.

@scorpp
Created December 31, 2014 14:16
Show Gist options
  • Save scorpp/8da0bdcd61f63fb77d99 to your computer and use it in GitHub Desktop.
Save scorpp/8da0bdcd61f63fb77d99 to your computer and use it in GitHub Desktop.
Skype: focus main win and prepare it for typing in contact name
#!/usr/bin/perl
use strict;
use warnings;
use Net::DBus;
my $session = Net::DBus->session;
my $service = $session->get_service('com.Skype.API');
my $skype = $service->get_object('/com/Skype');
$skype->Invoke('NAME PerlMuteScript') eq 'OK'
or die 'Cannot connect to skype';
$skype->Invoke('PROTOCOL 5') eq 'PROTOCOL 5'
or die 'Cannot agree protocol';
print $skype->Invoke('OPEN CONTACTS') . "\n";
# sometimes it fails to activate window from first time properly
system('sh', '-c', 'xdotool search Skype™ | sort | head -n1 | xargs -i xdotool windowactivate --sync {} key Escape');
system('sh', '-c', 'xdotool search Skype™ | sort | head -n1 | xargs -i xdotool windowactivate --sync {} key Escape');
exit 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment