summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2025-10-01 17:23:20 +0100
committerjao <jao@gnu.org>2025-10-01 17:23:50 +0100
commit3e96ae1ade23eee42b63ed047682b7cbf430f7d8 (patch)
tree886508504f2d17f9f717557b1e23fce5135dae3b
parent1a54f3532dcd812b5b4c1c1ecfcf366d9aa10669 (diff)
downloadelibs-3e96ae1ade23eee42b63ed047682b7cbf430f7d8.tar.gz
elibs-3e96ae1ade23eee42b63ed047682b7cbf430f7d8.tar.bz2
jao-mpc tweaks (mainly notifications)
-rw-r--r--custom/jao-custom-multimedia.el8
-rw-r--r--init.el21
-rw-r--r--lib/doc/jao-mac.el9
-rw-r--r--lib/eos/jao-notify.el31
-rw-r--r--lib/media/jao-mpc.el15
5 files changed, 55 insertions, 29 deletions
diff --git a/custom/jao-custom-multimedia.el b/custom/jao-custom-multimedia.el
index 9f421d7..aab9cf1 100644
--- a/custom/jao-custom-multimedia.el
+++ b/custom/jao-custom-multimedia.el
@@ -97,18 +97,12 @@
(interactive "P")
(jao-show-lyrics force #'jao-mpris-artist-title))
-(defun jao-mpris-mopidy-p () (string= "mopidy "jao-mpris-player))
-
-(defun jao-mpc-mopidy-playlist ()
- (interactive)
- (jao-mpc-show-playlist jao-mopidy-port))
-
(use-package jao-mpris :demand t)
(defun jao-mpris-setup-aliases ()
(setq espotify-play-uri-function #'espotify-play-uri-with-dbus)
;; (setq jao-mpris-player "mopidy")
- (defalias 'jao-streaming-list #'jao-mpc-mopidy-playlist)
+ (defalias 'jao-streaming-list #'jao-mpc-show-playlist)
(defalias 'jao-streaming-lyrics #'jao-mpris-lyrics)
(defalias 'jao-streaming-toggle #'jao-mpris-play-pause)
(defalias 'jao-streaming-next #'jao-mpris-next)
diff --git a/init.el b/init.el
index 7434c2f..ff43e11 100644
--- a/init.el
+++ b/init.el
@@ -597,7 +597,7 @@
;;;; jao-notify
(use-package jao-notify
:demand t
- :init (setq jao-notify-use-messages t))
+ :init (setq jao-notify-use-messages (jao-d-l 'mac t)))
;;;; tracking
(use-package tracking
@@ -1668,7 +1668,7 @@
(jao-defun-play next)
(jao-defun-play previous)
(jao-defun-play stop)
-(jao-defun-play echo echo-current-times)
+(jao-defun-play echo echo-current)
(jao-defun-play list show-playlist)
(jao-defun-play info lyrics-track-data)
(jao-defun-play browse show-albums)
@@ -1687,23 +1687,24 @@
(defun jao-player-seek-10 () (interactive) (jao-player-seek 10))
(defun jao-player-seek--10 () (interactive) (jao-player-seek -10))
-(defun jao-streaming-clear () (interactive) (jao-mpc-clear jao-mopidy-port))
+(defun jao-streaming-clear () (interactive) (jao-mpc-clear))
(defun jao-streaming-echo-current ()
(interactive)
- (jao-mpc-echo-current jao-mopidy-port))
+ (jao-d-l (let ((inhibit-message t)) (jao-mpc-notify))
+ (jao-mpc-echo-current)))
(defun jao-streaming-show-playlist ()
(interactive)
- (jao-mpc-show-playlist jao-mopidy-port))
+ (jao-mpc-show-playlist))
(use-package jao-random-album
:demand t
:config
(defun jao--notify-album (album)
- (unless jao-minibuffer-mode
- (jao-notify album "Next album" jao-notify-audio-icon))
- (jao-minibuffer-refresh))
+ (if jao-minibuffer-mode
+ (jao-minibuffer-refresh)
+ (jao-notify album "Next album" jao-notify-audio-icon "")))
(setq jao-random-album-notify #'jao--notify-album))
(transient-define-prefix jao-transient-media ()
@@ -1721,7 +1722,7 @@
("b" "browse" jao-player-browse)
("l" "show play list" jao-player-list)
("L" "show lyrics" jao-show-lyrics)
- ("w" "now playing" jao-player-echo)]
+ ("w" "now playing" jao-streaming-echo-current)]
[:description
(lambda ()
(message "mpd %s" (if (jao-mpc-playing-p)
@@ -1747,7 +1748,7 @@
(global-set-key (kbd "s-m") #'jao-transient-media)
-(jao-mpc-setup nil 70)
+(jao-mpc-setup nil (jao-when-linux 70))
;;; Graphical window system
diff --git a/lib/doc/jao-mac.el b/lib/doc/jao-mac.el
index b9da4ab..06d6ad3 100644
--- a/lib/doc/jao-mac.el
+++ b/lib/doc/jao-mac.el
@@ -20,7 +20,7 @@
(require 'jao-shell)
-;;; Applescript
+;;; applescript
(defun jao-mac-applescript-prepare (&rest lines)
(let ((script (mapconcat 'identity lines "\r"))
(start))
@@ -74,6 +74,13 @@
(format "keystroke %s" (or page 1))
"delay 0.1\rkeystroke return\rend tell")))
+;;; notifications
+
+(defun jao-mac-notify (title subtitle msg)
+ (jao-mac-run-applescript*
+ (format "display notification %S with title %S subtitle %S"
+ msg title subtitle)))
+
;;; Skim
(defvar jao-skim--current-file-script
(jao-mac-applescript-prepare
diff --git a/lib/eos/jao-notify.el b/lib/eos/jao-notify.el
index 623b8cc..8389b3a 100644
--- a/lib/eos/jao-notify.el
+++ b/lib/eos/jao-notify.el
@@ -1,6 +1,6 @@
;; jao-notify.el -- Interacting with notification daemon
-;; Copyright (c) 2017, 2019, 2020, 2021, 2024 Jose Antonio Ortega Ruiz
+;; Copyright (c) 2017, 2019, 2020, 2021, 2024, 2025 Jose Antonio Ortega Ruiz
;; Author: Jose Antonio Ortega Ruiz <jao@gnu.org>
;; Start date: Sun Jan 08, 2017 20:24
@@ -17,21 +17,30 @@
(defvar jao-notify-audio-icon (jao-data-file "music-player-icon.png"))
(declare-function notifications-notify "notifications")
+(declare-function alert "alert")
+(declare-function jao-mac-notify "jao-mac")
;; "/usr/share/icons/Papirus/64x64/mimetypes/audio-x-generic.svg"
;; "/usr/share/icons/Tango/scalable/mimetypes/audio-x-generic.svg"
-(defun jao-notify (msg &optional title icon)
+(defun jao-notify (msg &optional title icon subtitle)
(let ((title (when (and title (not (string-blank-p title))) title)))
- (if jao-notify-use-messages
- (message "%s%s%s" (or title "") (if title ": " "") (or msg ""))
- (let* ((args `(:timeout ,jao-notify-timeout))
- (args (append args
- (if title `(:title ,title :body ,msg) `(:title ,msg))))
- (args (if (and (stringp icon) (file-exists-p icon))
- (append args `(:app-icon ,(format "%s" icon)))
- args)))
- (apply 'notifications-notify args)))))
+ (cond ((eq jao-notify-use-messages t)
+ (message "%s%s%s" (or title "") (if title ": " "") (or msg "")))
+ ((eq jao-notify-use-messages 'notification)
+ (let* ((args `(:timeout ,jao-notify-timeout))
+ (args (append args
+ (if title
+ `(:title ,title :body ,msg)
+ `(:title ,msg))))
+ (args (if (and (stringp icon) (file-exists-p icon))
+ (append args `(:app-icon ,(format "%s" icon)))
+ args)))
+ (apply 'notifications-notify args)))
+ ((eq jao-notify-use-messages 'alert)
+ (alert msg :title title :icon icon :never-persist t))
+ ((eq jao-notify-use-messages 'mac)
+ (jao-mac-notify title subtitle msg)))))
(provide 'jao-notify)
diff --git a/lib/media/jao-mpc.el b/lib/media/jao-mpc.el
index 82c38ba..2dfec76 100644
--- a/lib/media/jao-mpc.el
+++ b/lib/media/jao-mpc.el
@@ -30,6 +30,7 @@
(require 'jao-themes)
(require 'jao-lyrics)
(require 'jao-random-album)
+(require 'jao-notify)
(defconst jao-mpc--albums "*MPC Albums*")
(defconst jao-mpc--playlist "*MPC Playlist*")
@@ -257,6 +258,20 @@
(message "Playing time: %s" (jao-mpc--current-timestr t)))
;;;###autoload
+(defun jao-mpc-notify (&optional port)
+ (interactive)
+ (when-let* ((current (jao-mpc--current)))
+ (let* ((artist (alist-get 'artist current))
+ (title (alist-get 'title current))
+ (album (alist-get 'album current))
+ (track (alist-get 'track current))
+ (times (jao-mpc--current-timestr t current)))
+ (jao-notify (format "%s -- %s" artist times)
+ (format "%s %s" track title)
+ jao-notify-audio-icon
+ album))))
+
+;;;###autoload
(defun jao-mpc-add-url (url)
(interactive "sURL: ")
(jao-mpc--cmd (format "add %s" url)))