forked from Gavinok/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlinkhandler
More file actions
executable file
·37 lines (33 loc) · 1.36 KB
/
linkhandler
File metadata and controls
executable file
·37 lines (33 loc) · 1.36 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
#!/bin/sh
# Feed script a url.
# If an image, it will view in sxiv,
# if a video or gif, it will view in mpv
# if a music file or pdf, it will download,
# otherwise it opens link in browser.
# cant use environmental variables
# If no url given. Opens browser. For using script as $BROWSER.
OS="$(uname -o)" # this is for use with termux
if [ "$OS" = 'Android' ];then
[ -z "$1" ] && { xdg-open "https://duckduckgo.com"; exit; }
xdg-open "$1"
exit
fi
[ -z "$1" ] && { $TRUEBROWSER "https://duckduckgo.com"; exit; }
case "$1" in
*mkv|*webm|*mp4|*gif|*hooktube.com*)
setsid mpv -quiet "$1" >/dev/null 2>&1 &
/usr/bin/dunstify -t 500 "Playing Video";;
*youtube.com*|*youtu.be*) #limit the video quality
setsid tsp mpv -quiet --ytdl-format=18 "$1" >/dev/null 2>&1 &
/usr/bin/dunstify -t 500 "Playing from Youtube";;
*png|*jpg|*jpe|*jpeg)
curl -sL "$1" > "/tmp/$(echo "$1" | sed "s/.*\///")" && sxiv -a "/tmp/$(echo "$1" | sed "s/.*\///")" >/dev/null 2>&1 & ;;
*mp3|*m4a|*flac|*opus|*mp3?source)
setsid "$TERMINAL" -e mpv "$1" >/dev/null 2>&1 & ;;
*imgur.com/*)
setsid "$TRUEBROWSER" "$1" >/dev/null 2>&1 & ;;
*.diff|*.md|*.txt|*.c|*.h|*.cpp|*.hs|*.py|*raw*)
curl -sL "$1" > "/tmp/$(echo "$1" | sed "s/.*\///")" && "$TERMINAL" -t popup -e "$EDITOR" "/tmp/$(echo "$1" | sed "s/.*\///")" & ;;
*)
setsid "$TRUEBROWSER" "$1" >/dev/null 2>&1 & ;;
esac