-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmpvplayerwrapper
More file actions
executable file
·63 lines (56 loc) · 2.32 KB
/
Copy pathmpvplayerwrapper
File metadata and controls
executable file
·63 lines (56 loc) · 2.32 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
#!/usr/bin/env bash
menuopt=$(echo -e "Play\nAdd Links\nRemove Links\nAdd File\nQuit" | rofi -dmenu -i -theme dmenu -p "The Eestrecord:")
user=$(whoami)
[ ! -d "/home/$user/.config/mpv/playlists" ] && mkdir -p "/home/$user/.config/mpv/playlists" && touch "/home/$user/.config/mpv/playlists/playlists.txt"
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
if [ "$menuopt" == "Play" ]; then
playlistfile=$(
{
find "$HOME/.config/mpv/playlists" -type f 2>/dev/null | sed "s|^$HOME|~|"
} | rofi -dmenu -i -p "Load file"
)
[ -z $playlistfile ] && exit;
playlistfile="${playlistfile/#\~/$HOME}"
"${SCRIPT_DIR}/mpvmusicplayer" $playlistfile
exit
elif [ "$menuopt" == "Add Links" ]; then
linktype=$(echo -e "Video Link\nPlaylist Link With Preview\nChannel\nCustom Link" | rofi -dmenu -i -theme dmenu -p "Link type:")
[ -z $linktype ] && exit;
outlink=$("${SCRIPT_DIR}/playlistselector" "$linktype")
echo $outlink
[ -z $outlink ] && exit;
outfile=$(find "/home/$user/.config/mpv/playlists" -type f 2>/dev/null | sed "s/~/\/home\/$user/g" | rofi -dmenu -i -p "Out File:" -theme dmenu)
echo "$outlink" >> $outfile
elif [ "$menuopt" == "Remove Links" ]; then
outfile=$(find "/home/$user/.config/mpv/playlists" -type f 2>/dev/null | sed "s/~/\/home\/$user/g" | rofi -dmenu -i -p "Out File:" -theme dmenu)
[ -z $outfile ] && exit;
allLines=""
lines=$(wc -l < "$outfile")
for n in $(seq 1 $lines);
do
allLines+="${n} $(head -n $n "$outfile" | tail -1)\n"
done
allLines+="0 Full Clear"
lineselect=($(echo -e "$allLines" | rofi -dmenu -i -p "Select link"))
[ -z $lineselect ] && exit;
echo "${lineselect[0]}d"
sed -i "${lineselect[0]}d" "$outfile"
[ "${lineselect[0]}" == "0" ] && > "$outfile"
elif [ "$menuopt" == "Add File" ]; then
filename=$(find "/home/$user/.config/mpv/playlists" -type f 2>/dev/null | sed "s/.config\/mpv\/playlists\///g" | rofi -dmenu -i -p "File name:" -theme dmenu)
[ -z $filename ] && exit;
[[ "$filename" != *.* ]] && filename+=".txt"
echo $filename
filepath="/home/$user/.config/mpv/playlists/$filename"
i=1
while [[ -f $filepath ]]; do
tempfilename="${filename::-4}${i}.txt"
filepath="/home/$user/.config/mpv/playlists/$tempfilename"
i=$((i+1))
done
echo $filepath
touch $filepath
else
exit
fi
"${SCRIPT_DIR}/mpvplayerwrapper" & disown