From 1739341e87cf7b1b80f76b78eb0a48912d47a705 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Sun, 1 Nov 2020 20:19:21 +0100 Subject: Renamed again --- .local/bin/linkview | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++ .local/bin/linkview.pl | 46 ----------------------------- 2 files changed, 79 insertions(+), 46 deletions(-) create mode 100755 .local/bin/linkview delete mode 100755 .local/bin/linkview.pl (limited to '.local') diff --git a/.local/bin/linkview b/.local/bin/linkview new file mode 100755 index 0000000..2a16c03 --- /dev/null +++ b/.local/bin/linkview @@ -0,0 +1,79 @@ +#!/usr/local/bin/perl + +use strict; +use warnings; +use Scalar::Util qw(looks_like_number); +use Term::ANSIColor; + +use constant { + MPV_PATH => '/home/jozan/.local/bin/mpview', + FETCH_PATH => '/usr/bin/fetch' +}; + +# ext="${1##*.}" +# mpvFiles="mkv mp4 gif" +# sxivFiles="png jpg jpeg jpe xpm" +# wgetFiles="flac mp3 mp3?source=feed opus pdf doc docx" +# +# cd ~/dl || exit +# +# if echo "$sxivFiles" | grep -w "$ext" > /dev/null; then +# nohup sxiv "$1" > /dev/null & +# elif echo "$mpvFiles" | grep -w "$ext" > /dev/null; then +# nohup mpv --loop --quiet "$1" > /dev/null & +# elif echo "$wgetFiles" | grep -w "$ext" > /dev/null; then +# clear +# fetch "$1" +# else +# clear +# mpv-view.pl "$1" +# fi + +sub open_link +{ + my ($answer) = @_; + return; +} + +sub prompt +{ + my ($url) = @_; + my $answer; + + print 'URL: ' . colored($url, 'red') . "\n\n" . + "Open with?\n" . + "0) mpv\n" . + "1) fetch\n" . + "2) sxiv\n" . + "3) zathura\n" . + "4) w3m\n" . + "5) firefox\n\n" . + "> "; + $answer = ; + if (!looks_like_number($answer) || $answer == 0 || $answer == 1 || $answer > 6) { + $answer = -1; + } + return $answer; +} + +sub main +{ + my $answer; + + system('tput', 'clear'); + if (@ARGV == 0) { + print STDERR "linkview: URL needed\n"; + exit 1; + } + $answer = prompt($ARGV[0]); + if ($answer == -1) { + print STDERR "linkview: Bad answer\n"; + exit 2; + } + open_link($answer); + return; +} + +main(); + +__END__ diff --git a/.local/bin/linkview.pl b/.local/bin/linkview.pl deleted file mode 100755 index 8baf8c0..0000000 --- a/.local/bin/linkview.pl +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/local/bin/perl - -use strict; -use warnings; -use Term::ANSIColor; - -use constant { - MPV_PATH => '/home/jozan/.local/bin/mpview', - FETCH_PATH => '/usr/bin/fetch' -}; - -# ext="${1##*.}" -# mpvFiles="mkv mp4 gif" -# sxivFiles="png jpg jpeg jpe xpm" -# wgetFiles="flac mp3 mp3?source=feed opus pdf doc docx" -# -# cd ~/dl || exit -# -# if echo "$sxivFiles" | grep -w "$ext" > /dev/null; then -# nohup sxiv "$1" > /dev/null & -# elif echo "$mpvFiles" | grep -w "$ext" > /dev/null; then -# nohup mpv --loop --quiet "$1" > /dev/null & -# elif echo "$wgetFiles" | grep -w "$ext" > /dev/null; then -# clear -# fetch "$1" -# else -# clear -# mpv-view.pl "$1" -# fi - -sub main -{ - my $answer; - - if (@ARGV == 0) { - print STDERR "URL needed\n"; - exit 1; - } - print colored($ARGV[0], 'bold_green') . "\n"; - $answer = ; - return; -} - -main(); - -__END__ -- cgit v1.2.3