~sircmpwn/dotfiles

ref: 0952c8392b47791670e378491a5cc6f9c99c9729 dotfiles/bin/stewdio -rwxr-xr-x 1.4 KiB View raw
                                                                                
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
#!/bin/sh

[ -e ~/.config/stewdio.conf ] && . ~/.config/stewdio.conf

if [ "$1" == "play" ]
then
    if [ -e "$XDG_RUNTIME_DIR/stewdio.fifo" ]
	then
        echo quit > "$XDG_RUNTIME_DIR/stewdio.fifo"
        rm "$XDG_RUNTIME_DIR/stewdio.fifo"
    else
        mkfifo "$XDG_RUNTIME_DIR/stewdio.fifo"
        mpv --input-file="$XDG_RUNTIME_DIR/stewdio.fifo" --no-audio-display --quiet \
            "https://$upstream/stream/stream256.opus?user=$USER" > /dev/null < /dev/null &
    fi
fi

if [ "$1" == "qfav" ]
then
    curl -s https://$upstream/api/request/favorite/$USER
fi

if [ "$1" == "skip" ]
then
    curl -s https://$upstream/api/skip
fi

if [ "$1" == "dmenu-queue" ]
then
    curl -s https://$upstream/api/queue | \
		jq '.[] | .artist + " - " + .title + " (" + .album + ")"' | \
		dmenu -p 'Queue:' -l 10
fi

if [ "$1" == "dmenu-search" ]
then
    touch ~/.config/stewdio-search-history
    terms=$(cat ~/.config/stewdio-search-history | tac | uniq \
		| dmenu -l 8 -p "Search:")
    if [ $? -eq 0 ]
    then
        echo "$terms" >> ~/.config/stewdio-search-history
        results=$(curl -s "https://$upstream/api/search/$terms")
        choice=$(echo "$results" | \
			jq -r '.[] | .hash[:6] + " " + .artist + " - " + .title + " (" + .album + ")"' | \
			dmenu -l 10)
        if [ $? -eq 0 ]
        then
            choice=$(echo "\"$choice\"" | jq -r '.[:6]')
            curl -s https://$upstream/api/request/$choice
        fi
    fi
fi