Fixed win32 compatibility again, somehow I expected Clipboard.pm to be decent on systems that are not linux.
This commit is contained in:
parent
ce2dedab7a
commit
266406652c
|
@ -11,17 +11,19 @@ use Net::SSH2; use Try::Tiny;
|
||||||
use POE; use POE::Component::DirWatch::WithCaller;
|
use POE; use POE::Component::DirWatch::WithCaller;
|
||||||
use Unix::PID; use YAML;
|
use Unix::PID; use YAML;
|
||||||
|
|
||||||
if($^O eq 'darwin') {
|
#Load platform-specific modules here too to avoid missing modules causing a crash later
|
||||||
#Needed because Clipboard's use of Mac::Pasteboard is incomplete.
|
for ($^O) {
|
||||||
require Mac::Pasteboard;
|
#Clipboard.pm doesn't integrate nicely with the OSX clipboard due to datatype differences
|
||||||
} else {
|
#nor does it integrate well with windows, as it doesn't support empty()
|
||||||
require Clipboard;
|
require Mac::Pasteboard if /darwin/;
|
||||||
#Mac::Speech does not build on modern OSX installations, so we can't use Speech::Synthesis on darwin
|
require Win32::Clipboard if /MSWin32/;
|
||||||
#We still use Speech::Synthesis as a wrapper for Win32::SAPI5 because the interface is simpler
|
#Unsurprisingly it's perfectly fine for linux :/
|
||||||
require Speech::Synthesis;
|
require Clipboard unless /darwin/ or /MSWin32/;
|
||||||
|
#Speech::Synthesis is a great wrapper for Win32::SAPI5 and should work for Festival
|
||||||
|
#It unfortunately doesn't work -at all- on modern OSX due to API changes/Carbon deprecation
|
||||||
|
require Speech::Synthesis unless /darwin/;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
my $ME = __PACKAGE__;
|
my $ME = __PACKAGE__;
|
||||||
#will bump to v1.0 upon full cross-platform compatibility and submission to CPAN.
|
#will bump to v1.0 upon full cross-platform compatibility and submission to CPAN.
|
||||||
#version number reflective of how close the module is to 'complete'
|
#version number reflective of how close the module is to 'complete'
|
||||||
|
@ -51,8 +53,9 @@ sub timefmt2str {
|
||||||
return Date::Format::time2str(shift,time());
|
return Date::Format::time2str(shift,time());
|
||||||
}
|
}
|
||||||
sub clipb_copy {
|
sub clipb_copy {
|
||||||
my $t = shift;
|
my $t = shift;
|
||||||
Clipboard->copy($t) and return unless $^O eq 'darwin'; #OSX is a special snowflake here
|
Clipboard->copy($t) and return unless $^O eq 'darwin' or $^O eq 'MSWin32';
|
||||||
|
Win32::Clipboard::Empty() and Win32::Clipboard::Set($t) and return unless $^O eq 'darwin';
|
||||||
my $p = Mac::Pasteboard->new();
|
my $p = Mac::Pasteboard->new();
|
||||||
$p->clear(); #Clear clipboard first to avoid a clipboard ownership error
|
$p->clear(); #Clear clipboard first to avoid a clipboard ownership error
|
||||||
$p->copy($t);
|
$p->copy($t);
|
||||||
|
@ -193,7 +196,7 @@ sub filter {
|
||||||
}
|
}
|
||||||
sub trigger {
|
sub trigger {
|
||||||
my ($sender_mon,$file) = @_;
|
my ($sender_mon,$file) = @_;
|
||||||
logger(1,"sender: $sender_mon, file: $file");
|
#logger(1,"sender: $sender_mon, file: $file");
|
||||||
$file->move_to($Conf->{general}->{tmp}.name($sender_mon,$file->basename));
|
$file->move_to($Conf->{general}->{tmp}.name($sender_mon,$file->basename));
|
||||||
upload($file) or $file->move_to($Conf->{general}->{tmp}.$file->basename) and return if defined $Conf->{monitor}->{$sender_mon}->{action}->{'upload'} and $Conf->{monitor}->{$sender_mon}->{action}->{'upload'} == 1;
|
upload($file) or $file->move_to($Conf->{general}->{tmp}.$file->basename) and return if defined $Conf->{monitor}->{$sender_mon}->{action}->{'upload'} and $Conf->{monitor}->{$sender_mon}->{action}->{'upload'} == 1;
|
||||||
$file->move_to($Conf->{monitor}->{$sender_mon}->{action}->{target}."/".$file->basename) or logger(2,"Couldn't move ".$file->basename." to ".$Conf->{monitor}->{$sender_mon}->{action}->{target}) if defined $Conf->{monitor}->{$sender_mon}->{action}->{move} and $Conf->{monitor}->{$sender_mon}->{action}->{move} == 1 and defined $Conf->{monitor}->{$sender_mon}->{action}->{target};
|
$file->move_to($Conf->{monitor}->{$sender_mon}->{action}->{target}."/".$file->basename) or logger(2,"Couldn't move ".$file->basename." to ".$Conf->{monitor}->{$sender_mon}->{action}->{target}) if defined $Conf->{monitor}->{$sender_mon}->{action}->{move} and $Conf->{monitor}->{$sender_mon}->{action}->{move} == 1 and defined $Conf->{monitor}->{$sender_mon}->{action}->{target};
|
||||||
|
|
Loading…
Reference in New Issue