emacs-使用Windows-Toasts的python库为Emacs创建Windows11通知提醒
安装pip包
pip install windows-toasts
在 ~/.emacs.d/
中新建 notify.py
,内容如下:
import sys,os from urllib.parse import unquote from windows_toasts import Toast, WindowsToaster, ToastDisplayImage toaster = WindowsToaster('Emacs Agenda') newToast = Toast() newToast.text_fields = [unquote(sys.argv[1])] newToast.AddImage(ToastDisplayImage.fromPath(unquote(sys.argv[2])+"/org/phone/emacs.png")) toaster.show_toast(newToast)
将先前的elisp函数 fw/appt-disp-windows
改为
(defun fw/appt-disp-windows (min-to-app new-time msg) "A custom `appt-disp-window-function' which uses the PowerShell module 'BurntToast'" (shell-command (concat "python -X utf8 "(file-truename user-emacs-directory) "notify.py " (url-encode-url msg )" " (url-encode-url (file-truename user-emacs-directory))))
经测试能正常提醒。使用python库的好处在于规避powershell的安装、策略设置过程,可以利用国内的pip镜像库,方便下载。