#!/usr/bin/env perl use strict; use warnings; use Cwd qw(cwd); 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 -selection clipboard -t image/png"); exec( 'notify-send', '-t', '2000', 'clipped image', ' clipped image' ); } return; } sub clip_raw { my ($file) = @_; my $pid; $pid = fork(); if ($pid == 0) { system( "xclip -selection clipboard $file"); exec( 'notify-send', '-t', '2000', 'clipped file', ' 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__