blob: 72a68ae2d185774b7edf9b907b9ea38abc8173c0 (
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
|
#!/usr/bin/env sh
# ── dwmblocks signal ─────────────────────────────────────────────────────────
pkill -RTMIN+21 dwmblocks
# ── Desktop notification ──────────────────────────────────────────────────────
TMP_DIR="/tmp/rmpc"
mkdir -p "$TMP_DIR"
ALBUM_ART_PATH="$TMP_DIR/notification_cover"
if ! rmpc albumart --output "$ALBUM_ART_PATH"; then
ALBUM_ART_PATH=""
fi
if [ -n "$ALBUM_ART_PATH" ]; then
notify-send -i "$ALBUM_ART_PATH" "Now Playing" "$ARTIST - $TITLE"
else
notify-send "Now Playing" "$ARTIST - $TITLE"
fi
# ── Play count ────────────────────────────────────────────────────────────────
sticker=$(rmpc sticker get "$FILE" "playCount" 2>/dev/null | jq -r '.value')
if [ -z "$sticker" ]; then
rmpc sticker set "$FILE" "playCount" "1"
else
rmpc sticker set "$FILE" "playCount" "$((sticker + 1))"
fi
# ── Auto lyrics download ──────────────────────────────────────────────────────
LRCLIB_INSTANCE="https://lrclib.net"
if [ "$HAS_LRC" = "false" ]; then
mkdir -p "$(dirname "$LRC_FILE")"
LYRICS="$(curl -X GET -sG \
-H "Lrclib-Client: rmpc-$VERSION" \
--data-urlencode "artist_name=$ARTIST" \
--data-urlencode "track_name=$TITLE" \
--data-urlencode "album_name=$ALBUM" \
"$LRCLIB_INSTANCE/api/get" | jq -r '.syncedLyrics')"
if [ -z "$LYRICS" ]; then
rmpc remote --pid "$PID" status "Failed to download lyrics for $ARTIST - $TITLE" --level error
exit
fi
if [ "$LYRICS" = "null" ]; then
rmpc remote --pid "$PID" status "Lyrics for $ARTIST - $TITLE not found" --level warn
exit
fi
echo "[ar:$ARTIST]" >"$LRC_FILE"
{
echo "[al:$ALBUM]"
echo "[ti:$TITLE]"
} >>"$LRC_FILE"
echo "$LYRICS" | sed -E '/^\[(ar|al|ti):/d' >>"$LRC_FILE"
rmpc remote --pid "$PID" indexlrc --path "$LRC_FILE"
rmpc remote --pid "$PID" status "Downloaded lyrics for $ARTIST - $TITLE" --level info
fi
|