(osd "Hello, %s!" "word")

Jun 07, 2007 09:46


Привет. Однажды я писал про прикручивание osd_cat - X On Screen Display - к Emacs-овому джаббер клиенту.

Код возмужал, заматерел и вырос в отдельную функцию ‘osd':

;; --------------------------------------------------------------------- ;; On-Screen Display (OSD) alerts (if (and (display-graphic-p) (file-executable-p "/usr/bin/osd_cat")) (progn (defun osd-start () "Start \"osd_cat\" process. Do nothing if the process exists." (unless (get-process "osd_cat") (let ((process-connection-type nil)) (start-process-shell-command "osd_cat" nil "osd_cat" "--pos=bottom" "--align=right" "--lines=1" "--font='-adobe-helvetica-bold-r-*-*-34-*-*-*-*-*-iso10646-1'")))) (defun osd-kill () "Kill \"osd_cat\" process." (when (get-process "osd_cat") (process-send-eof "osd_cat") (delete-process "osd_cat"))) (defun osd (fmt &rest args) "Display message on X screen." (process-send-string "osd_cat" (apply 'format (concat fmt "\n") args))) (defadvice save-buffers-kill-emacs (before kill-osd-cat) "Kill \"osd_cat\" process before exiting Emacs." (osd-kill)) (osd-start)) ;; unable to run OSD (defalias 'osd 'ignore))
При старте Emacs запускается процесс "osd_cat", а уж в него пиши - сколько фантазия позволит.

Моя позволила писать из jabber.el:

;;; -------------------------------------------------------------------- ;;; OSD for jabber.el (when (get-process "osd_cat") (defun jabber-message-osd (from buffer text proposed-alert) "Display a message using the osd_cat program." (let ((jid (if (jabber-muc-sender-p from) from (jabber-jid-user from)))) (osd (cdr (jabber-activity-lookup-name jid))))) (add-hook 'jabber-alert-message-hooks 'jabber-message-osd))

.. и из Gnus:

;;; -------------------------------------------------------------------- ;;; OSD for Gnus (defun split-with-osd (split) (osd "Mail") split) (setq nnmail-split-methods 'nnmail-split-fancy nnmail-split-fancy '(| ("to\\|cc" "haskell-cafe@haskell.org" "mail.haskell-cafe") ("from" "\\(recruitment\\|xxxbreak\\)@xxx.com.ua" "mail.junk") ("to" "broadcast@xxx.com.ua" "mail.junk") (: split-with-osd "mail.misc")))

Happy on-screen displaying!
Previous post Next post
Up