Christophe Weblog Wiki Code Publications Music
notifications on new song
authorChristophe Rhodes <csr21@cantab.net>
Sun, 7 Dec 2014 20:39:25 +0000 (20:39 +0000)
committerChristophe Rhodes <csr21@cantab.net>
Sun, 7 Dec 2014 20:39:25 +0000 (20:39 +0000)
it's rough and ready but does work

squeeze.el

index a255c603505d423bad69b812628e79daa50ac856..16fdb83a37836e6dfe87cef0fc61a5d7a0e4ad09 100644 (file)
@@ -98,6 +98,8 @@
               (and current (max 0 (min 100 (+ current number)))))
       (setf (squeeze-player-volume player) number))))
 
+(require 'notifications)
+
 (defun squeeze-update-state-from-line (string)
   (cond
    ((string-match "^players 0" string)
     (let ((substring (substring string (match-end 0)))
           (id (url-unhex-string (match-string 1 string))))
       (cond
+       ((string-match "^playlist newsong \\(.*\\) \\([0-9]+\\)$" substring)
+        (let ((value (save-match-data (url-unhex-string (match-string 1 substring))))
+              (index (url-unhex-string (match-string 2 substring))))
+          (notifications-notify :title "Now playing" :body (encode-coding-string (format "%s: %s" index value) 'utf-8)))
+        t)
        ((string-match "^power\\(?: \\([01]\\)\\)?" substring)
         (let ((state (match-string 1 substring))
               (player (squeeze-find-player id)))