-
Notifications
You must be signed in to change notification settings - Fork 0
/
d-stuff
executable file
·69 lines (62 loc) · 2.92 KB
/
d-stuff
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
#!/usr/bin/env bash
# Link handler for every thinkable purpose
# I use `nq` for task scheduling with mpv
source d-var.conf
feed="${1:-$(printf "$(wl-paste -p)\n$(wl-paste)" | $D_MENU -i -p ' ')}"
# echo "$feed" | wl-copy -n
# For prompt/notify on chosen link
shortfeed="$(echo ${feed} | cut -d '/' -f3,4,5,6 )"
# Aria2 for torrents (acts on rpc server)
aria_tor () {
curl 'http://localhost:6800/jsonrpc' || setsid aria2c --enable-rpc --rpc-listen-all &
sleep 4 && curl http://localhost:6800/jsonrpc -d '{"jsonrcp":"2.0","id":"someID","method":"aria2.addUri","params":["token:ariatest",["'${feed}'"]]}'
}
audio_podcast () {
case "$(printf "Song\nPodcast" | $D_MENU -p ' ')" in
"Podcast") mpc pause; NQDIR=/tmp/podcast nq mpv --force-window --geometry=15% --title=podcast --vid=1 "${feed}" >/dev/null 2>&1 ;;
"Song") pgrep mpd || mpd; mpc add "$(yt-dlp -f bestaudio -g "${feed}")" ;;
*) exit 1 ;;
esac
}
menuopts=(" Copy Url"
" Fire Fox"
" Download Files"
" YT Vid Download"
" Audio Music Download"
" Podcast Listen Stream"
" View Image"
" Play Watch Stream"
" Misc Download"
" Bookmark"
" Brave"
" Mullvad"
" Chromium"
" Torrent Aria"
" YT Music"
" Search Engine"
" Document Viewer"
" LibreWolf"
" Transmission"
)
case "$(printf '%s\n' "${menuopts[@]}" | sort | $D_MENU -p ${shortfeed})" in
"${menuopts[0]}") echo "${feed}" | wl-copy -p ;;
"${menuopts[1]}") setsid -f firefox "${feed}" >/dev/null 2>&1 ;;
"${menuopts[2]}") setsid aria2c -j 6 -x 16 -c -d ~/dloads "${feed}" >/dev/null 2>&1 ;;
"${menuopts[3]}") NQDIR=/tmp/yt-vid nq yt-dlp --embed-metadata --embed-subs -f "bestvideo[height<=1080]+bestaudio" -P ~/vids/yt "${feed}" >/dev/null 2>&1 ;;
"${menuopts[4]}") NQDIR=/tmp/yt-music nq yt-dlp -P ~/d-sync/music/yt/ -icx --embed-metadata "${feed}" && pidof -x mpd || mpd && mpc update ;;
"${menuopts[5]}") audio_podcast ;;
"${menuopts[6]}") (wget "${feed}" --output-document=/tmp/image && imv /tmp/image) || imv "${feed}" ;;
"${menuopts[7]}") NQDIR=/tmp/stream nq mpv -quiet "${feed}" >/dev/null 2>&1 ;;
"${menuopts[8]}") aria2c -j 6 -x 10 -c -d ~/vids/documentary/.cache/clean.db/ "${feed}" ;;
"${menuopts[9]}") d-bookmark "${feed}" ;;
"${menuopts[10]}") setsid brave "${feed}" ;;
"${menuopts[11]}") setsid mullvad-browser "${feed}" ;;
"${menuopts[12]}") setsid chromium "${feed}" ;;
"${menuopts[13]}") aria_tor ;;
"${menuopts[14]}") pgrep mpd || mpd; mpc add "$(yt-dlp -f bestaudio -g "$(ytfzf -LD ${feed})")" && mpc play ;;
"${menuopts[15]}") d-search ;;
"${menuopts[16]}") sioyek ${feed} ;;
"${menuopts[17]}") setsid librewolf "${feed}";;
"${menuopts[18]}") transmission-remote -a "${feed}";;
*) exit 1 ;;
esac