-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlink-handler
66 lines (58 loc) · 2.29 KB
/
link-handler
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
#!/bin/bash
#which clipboard to use, valid options are "primary" and "clipboard"
SELECTION=clipboard
# choose bookmarks file location
BOOKMARKS="$HOME/.config/vimb/bookmark"
#choose your terminal
TERM=termite
shopt -s lastpipe
ops=(
qutebrowser
mpv
video-play-download
# curl-download
# curl-save
send_to_kodi
wget
add-bookmark
w3m
def
guj
netsurf
)
getopts u: name
case $name in
u) url=$OPTARG ;;
*) url="$(xclip -o -selection $SELECTION)" ;;
#lariza "$(xclip -o -selection $SELECTION)" && exit ;;
#url="$(xclip -o -selection $SELECTION)" ;;
esac
[[ ! $url ]] && exit
# to use with rofi ##
option=$(for i in "${ops[@]}"; do echo "$i"; done | rofi -dmenu -location 1 -l 10 -width 100 -p : -font "Inconsolata 14" -mesg "open <u>$url</u> with...")
## uncomment below line to use with dmenu , and comment out line before this ##
# option=$(for i in "${ops[@]}"; do echo "$i"; done | /usr/bin/dmenu -b )
[[ ! $option ]] && exit
case "$option" in
w3m) $TERM -e "w3m $url" ;;
news) vimb -p news "$url" ;;
mpv) $TERM --class=TERM -e "mpv --no-resume-playback --ytdl-format=18/43/best $url" ;;
vlc) $TERM --class=TERM -e "cvlc $url" ;;
video-play-download) $TERM --class=TERM -e "hotstar $url" ;;
## downlod with curl in current dir (home)
curl-download) $TERM -e "curl -g -L -J -O --user-agent Mozilla/5.0 $url" ;;
## save page as curl.html in Downloads
curl-save) $TERM -e "curl -L -o ~/Downloads/curl.html --user-agent Mozilla/5.0 $url" ;;
## save full page with wget, saved in Downloads
wget) $TERM --class=wget -e "wget --user-agent=Mozilla/5.0 --mirror -P $HOME/Downloads $url" ;;
# add bookmark
add-bookmark)
echo -e "news\nlinux\ncycling\nsocial\nshopping\ntravel" | rofi -dmenu -location 1 -l 6 -width 100 -p : -font "Inconsolata 14" -mesg "choose tag for bookmark" | read tag
## uncomment below for use with dmenu and comment out the upper line ##
# echo -e "news\nlinux\ncycling\nsocial\nshopping\ntravel\nmotors" | /usr/bin/dmenu -fn "Inconsolata 14" -p "choose tag" | read tag
echo "$url $tag" >> $BOOKMARKS ;;
## use any other external program with !chromium or !firefox or ?firefox etc.
def) notify-send "$( sdcv -n --data-dir ~/dic/english/ $url )" && exit ;;
guj) notify-send "$( sdcv -n --data-dir ~/dic/gujarati/ $url )" && exit ;;
*) $option "$url" ;;
esac