help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [External] : Re: Is there a way to avoid clobbering minibuffer by me


From: Jean Louis
Subject: Re: [External] : Re: Is there a way to avoid clobbering minibuffer by messages?
Date: Thu, 30 Mar 2023 22:26:54 +0300
User-agent: Mutt/2.2.9+54 (af2080d) (2022-11-21)

* Eli Zaretskii <eliz@gnu.org> [2023-03-30 19:37]:
> Users can already choose between 1 and 2: see set-message-function.

I did this:

(setq set-message-function 'dunstify)

And now I get very visible message notifications on the desktop by
using program `dunst'. I can see much better what is going on in Emacs.

;;; Dunst

(defun rcd-pgrep-pid (program)
  "Return PID for PROGRAM by using system command `pgrep'."
  (let ((pgrep (executable-find "pgrep")))
    (rcd-unless pgrep
        "Can't find `pgrep' in $PATH"
      (let* ((pid (call-process-to-string pgrep nil nil "-x" program))
             (pid (string-trim pid))
             (pid (cond ((string= pid "") nil)
                        (t (string-to-number pid)))))
        pid))))

 (defvar dunst-pid nil
  "Keep `dunst' PID.")

(defun dunst-launch ()
  "Launch `dunst' notification daemon."
  (interactive)
  (let ((pid (rcd-pgrep-pid "dunst")))
    (cond (pid (rcd-warning-message (format "`dunst' notification daemon 
already running with PID %s" pid)))
          (t (setq dunst-pid pid)
             (start-process "*dunst*" "*dunst*" "dunst")))))

(defun dunstify (title &optional text urgency timeout appname)
  ;; appname urgency hints action timeout icon raw-icon print-id replace-id 
block)
  "Dunstify TITLE with optional TEXT."
  (let* ((dunstify (executable-find "dunstify"))
         (name (concat "*" dunstify "*"))
         (buffer name)
         (appname (cond (appname (list "-a" appname))
                        (t nil)))
         (timeout (cond (timeout (list "-t" (format "%s" timeout)))
                        (t "10000")))
         (urgency (cond (urgency (list "-u" (format "%s" urgency)))
                        (t nil)))
         (args (delq nil (append (list title) (flatten-list (list text appname 
timeout))))))
    (cond (dunstify 
           (apply #'start-process name buffer dunstify args))
          (t (rcd-warning-message "Program `dunstify' not found")))))

  ;; -u, --urgency=URG           The urgency of this notification
  ;; -h, --hints=HINT            User specified hints
  ;; -A, --action=ACTION         Actions the user can invoke
  ;; -i, --icon=ICON             An Icon that should be displayed with the 
notification
  ;; -I, --raw_icon=RAW_ICON     Path to the icon to be sent as raw image data
  ;; -p, --printid               Print id, which can be used to update/replace 
this notification
  ;; -r, --replace=ID            Set id of this notification.
  ;; -C, --close=ID              Close the notification with the specified ID
  ;; -b, --block                 Block until notification is closed and print 
close reason

--
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]