blob: 2a16c039f8dc5b9c83a43f25acfcd3f93ed08527 (
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
70
71
72
73
74
75
76
77
78
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__
|