设置由组织模式事件触发的警报(音频和视频)的好方法?


35

我想根据与特定时间(或开始时间)相关的组织模式事件来设置警报。理想情况下,这些将是音频和视频,并且可以在某种程度上进行自定义。我曾经使用过Sauron,但现在无法使其与组织模式事件(或电子邮件通知)一起使用。还有什么好的方法?

(我特别希望不仅可以通过通知守护程序在屏幕上显示通知,而且还可以通过语音(文本到语音)显示通知。我在Linux上。)



@康斯坦丁-这对我来说似乎很不一样。我并不是在寻求实现此目的的工具,而是已经存在的现成的解决方案。此外,我实际上对的不是DEADLINEs警报,而是与(开始)时间相关的事件感兴趣。
emacsomancer 2014年

好; 我编辑了我的评论。(我认为我们都同意您的问题与我所链接的问题有关。)
君士坦丁


2
如果您已经使用内置的appt系统使用函数从org-agenda文件中导入约会org-agenda-to-appt。然后,您可以自定义appt-disp-window-function以通知您所需的方式(可能包括调用外部程序)。
伊克巴尔·安萨里

Answers:


15

我对我使用的系统非常满意,该系统确实(确实)满足您的需求。它包括两个部分:使用appt.el安排提醒的Emacs部分和创建弹出式窗口和声音通知的小型Shell程序(我正在使用Linux)。在这里,我共享这两部分的代码。

A)〜/ .emacs.d / init.el中的代码

(require 'appt)
(appt-activate t)

(setq appt-message-warning-time 5) ; Show notification 5 minutes before event
(setq appt-display-interval appt-message-warning-time) ; Disable multiple reminders
(setq appt-display-mode-line nil)

; Use appointment data from org-mode
(defun my-org-agenda-to-appt ()
  (interactive)
  (setq appt-time-msg-list nil)
  (org-agenda-to-appt))

; Update alarms when...
; (1) ... Starting Emacs
(my-org-agenda-to-appt)

; (2) ... Everyday at 12:05am (useful in case you keep Emacs always on)
(run-at-time "12:05am" (* 24 3600) 'my-org-agenda-to-appt)

; (3) ... When TODO.txt is saved
(add-hook 'after-save-hook
          '(lambda ()
             (if (string= (buffer-file-name) (concat (getenv "HOME") "/ideas/TODO.txt"))
                 (my-org-agenda-to-appt))))

; Display appointments as a window manager notification
(setq appt-disp-window-function 'my-appt-display)
(setq appt-delete-window-function (lambda () t))

(setq my-appt-notification-app (concat (getenv "HOME") "/bin/appt-notification"))

(defun my-appt-display (min-to-app new-time msg)
  (if (atom min-to-app)
    (start-process "my-appt-notification-app" nil my-appt-notification-app min-to-app msg)
  (dolist (i (number-sequence 0 (1- (length min-to-app))))
    (start-process "my-appt-notification-app" nil my-appt-notification-app (nth i min-to-app) (nth i msg)))))

B)〜/ bin / appt-notification中的代码

#!/bin/sh

TIME="$1"
MSG="$2"

notify-send -t 0 "<br>Appointment in $TIME minutes:<br>$MSG<br>"
play "~/bin/alarm.wav"

要获取语音通知,您可以将以下行(播放)替换为以下内容:

espeak "Appointment in $TIME minutes: $MSG"

我在退出org-议程时添加了自动更新apps的情况: ; (4) ... Quitting org-agenda. (advice-add 'org-agenda-quit :after #'hw-org-agenda-to-appt)
holocronweaver

注意:午夜左右更新对于夜猫子很重要,因为它org-agenda-to-appt只会创建当天的appts。
holocronweaver

+1太好了。谢谢你的分享。我已经对此做了一些修改,以使用alert.el代替。但是,有一个问题:您是否有幸与org“ APPT_WARNTIME”属性一起使用来为每个事件设置自定义警告时间?我似乎无法正常工作。
Joseph R.

11

您可以在Emacs> 24中使用通知

(require 'notifications)

(notifications-notify :title "Achtung!"
                      :body (format "You have an appointment in %d minutes" 10)
                      :app-name "Emacs: Org"
                      :sound-name "alarm-clock-elapsed")

13
这似乎很有用。您知道如何与之集成org-mode吗?
erikstokes

2

我最终想到的是:

;;; org-to-appt

;; based on http://emacs-fu.blogspot.nl/2009/11/showing-pop-ups.html
(defun talky-popup (title msg &optional icon sound)  
  "Show a popup if we're on X, or echo it otherwise; TITLE is the title
of the message, MSG is the context. Optionally, you can provide an ICON and
a sound to be played"

  (interactive)
  ;;verbal warning



  (shell-command
   ;;  (concat "espeak -v mb-en1 -k5 -s125 " "'" title " " msg "'" " --stdout | paplay") ;; use local espeak
   (concat "echo " "'" title "'" " " "'" msg "'" " |text-to-speech en-gb")  ;; use remote Google voices
    ;; text-to-speech is from https://github.com/taylorchu/speech-to-text-text-to-speech
   )
  (if (eq window-system 'x)
    (shell-command (concat "notify-send -u critical -t 1800000  " 

                     (if icon (concat "-i " icon) "")
                     " '" title "' '" msg "'"))
    ;; text only version

    (message (concat title ": " msg))))

;; the appointment notification facility
(setq
  appt-message-warning-time 15 ;; warn 15 min in advance

  appt-display-mode-line t     ;; show in the modeline
  appt-display-format 'window) ;; use our func
(appt-activate 1)              ;; active appt (appointment notification)
(display-time)                 ;; time display is required for this...

 ;; update appt each time agenda opened

(add-hook 'org-finalize-agenda-hook 'org-agenda-to-appt)

;; our little façade-function for talky-popup
 (defun talky-appt-display (min-to-app new-time msg)
    (talky-popup (format "In %s minute(s):" min-to-app) msg 
  ;;    "/usr/share/icons/gnome/32x32/status/appointment-soon.png"   ;; optional icon

  ;;    "/usr/share/sounds/ubuntu/stereo/phone-incoming-call.ogg"    ;; optional sound

        ))
  (setq appt-disp-window-function (function talky-appt-display))

它与Scaramouche的设置并无不同。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.