summaryrefslogtreecommitdiff
path: root/rmpc/notify
diff options
context:
space:
mode:
Diffstat (limited to 'rmpc/notify')
-rwxr-xr-xrmpc/notify26
1 files changed, 26 insertions, 0 deletions
diff --git a/rmpc/notify b/rmpc/notify
new file mode 100755
index 0000000..84767d5
--- /dev/null
+++ b/rmpc/notify
@@ -0,0 +1,26 @@
+#!/usr/bin/env sh
+
+# Directory where to store temporary data
+TMP_DIR="/tmp/rmpc"
+
+# Ensure the directory is created
+mkdir -p "$TMP_DIR"
+
+# Where to temporarily store the album art received from rmpc
+ALBUM_ART_PATH="$TMP_DIR/notification_cover"
+
+# Path to fallback album art if no album art is found by rmpc/mpd
+# Change this to your needs
+DEFAULT_ALBUM_ART_PATH="$TMP_DIR/default_album_art.jpg"
+
+# Save album art of the currently playing song to a file
+if ! rmpc albumart --output "$ALBUM_ART_PATH"; then
+ # Use default album art if rmpc returns non-zero exit code
+ ALBUM_ART_PATH="${DEFAULT_ALBUM_ART_PATH}"
+fi
+
+MSG_TITLE=$(urlencode "$TITLE")
+MSG_ARTIST=$(urlencode "$ARTIST")
+
+# Integrates with hammerspoon, but use whatever terminal notifier you have set up.
+open "hammerspoon://canvasNotify?line1=$TITLE&line2=$ARTIST&duration=3"