summaryrefslogtreecommitdiffstats
path: root/.local/bin/linkview
diff options
context:
space:
mode:
Diffstat (limited to '.local/bin/linkview')
-rwxr-xr-x.local/bin/linkview79
1 files changed, 79 insertions, 0 deletions
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 = <STDIN>;
+ 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__