blob: 661f711417028ffbb4e9203aaef57a3cfe434186 (
plain)
| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
 | #!/usr/bin/env perl
use strict;
use warnings;
use Cwd qw(cwd);
use constant XCLIP => 'xclip -selection clipboard ';
sub close_io
{
	open STDIN,  '<', '/dev/null' or die $!;
	open STDOUT, '>', '/dev/null' or die $!;
	open STDERR, '>', '/dev/null' or die $!;
	return;
}
sub clip_img
{
	my ($file) = @_;
	my $pid;
	$pid = fork();
	if ($pid == 0) {
		system("magick '$file' png:- | " . XCLIP . "-t image/png");
		exec('herbe', '  clipped image');
	}
	return;
}
sub clip_raw
{
	my ($file) = @_;
	my $pid;
	$pid = fork();
	if ($pid == 0) {
		system( "xclip -selection clipboard '$file'");
		exec('herbe', '  clipped file');
	}
	return;
}
sub clip
{
	my ($file, $mimetype) = @_;
	return clip_img($file) if $mimetype =~ /^image\//;
	clip_raw($file);
	return;
}
sub joe_clipper
{
	my $file = cwd() . '/' . $ARGV[0];
	my $mimetype;
	if (-d $file) {
		return;
	}
    $mimetype=`file -bL --mime-type -- "$file"`;
	clip($file, $mimetype);
	return;
}
joe_clipper();
__END__
 |