Mac-PopClip-Quick
view release on metacpan or search on metacpan
lib/Mac/PopClip/Quick.pm view on Meta::CPAN
every version of your extension so installing later version of the extension
replaces the old version.
While the temporary extension identifier generated will not change as long as
you do not change the name of the extension and are generating the extension on
this particular Mac, you should use the extension_identifier parameter to set a
unique identifier in perpetuity in case you ever want to generate the extension
on different hardware:
use Mac::PopClip::Quick (
extension_identifier => 'com.yourdomainname.yourextensionname',
);
WARNING
}
print "Created extension at @{[ $generator->filename ]}\n"
or die "Can't print for some reason: $!";
}
exit;
}
sub _generator_class { return 'Mac::PopClip::Quick::Generator' }
sub popclip_text() { return $ENV{POPCLIP_TEXT} }
push @EXPORT, 'popclip_text';
1;
__END__
=head1 NAME
Mac::PopClip::Quick - quickly write PopClip extensions in Perl
=for test_synopsis BEGIN { die "SKIP: not testable\n"; }
=head1 SYNOPSIS
First write a script:
#!/usr/bin/perl
use 5.012;
use warnings;
use autodie;
use Mac::PopClip::Quick;
use POSIX qw(strftime);
open my $fh, ''>>:utf8', "$ENV{HOME}/Dropbox/runlog.txt";
say $fh strftime("%FT%T",gmtime) . ' ' . popclip_text();
Then install it as a PopClip Extension
bash$ INSTALL_POPCLIP_EXTENSION=1 ./runlog.pl
=head1 DESCRIPTION
PopClip For Mac is a commercial OS X utility from Pilotmoon Software that
creates little popup menus when you highlight text. Please see
L<http://pilotmoon.com/popclip/> for more details.
This module make it easier to write PopClip extensions in Perl. With this
module you can turn a simple Perl script into an installable extension with a
single command.
The resulting extension does not depend on the Mac::PopClip::Quick module, and
can be safely distributed to systems that do not have this module installed.
=head2 Examples
In your script you should C<use Mac::PopClip::Quick>.
#!/usr/bin/perl
use Mac::PopClip::Quick;
system('say','The selected text is '.popclip_text());
From the command line you simply need to execute the script with the
C<INSTALL_POPCLIP_EXTENSION> environment variable set to a true value.
bash$ INSTALL_POPCLIP_EXTENSION=1 ./reverse.pl
You can also create an executable suitable for distribution using the
bash$ CREATE_POPCLIP_EXTENSION=1 ./reverse.pl
Options can be set by passing them in the C<use> statement:
use Mac::PopQuick::Quick (
extension_identifier => 'com.yourdomain.extensionname',
);
They'll be passed through to the underlying L<Mac::PopClip::Quick::Generator>
class's constructor.
You can use C<after_action> to control what your extension does with the
script output, for example pasting it:
use Mac::PopQuick::Quick (
extension_name => 'Reverse Text',
after_action => 'paste-result',
);
print reverse popclip_text();
=head1 Supported Options
=head2 Core Options
=head3 extension_name
The name of the extension. By default this is the name of the script, minus
any file extension (e.g. if your script if called C<foo.pl> then the extension
will be called C<foo> by default.)
=head3 title
The title. By default, the same as the C<extension_name>.
=head3 filename
( run in 0.883 second using v1.01-cache-2.11-cpan-364913b4093 )