From cc363d84e59a0beafb118bdc7b523fce374ba2b1 Mon Sep 17 00:00:00 2001 From: Andrew DeFaria Date: Wed, 24 Feb 2021 12:22:38 -0800 Subject: [PATCH] Removed old tunnel. Implemented speak bin --- bin/speak | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++ bin/tunnel | 7 ---- lib/Speak.pm | 4 ++ 3 files changed, 107 insertions(+), 7 deletions(-) create mode 100755 bin/speak delete mode 100755 bin/tunnel diff --git a/bin/speak b/bin/speak new file mode 100755 index 0000000..97aceb1 --- /dev/null +++ b/bin/speak @@ -0,0 +1,103 @@ +#!/usr/bin/perl + +=pod + +=head1 NAME $RCSfile: speak,v $ + +Simply speaks the passed in message, clipboard or file + +=head1 VERSION + +=over + +=item Author + +Andrew DeFaria + +=item Revision + +$Revision: 1.0 $ + +=item Created: + +Wed 24 Feb 2021 12:01:12 PM PST + +=item Modified: + +=back + +=head1 SYNOPSIS + + Usage: speak [-usa|ge] [-h|elp] [-v|erbose] [-de|bug] + [-c|lipboard] [-f|ile ] ["message"] + + Where: + -usa|ge: Print this usage + -h|elp: Detailed help + -v|erbose: Verbose mode (Default: -verbose) + -de|bug: Turn on debugging (Default: Off) + -c|lipboard: Speak the contents of the clipboard + -f|ile Speak the contents of + "message" Speak the message + +=head1 DESCRIPTION + +This script speaks the contents of the passed in message, clipboard or file + +=cut + +use strict; +use warnings; + +use FindBin; +use Getopt::Long; +use Pod::Usage; + +use lib"$FindBin::Bin/../lib"; + +use Display; +use Clipboard; +use Speak; + +my %opts = ( + usage => sub { pod2usage }, + help => sub { pod2usage(-verbose => 2)}, + verbose => sub { set_verbose }, + debug => sub { set_debug }, +); + +## Main +GetOptions( + \%opts, + 'usage', + 'help', + 'verbose', + 'debug', + 'clipboard', + 'file=s', +) || pod2usage; + +my $msg = join ' ', @ARGV; + +if ($opts{clipboard}) { + if ($opts{file}) { + error 'Cannot specify both -clipboard and -file', 1; + } elsif ($msg) { + error 'Cannot specify both -clipboard and ', 1; + } else { + $msg = Clipboard->paste; + } # if +} elsif ($opts{file}) { + if ($msg) { + error 'Cannot specify both -file and ', 1; + } else { + open my $file, '<', $opts{file} or + error "Unable to open $opts{file} - $!", 1; + + $msg = <$file>; + + close $file; + } # if +} # if + +speak $msg; diff --git a/bin/tunnel b/bin/tunnel deleted file mode 100755 index 2925093..0000000 --- a/bin/tunnel +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -# -# Simple script to use ssh to tunnel ports for IMAP (1143 -> 143) and SMTP (1025 -> 25) -# to defaria.com so I can read and write email to my home server. -# -# Note -Nf puts ssh in the background after establishing the tunnel. -ssh -Nf -L localhost:1025:defaria.com:25 -L localhost:1143:defaria.com:143 andrew@defaria.com diff --git a/lib/Speak.pm b/lib/Speak.pm index 0869ed4..c18c2f7 100644 --- a/lib/Speak.pm +++ b/lib/Speak.pm @@ -47,6 +47,7 @@ use warnings; use base 'Exporter'; use FindBin; +use Clipboard; use lib "$FindBin::Bin/../lib"; @@ -112,6 +113,9 @@ Returns: return; } # if + # Handle the case where $msg is not passed in. Then use the clipboard; + $msg = Clipboard->paste unless $msg; + # Handle the case where $msg is a filehandle $msg = <$msg> if ref $msg eq 'GLOB'; -- 2.17.1