aboutsummaryrefslogtreecommitdiff
path: root/private_dot_local/bin/executable_linkmenu
blob: 32fd8df639d7a3a42f5eea33fad43b0cc510fa3b (plain)
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
94
95
96
#!/bin/sh

# If link is set in the first arg, use it
# Otherwise, read from stdin
if [ -n "$1" ]; then
    link="$1"
else
    read -r link
fi

tools="type
surf
surf-incognito
firefox
firefox-private
yt-dlp
yt-dlp-pl
yt-dlp-audio
mpv
mpv-audio
type
bookmark"

#[ "$1" = "dmenu" ] && tool="$(echo "$tools" | dmenu)" || tool="$1" # OLD VER
#tool="$(echo "$tools" | dmenu)"
tool="$(echo "$tools" | wofi -d)"



# Sed scripts to clean invidious links
# Fir"$TERM" one also removes playli"$TERM" context
#ytcleaner='s|(https://).*(/watch\?v=.{11}).*|\1youtube.com\2|'
#ytcleaner2='s|\(https://\).*/|\1youtube.com/|'
yt_prefix="https://youtube.com/watch?v="

case $tool in
"surf")
    notify-send -t 2000 "Opening in surf:" "$link"
    surf -s "$link"
    ;;
*surf-incognito)
    notify-send -t 2000 "Opening in surf:" "$link"
    surf-incognito -s "$link"
    ;;
*firefox)
    notify-send -t 2500 "Opening in Firefox:" "$link"
    firefox "$link"
    ;;
*firefox-private)
    notify-send -t 2500 "Opening in Firefox private:" "$link"
    firefox --private-window "$link"
    ;;
*yt-dlp)
    link="$yt_prefix${link##*watch?v=}"
    link="${link%%&list*}"
    #link="$(echo "$link" | sed -Ee "$ytcleaner")"
    notify-send -t 2500 "Downloading video:" "$link"
    "$TERM" -e /bin/sh -c "yt-dlp \"$link\"; sleep 5"
    ;;
*yt-dlp-pl)
    link="$yt_prefix${link##*watch?v=}"
    #link="$(echo "$link" | sed -e "$ytcleaner2")"
    notify-send -t 2500 "Downloading video:" "$link"
    "$TERM" -e /bin/sh -c "yt-dlp \"$link\"; sleep 5"
    ;;
*yt-dlp-audio)
    link="$yt_prefix${link##*watch?v=}"
    link="${link%%&list*}"
    #link="$(echo "$link" | sed -Ee "$ytcleaner")"
    notify-send -t 2500 "Downloading audio:" "$link"
    "$TERM" -e yt-dlp -f "ba*" -x --audio-format opus --remux-video opus "$link"
    ;;
*mpv)
    link="$yt_prefix${link##*watch?v=}"
    link="${link%%&list*}"
    #link="$(echo "$link" | sed -Ee "$ytcleaner")"
    notify-send -t 2500 "Playing video:" "$link"
    echo "$TERM"
    "$TERM" -e /bin/sh -c "mpv \"$link\"; sleep 5"
    #"$TERM" -e /bin/sh -c "mpv --ao=pulse \"$link\"; sleep 5"
    ;;
*mpv-audio)
    link="$yt_prefix${link##*watch?v=}"
    link="${link%%&list*}"
    #link="$(echo "$link" | sed -Ee "$ytcleaner")"
    notify-send -t 2500 "Playing audio:" "$link"
    "$TERM" -e mpv --no-video "$link"
    ;;
*type)
    notify-send -t 1000 "Typing" "$link"
    xdotool type "$link"
    ;;
*bookmark)
    save-bookmark "$link"
    ;;
esac