summaryrefslogtreecommitdiff
path: root/rmpc/notify
diff options
context:
space:
mode:
authoranand <anand.panchdhari@gmail.com>2025-12-17 15:57:55 +0530
committeranand <anand.panchdhari@gmail.com>2025-12-17 15:57:55 +0530
commitb7ef29a8886a57aadb787807a7c6cf74c1f0ed3a (patch)
tree366a68240fbc9da6b1d567bd6c46d1350ad814de /rmpc/notify
Nixos
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"