-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathd-stuff
More file actions
executable file
·81 lines (73 loc) · 3.39 KB
/
d-stuff
File metadata and controls
executable file
·81 lines (73 loc) · 3.39 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
#!/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 'Link: ')}"
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 --ytdl-format='bestaudio' --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
}
ytdlf () {
yt-dlp -F "${feed}"
read -p "Choose format: " format
yt-dlp -f $format "${feed}"
}
menuopts=("Copy Url"
"Open via Fire Fox"
"Download Files via Aria2c"
"Media YT Vid Download"
"Media Audio Music Download"
"Podcast Listen Stream Song Music Mpd"
"View Image via swayimg"
"Play Watch Stream HQ"
"Misc Download.."
"Bookmark Url with tags"
"Open via Brave"
"Open via Mullvad"
"Open via Chromium"
"Torrent files via Aria"
"Ytfzf"
"Open Search Engine"
"Document Pdf/cbz Manga via Sioyek"
"Open via LibreWolf"
"Add Torrent via Transmission"
"Play Watch Stream LQ"
"CLI Youtube DL with Format Options"
"Get BibTex biblio reference"
)
case "$(printf '%s\n' "${menuopts[@]}" | sort | $D_MENU -p "Open in: " -mesg "=> ${shortfeed} : ")" in
"${menuopts[0]}") echo "${feed}" | wl-copy -n ;;
"${menuopts[1]}") setsid -f firefox "${feed}" >/dev/null 2>&1 ;;
"${menuopts[2]}") setsid aria2c -j 6 -x 16 -c -d "${XDG_DOWNLOAD_DIR}" "${feed}" >/dev/null 2>&1 ;;
"${menuopts[3]}") NQDIR=/tmp/yt-vid nq yt-dlp --embed-metadata --embed-subs -f "bestvideo[height<=1080]+bestaudio" -P "${XDG_VIDEOS_DIR}" "${feed}" >/dev/null 2>&1 ;;
"${menuopts[4]}") NQDIR=/tmp/yt-music nq yt-dlp -P "${XDG_MUSIC_DIR}" -icx --embed-metadata "${feed}" && mpc update ;;
"${menuopts[5]}") audio_podcast ;;
"${menuopts[6]}") (wget "${feed}" --output-document=/tmp/image && swayimg /tmp/image) || swayimg "${feed}" ;;
"${menuopts[7]}") NQDIR=/tmp/stream nq mpv -quiet "${feed}" >/dev/null 2>&1 ;;
"${menuopts[8]}") aria2c -j 6 -x 10 -c -d "${XDG_VIDEOS_DIR}" "${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]}") mpc add "$(yt-dlp -f bestaudio -g "$(ytfzf -LD $"{feed}")")" ;;
"${menuopts[15]}") d-search ;;
"${menuopts[16]}") sioyek "${feed}" ;;
"${menuopts[17]}") setsid librewolf "${feed}";;
"${menuopts[18]}") transmission-remote -a "${feed}";;
"${menuopts[19]}") NQDIR=/tmp/stream nq mpv --ytdl-format=18 -quiet "${feed}" >/dev/null 2>&1 ;;
"${menuopts[20]}") ytdlf;;
"${menuopts[21]}") d-bibtex "${feed}";;
*) exit 1 ;;
esac