-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathspotifyc
More file actions
executable file
·83 lines (74 loc) · 1.97 KB
/
Copy pathspotifyc
File metadata and controls
executable file
·83 lines (74 loc) · 1.97 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
82
83
#!/bin/bash
sc () { echo $@ | socat - UNIX-CONNECT:/tmp/spotifyd 2>/dev/null; }
export PULSE_LATENCY_MSEC=60
if [[ -n $(pidof spotifyd) ]]; then
echo "spotifyd already running"
else
echo "starting spotifyd"
spotifyd
fi
mainMenu () {
menu=("1. Search And Add Song(s)"
"2. Add Songs by Spotify URI"
"3. Show Queue"
"---"
"4. Load Playlist"
"---"
"5. Toggle Playback"
"6. Next"
"7. Previous"
"8. Clear Queue")
prompt() {
printf "%s\n" "$@" | rofi -dmenu -p "Select > "
}
case "$(prompt "${menu[@]}")" in
0:*) exit ;;
1.*) search ;;
2.*) addURI ;;
3.*) showQueue ;;
4.*) loadPlaylist ;;
5.*) sc pause && spotifyc ;;
6.*) sc next && spotifyc ;;
7.*) sc prev && spotifyc ;;
8.*) sc qclear && spotifyc ;;
*) exit
esac
}
search () {
query="$(echo "Enter Search Term" | rofi -dmenu -p "> ")"
list="$(sc search ${query})"
songlist="$(echo -e "Add all\n---\n$(echo "$list" | column -t -s '|'))" | rofi -dmenu -p "Select Song to Add to Queue > ")"
if [[ "$songlist" == "Add all" ]]; then
for i in $(echo "$list" | awk '{ print $1 }'); do
sc qadd "$i"
done
else
sc qadd "$(echo "$songlist" | awk '{ print $1 }')"
fi
if [[ -z $(sc qlist) ]]; then
sc play 0
else
echo ""
fi
spotifyc
}
addURI () {
menu=$(echo "Paste Spotify URI" | rofi -dmenu -p "> ")
sc link "$menu"
spotifyc
}
showQueue () {
if [[ -n $(sc qlist) ]]; then
songlist=$(sc qlist | column -t -s '|' | rofi -dmenu -p "Current Queue > ")
sc play "$songlist" | awk '{ print $1 }'
else
echo "Queue is empty" | rofi -dmenu -p "> "
fi
spotifyc
}
loadPlaylist () {
list="$(sc pl | column -t -s '|' | rofi -dmenu -p "Chose Playlist > ")"
sc qaddpl "$list" | awk '{ print $1 }'
spotifyc
}
mainMenu