From e12f7ff9ce79752c644e5a82b89068d65ea3df40 Mon Sep 17 00:00:00 2001 From: lemyx Date: Sun, 19 Jan 2025 22:28:23 +0800 Subject: [PATCH] Support org-pomodoro with desktop notification on macOS --- init.el | 7 ++--- install/install-macos.sh | 7 +++-- lisp/init-pomodoro.el | 54 ++++++++++++++++++++++++++++++++++++++ site-lisp/aider | 2 +- site-lisp/vertico-posframe | 2 +- 5 files changed, 65 insertions(+), 7 deletions(-) create mode 100644 lisp/init-pomodoro.el diff --git a/init.el b/init.el index 4fa1ea9..6c89c99 100644 --- a/init.el +++ b/init.el @@ -26,9 +26,6 @@ (require 'init-meow) (require 'init-dired) -;; Gtd -(require 'init-calendar) - ;; Reading (require 'init-english) @@ -48,6 +45,10 @@ (require 'init-tex) (require 'init-pdf) +;; Gtd +(require 'init-calendar) +(require 'init-pomodoro) + (require 'init-session) (emacs-session-restore) diff --git a/install/install-macos.sh b/install/install-macos.sh index 257960c..3c6730f 100644 --- a/install/install-macos.sh +++ b/install/install-macos.sh @@ -14,7 +14,7 @@ fi # emacs brew tap d12frosted/emacs-plus brew uninstall emacs-plus -brew install emacs-plus --with-xwidgets --with-imagemagick +brew install emacs-plus --with-xwidgets --with-imagemagick --with-dbus --with-ctags brew services restart d12frosted/emacs-plus/emacs-plus@29 osascript -e 'tell application "Finder" to make alias file to posix file "/opt/homebrew/opt/emacs-plus@29/Emacs.app" at POSIX file "/Applications" with properties {name:"Emacs.app"}' @@ -29,9 +29,9 @@ brew install node npm install -g yaml-language-server npm install -g bash-language-server npm install -g vscode-langservers-extracted -npm install -g pyright pip3 install ruff-lsp --break-system-packages brew install texlab +brew install basedpyright # aider brew install aider @@ -40,5 +40,8 @@ brew install aider brew install --cask squirrel brew install librime +# pomodoro +brew install terminal-notifier + # fetch submodules git submodule update --init diff --git a/lisp/init-pomodoro.el b/lisp/init-pomodoro.el new file mode 100644 index 0000000..dce77a4 --- /dev/null +++ b/lisp/init-pomodoro.el @@ -0,0 +1,54 @@ +;;; init-pomodoro.el --- Pomodoro settings -*- lexical-binding: t -*- +;;; Commentary: + +;;; Code: + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; org-pomodoro +(use-package org-pomodoro + :custom-face + (org-pomodoro-mode-line ((t (:inherit warning)))) + (org-pomodoro-mode-line-overtime ((t (:inherit error)))) + (org-pomodoro-mode-line-break ((t (:inherit success)))) + :bind (:map org-mode-map + ("C-c C-x m" . org-pomodoro)) + :init + (with-eval-after-load 'org-agenda + (bind-keys :map org-agenda-mode-map + ("K" . org-pomodoro) + ("C-c C-x m" . org-pomodoro)))) + +;; https://github.com/devbins/.emacs.d/blob/5341a41e2b100c1228eb2438aa5a83927857cfb0/lisp/init-func.el#L335 +(defun notify-osx (title msg) + (call-process "terminal-notifier" + nil 0 nil + "-group" "Emacs" + "-title" title + ;; "-sender" "org.gnu.Emacs" + "-message" msg + "-sound" "Glass" + "-active" "org.gnu.Emacs")) +;; org-pomodoro mode hooks +(add-hook 'org-pomodoro-started-hook + (lambda () + (notify-osx "Pomodoro started!" "Time for a pomodoro."))) + +(add-hook 'org-pomodoro-finished-hook + (lambda () + (notify-osx "Pomodoro completed!" "Time for a break."))) + +(add-hook 'org-pomodoro-break-finished-hook + (lambda () + (notify-osx "Pomodoro Short Break Finished" "Ready for Another?"))) + +(add-hook 'org-pomodoro-long-break-finished-hook + (lambda () + (notify-osx "Pomodoro Long Break Finished" "Ready for Another?"))) + +(add-hook 'org-pomodoro-killed-hook + (lambda () + (notify-osx "Pomodoro Killed" "One does not simply kill a pomodoro!"))) + +(provide 'init-pomodoro) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; init-pomodoro.el ends here diff --git a/site-lisp/aider b/site-lisp/aider index a7f2153..a256968 160000 --- a/site-lisp/aider +++ b/site-lisp/aider @@ -1 +1 @@ -Subproject commit a7f21534522a725259cf2efd46837d7bd88ec231 +Subproject commit a256968d1faaf2936d12696a364158df56931cdb diff --git a/site-lisp/vertico-posframe b/site-lisp/vertico-posframe index 425ff7c..781ee08 160000 --- a/site-lisp/vertico-posframe +++ b/site-lisp/vertico-posframe @@ -1 +1 @@ -Subproject commit 425ff7cb89a76e08878d13743728a14a38da98ab +Subproject commit 781ee08f8d92f640dff8a0d8838b67a13a391846