summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--media/jao-emms-info-track.el (renamed from emms/jao-emms-info-track.el)0
-rw-r--r--media/jao-emms-lyrics.el (renamed from emms/jao-emms-lyrics.el)0
-rw-r--r--media/jao-emms-random-album.el (renamed from emms/jao-emms-random-album.el)0
-rw-r--r--media/jao-emms.el (renamed from emms/jao-emms.el)0
-rw-r--r--media/jao-mpris.el128
-rw-r--r--media/jao-random-album.el (renamed from misc/jao-random-album.el)0
-rwxr-xr-xmedia/leoslyrics.py (renamed from emms/leoslyrics.py)0
-rwxr-xr-xmedia/lyricwiki.rb (renamed from emms/lyricwiki.rb)0
-rw-r--r--net/randomsig.el (renamed from misc/randomsig.el)6
-rw-r--r--readme.org2
-rw-r--r--sys/jao-ednc.el (renamed from misc/jao-ednc.el)3
-rw-r--r--sys/jao-minibuffer.el (renamed from misc/jao-minibuffer.el)0
12 files changed, 135 insertions, 4 deletions
diff --git a/emms/jao-emms-info-track.el b/media/jao-emms-info-track.el
index 728666d..728666d 100644
--- a/emms/jao-emms-info-track.el
+++ b/media/jao-emms-info-track.el
diff --git a/emms/jao-emms-lyrics.el b/media/jao-emms-lyrics.el
index 0ea52e0..0ea52e0 100644
--- a/emms/jao-emms-lyrics.el
+++ b/media/jao-emms-lyrics.el
diff --git a/emms/jao-emms-random-album.el b/media/jao-emms-random-album.el
index 72e056b..72e056b 100644
--- a/emms/jao-emms-random-album.el
+++ b/media/jao-emms-random-album.el
diff --git a/emms/jao-emms.el b/media/jao-emms.el
index 53b3513..53b3513 100644
--- a/emms/jao-emms.el
+++ b/media/jao-emms.el
diff --git a/media/jao-mpris.el b/media/jao-mpris.el
new file mode 100644
index 0000000..195ffce
--- /dev/null
+++ b/media/jao-mpris.el
@@ -0,0 +1,128 @@
+;;; jao-mpris.el --- mpris players control -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2020 jao
+
+;; Author: jao <mail@jao.io>
+;; Keywords: multimedia
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; controlling and showing info on mpris players
+
+;;; Code:
+
+(require 'dbus)
+(require 'jao-minibuffer)
+(require 'jao-emms-info-track)
+
+(defun jao-mpris--playerctl (&rest args)
+ (shell-command-to-string (format "playerctl %s"
+ (mapconcat #'shell-quote-argument args " "))))
+
+(defmacro jao-playerctl--def (name &rest args)
+ `(defun ,name () (interactive) (jao-mpris--playerctl ,@args)))
+
+(jao-playerctl--def jao-mpris-play-pause "play-pause")
+(jao-playerctl--def jao-mpris-next "next")
+(jao-playerctl--def jao-mpris-previous "previous")
+
+(defun jao-playerctl--status (&optional sep)
+ (let* ((sep (or sep " ||| "))
+ (fmt (mapconcat 'identity
+ '("{{status}}"
+ "{{xesam:trackNumber}}"
+ "{{title}}"
+ "{{artist}}"
+ "{{album}}"
+ "{{duration(mpris:length)}}")
+ sep))
+ (m (jao-mpris--playerctl "metadata" "--format" fmt)))
+ (split-string (car (split-string m "\n")) sep)))
+
+;;;###autoload
+(defun jao-mpris-status-times ()
+ (interactive)
+ (let ((m (jao-mpris--playerctl "metadata" "--format"
+ (concat "{{duration(position)}}/"
+ "{{duration(mpris:length)}}"))))
+ (jao-notify (string-trim m) "Playing")))
+
+;;;###autoload
+(defun jao-mpris-show-osd ()
+ (interactive)
+ (jao-notify jao-spotify-track-string))
+
+;;;###autoload
+(defun jao-mpris-artist-title ()
+ (when-let (s (jao-mpris--playerctl "metadata"
+ "--format"
+ "{{artist}}|||{{title}}"))
+ (let ((s (split-string (string-trim s) "|||")))
+ (cons (car s) (cadr s)))))
+
+(defvar jao-mpris-track-string "")
+
+(defun jao-mpris--track (&rest info)
+ (let ((cs (or info (jao-playerctl--status))))
+ (if (string= "Playing" (or (elt cs 0) ""))
+ (let* ((track (format "%s" (elt cs 1)))
+ (title (elt cs 2))
+ (artist (elt cs 3))
+ (album (elt cs 4))
+ (length (elt cs 5))
+ (duration (cond ((stringp length) length)
+ ((numberp length)
+ (jao-emms--fmt-time (/ length 1e6) "")))))
+ (setq jao-mpris-track-string
+ (format "♪ %s %s %s%s%s"
+ (jao--put-face track 'jao-emms-font-lock-track)
+ (jao--put-face title 'jao-emms-font-lock-title)
+ (jao--put-face artist 'jao-emms-font-lock-artist)
+ (jao--put-face (if album (format " (%s)" album) "")
+ 'jao-emms-font-lock-album)
+ (if duration (format " [%s]" duration) ""))))
+ (setq jao-mpris-track-string "")))
+ (jao-minibuffer-refresh))
+
+(jao-minibuffer-add-variable 'jao-mpris-track-string t)
+
+(defun jao-mpris--handler (iname properties &rest args)
+ (when properties
+ (let ((st (caadr (assoc "PlaybackStatus" properties)))
+ (md (caadr (assoc "Metadata" properties))))
+ (cond ((and st (not (string= "Playing" st)))
+ (setq jao-spotify-track-string ""))
+ (md (let ((tno (caadr (assoc "xesam:trackNumber" md)))
+ (tlt (caadr (assoc "xesam:title" md)))
+ (art (caaadr (assoc "xesam:artist" md)))
+ (alb (caadr (assoc "xesam:album" md)))
+ (len (caadr (assoc "mpris:length" md))))
+ (setq jao-debug md)
+ (jao-mpris--track "Playing" tno tlt art alb len)))))))
+
+
+;;;###autoload
+(defun jao-mpris-minibuffer-register (name &optional bus)
+ (dbus-register-signal (or bus :session)
+ name
+ "/org/mpris/MediaPlayer2"
+ "org.freedesktop.DBus.Properties"
+ "PropertiesChanged"
+ 'jao-mpris--handler))
+
+
+(provide 'jao-mpris)
+;;; jao-mpris.el ends here
diff --git a/misc/jao-random-album.el b/media/jao-random-album.el
index 7158417..7158417 100644
--- a/misc/jao-random-album.el
+++ b/media/jao-random-album.el
diff --git a/emms/leoslyrics.py b/media/leoslyrics.py
index 5e4f8c8..5e4f8c8 100755
--- a/emms/leoslyrics.py
+++ b/media/leoslyrics.py
diff --git a/emms/lyricwiki.rb b/media/lyricwiki.rb
index f163fa4..f163fa4 100755
--- a/emms/lyricwiki.rb
+++ b/media/lyricwiki.rb
diff --git a/misc/randomsig.el b/net/randomsig.el
index e092810..d07e676 100644
--- a/misc/randomsig.el
+++ b/net/randomsig.el
@@ -1,6 +1,6 @@
;;; randomsig.el --- insert a randomly selected signature
-;; Copyright (C) 2001, 2002, 2013 Hans-Jürgen Ficker
+;; Copyright (C) 2001, 2002, 2013, 2020 Hans-Jürgen Ficker
;; Emacs Lisp Archive Entry
;; Author: Hans-Juergen Ficker <hj@backmes.de>
@@ -171,7 +171,7 @@
;; * documentation updates
(eval-when-compile
- (require 'cl))
+ (require 'cl-lib))
(defconst randomsig-version "0.7.0")
@@ -264,7 +264,7 @@ You probably want to have a newline at the end of it."
;;; mark-active)) ; Gnu Emacs
-(require 'cl)
+(require 'cl-lib)
(random t) ; Initialize random seed
diff --git a/readme.org b/readme.org
index 28b7d55..363803c 100644
--- a/readme.org
+++ b/readme.org
@@ -2,7 +2,7 @@
- *themes* color themes based on Emacs builtin custom themes
- *org* utilities for org-mode
- - *emms* utilities for EMMS
+ - *media* utilities for music players and the like
- *prog* utilities for programming modes
- *skels* skeletons for source files
- *net* utilities for networking (w3m, weather &c.)
diff --git a/misc/jao-ednc.el b/sys/jao-ednc.el
index 48223d8..06ed986 100644
--- a/misc/jao-ednc.el
+++ b/sys/jao-ednc.el
@@ -52,6 +52,9 @@
(defun jao-ednc-add-handler (app handler)
(add-to-list 'jao-ednc--handlers (cons app handler)))
+(defun jao-ednc-ignore-app (app)
+ (jao-ednc-add-handler app (lambda (not _) (ednc-dismiss-notification not))))
+
(defun jao-ednc--default-handler (notification newp)
(if newp
(progn
diff --git a/misc/jao-minibuffer.el b/sys/jao-minibuffer.el
index 7104544..7104544 100644
--- a/misc/jao-minibuffer.el
+++ b/sys/jao-minibuffer.el