-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlinkopenwithx
More file actions
executable file
·93 lines (92 loc) · 3.32 KB
/
Copy pathlinkopenwithx
File metadata and controls
executable file
·93 lines (92 loc) · 3.32 KB
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/sh
# a script to handle different links, when open from terminal with X
printf %s "${1}" | xsel -b
color=$(cat ~/scripts/var/bgcolor)
checkYoutubeStartpoint() {
if echo "${link}" | grep -q -e '[?#&]t=[0-9]\+s\?$'
then
second=$(echo "${link}" | sed 's/.*[?#&]t\\\?=\([0-9]\+\)s\?$/\1/')
link=$(echo "${link}" | sed 's/[?#&]t\\\?=[0-9]\+s\?$//')
mpv --really-quiet --no-osc "${link}" --start=+"${second}" ||\
link=$(echo "${link}" | sed 's/pak/tube/')&&\
mpv --really-quiet --no-osc "${link}" --start=+"${second}"
elif echo "${link}" | grep -q -e '[?#&]t\\\?=[0-9]\+m[0-9]\+s\?$'
then
second=$(echo "${link}" | sed 's/.*[?#&]t\\\?=[0-9]\+m\([0-9]\+\)s\?$/\1/')
minute=$(echo "${link}" | sed 's/.*[?#&]t\\\?=\([0-9]\+\)m[0-9]\+s\?$/\1/')
link=$(echo "${link}" | sed 's/[?#&]t=[0-9]\+m[0-9]\+s\?$//')
mpv --really-quiet --no-osc "${link}" --start=+"${minute}":"${second}" ||\
link=$(echo "${link}" | sed 's/pak/tube/') &&\
mpv --really-quiet --no-osc "${link}" --start=+"${minute}":"${second}"
else
mpv --really-quiet --no-osc "${link}" || (
link=$(echo "${link}" | sed 's/pak/tube/')
mpv --really-quiet --no-osc "${link}"
)
fi
}
if echo "${1}" | grep -q -e \.mp3$ -e \.mp4$ -e \.m4v$ -e v\.redd\.it
then
mpv --really-quiet --no-osc -no-audio-display "${1}"
elif echo "${1}" | grep -q -e m\.youtube\.
then
link=$(echo "$1" | sed 's/m\.//' | sed 's/tube/pak/')
checkYoutubeStartpoint
elif echo "${1}" | grep -q -e youtube\.
then
link=$(echo "$1" | sed 's/tube/pak/')
checkYoutubeStartpoint
elif echo "${1}" | grep -q -e youtu\.be
then
link=$(echo "$1" | sed 's/tu\.be\//pak.com\/watch?v=/')
checkYoutubeStartpoint
elif echo "${1}" | grep -q -e dailymotion\. -e streamable\.com -e liveleak\.com -e vimeo\.com
then
mpv --really-quiet --no-osc "${1}"
elif echo "${1}" | grep -q -e "\.\(jpg\|JPG\|jpeg\|png\|PNG\)\(?[^\.]*\)\?$"
then
if echo "${1}" | grep -q -e wikipedia.org # use the best quality of the picture
then
feh -. --image-bg "$color" "$(w3m -dump -o display_link_number=1 "${1}"| grep -q -e \.jpg$ -e \.JPG$ -e \.jpeg$ -e \.png$ | cut -c6- | grep -q -v /thumb/ | grep -q /commons/ | grep -q -e ^https)" || feh -. --image-bg "$color" "${1}"
else
feh -. --image-bg "$color" "${1}"
fi
elif echo "${1}" | grep -q -e \.svg
then
if echo "${1}" | grep -q -e wikipedia\.org
then
display "$(w3m -dump -o display_link_number=1 "${1}" | grep -q -e \.svg$ | cut -c6- | grep -q -v /thumb/ | grep -q /commons/ | grep -q -e ^https)"
else
display "${1}"
fi
elif echo "${1}" | grep -q -e \.gif -e \.gifv$
then
mpv --really-quiet --loop --no-osc -no-audio-display "${1}"
elif echo "${1}"| grep -q -e \.pdf
then
DIR="/tmp/newpdfs"
if [ ! -e $DIR ]
then
mkdir $DIR
chmod 0755 $DIR
else
rm -f $DIR/*
fi
wget "${1}" -P "${DIR}"
BILD="${1##*/}"
zathura "$DIR"/"$BILD"
elif echo "${1}" | grep -q -e imgur\.com -e flickr\.com -e i\.reddit
then
you-get -p "feh -. --image-bg $color" "${1}"
elif echo "${1}" | grep -q -e gfycat.com
then
mpv --really-quiet --loop --no-osc "$(you-get -u "${1}" | grep -q \.gif$ | head -1)"
elif echo "${1}" | grep -q -e www.reddit
then
rtv -l "${1}"
elif [ "$color" = "black" ]
then
qutebrowser "${1}"
else
qutebrowser "${1}"
fi