diff --git a/tools/doom/.gitignore b/tools/doom/.gitignore index e3c05d7..72f4c75 100644 --- a/tools/doom/.gitignore +++ b/tools/doom/.gitignore @@ -1,4 +1,3 @@ -org-pomo-music.el .custom.el local.el themes/ diff --git a/tools/doom/config.el b/tools/doom/config.el index 3c55b39..26e85f9 100644 --- a/tools/doom/config.el +++ b/tools/doom/config.el @@ -50,7 +50,7 @@ ;; `load-theme' function. This is the default: (setq doom-theme 'catppuccin) (setq catppuccin-flavor 'mocha) -;(catppuccin-reload) + ;(catppuccin-reload) ;; This determines the style of line numbers in effect. If set to `nil', line ;; numbers are disabled. For relative line numbers, set this to `relative'. @@ -92,6 +92,9 @@ ;; You can also try 'gd' (or 'C-c c d') to jump to their definition and see how ;; they are implemented. +(add-to-list 'load-path (expand-file-name "lisp" doom-user-dir)) + + (after! wakatime-mode (global-wakatime-mode) (setq wakatime-cli-path "~/.local/bin/wakatime")) diff --git a/tools/doom/lisp/org-pomodoro-music-controller.el b/tools/doom/lisp/org-pomodoro-music-controller.el new file mode 100644 index 0000000..932b1d4 --- /dev/null +++ b/tools/doom/lisp/org-pomodoro-music-controller.el @@ -0,0 +1,77 @@ +;;; org-pomodoro-music-controller.el --- Play music during org-pomodoro breaks -*- lexical-binding: t; -*- + +;;; Commentary: +;;; Add music control to org-pomodoro breaks. + +;;; Code: + +(require 'org-pomodoro) + +;; Variables +(defcustom org-pomodoro-music-player-command "playerctl" + "Command to control the music player." + :type 'string + :group 'org-pomodoro) + +(defcustom org-pomodoro-music-player-args nil + "Arguments to pass to the music player command." + :type '(repeat string) + :group 'org-pomodoro) + + +(defun org-pomodoro-music-get-status () + "Get thestatus of the music player." + (with-temp-buffer + (let ((args (append org-pomodoro-music-player-args '("status")))) + (apply #'call-process org-pomodoro-music-player-command nil t nil args) + (string-trim (buffer-string))))) + +(defun org-pomodoro-music-is-playing-p () + "Check if the music player is playing." + (let ((status (org-pomodoro-music-get-status))) + (string= status "Playing"))) + +(defun org-pomodoro-music-pause () + "Stop the music player." + (let ((args (append org-pomodoro-music-player-args '("pause")))) + (apply #'call-process org-pomodoro-music-player-command nil nil nil args))) + +(defun org-pomodoro-music-play () + "Start the music player." + (let ((args (append org-pomodoro-music-player-args '("play")))) + (apply #'call-process org-pomodoro-music-player-command nil nil nil args))) + +;; Defining Hooks +(defun org-pomodoro-music-break-started-hook () + "When a break start, pause the music player." + (setq org-pomodoro-music-was-playing (org-pomodoro-music-is-playing-p)) + (when org-pomodoro-music-was-playing + (org-pomodoro-music-pause) + (message "休息开始,音乐已暂停"))) + +;; (defun org-pomodoro-music-break-finished-hook () +;; "When a break finishes, resume the music player." +;; (when (and org-pomodoro-music-was-playing +;; (not (org-pomodoro-music-is-playing-p))) +;; (org-pomodoro-music-play) +;; (message "休息结束,音乐已恢复播放")) +;; (setq org-pomodoro-music-was-playing nil)) + +(defun org-pomodoro-music-started-hook () + "When a pomodoro start, play the music player." + (unless (org-pomodoro-music-is-playing-p) + (org-pomodoro-music-play) + (message "番茄开始,音乐已开始播放")) + ) + +;; Adding hooks +;; (add-hook 'org-pomodoro-break-started-hook #'org-pomodoro-music-break-started-hook) +;; (add-hook 'org-pomodoro-break-finished-hook #'org-pomodoro-music-break-finished-hook) + +;; (add-hook 'org-pomodoro-long-break-started-hook #'org-pomodoro-music-break-started-hook) +;; (add-hook 'org-pomodoro-long-break-finished-hook #'org-pomodoro-music-break-finished-hook) + +(add-hook 'org-pomodoro-started-hook #'org-pomodoro-music-started-hook) + +(provide 'org-pomodoro-music-controller) +;;; org-pomodoro-music-controller.el ends here diff --git a/tools/doom/+pomodoro-telegram.el b/tools/doom/lisp/org-pomodoro-telegram-notifier.el similarity index 77% rename from tools/doom/+pomodoro-telegram.el rename to tools/doom/lisp/org-pomodoro-telegram-notifier.el index f29a483..27aa6e3 100644 --- a/tools/doom/+pomodoro-telegram.el +++ b/tools/doom/lisp/org-pomodoro-telegram-notifier.el @@ -1,25 +1,31 @@ -;;; org-pomodoro-telegram-notifier.el --- 发送 Telegram 通知当 org-pomodoro 休息结束 +;;; org-pomodoro-telegram-notifier.el --- 为 org-pomodoro 添加发送 Telegram 通知的功能。 -*- lexical-binding: t; -*- + +;;; Commentary: +;;; Provide a way to send Telegram notifications when org-pomodoro breaks end. + +;;; Code: (require 'org-pomodoro) (require 'request) (defcustom org-pomodoro-telegram-bot-token "" - "你的 Telegram Bot Token。" + "Your Telegram bot token." :type 'string :group 'org-pomodoro) (defcustom org-pomodoro-telegram-chat-id "" - "接收通知的 Telegram Chat ID。" + "Your Telegram chat ID." :type 'string :group 'org-pomodoro) (defcustom org-pomodoro-telegram-break-end-message "休息时间结束" - "休息结束时发送的消息。" + "The message to send when a break ends." :type 'string :group 'org-pomodoro) (defun org-pomodoro-send-telegram-message (message) - "使用 Telegram bot 发送消息。" + "Send a message to the Telegram chat. +MESSAGE is the message to send." (interactive) (when (and (not (string-empty-p org-pomodoro-telegram-bot-token)) (not (string-empty-p org-pomodoro-telegram-chat-id))) @@ -40,7 +46,7 @@ ) (defun org-pomodoro-telegram-break-finished-hook () - "当休息时间结束时发送 Telegram 通知。" + "Send a Telegram message when a break ends." (org-pomodoro-send-telegram-message org-pomodoro-telegram-break-end-message)) (add-hook 'org-pomodoro-break-finished-hook #'org-pomodoro-telegram-break-finished-hook) diff --git a/tools/doom/org.el b/tools/doom/org.el index 8dcb04b..a367d52 100644 --- a/tools/doom/org.el +++ b/tools/doom/org.el @@ -199,7 +199,6 @@ (if (bound-and-true-p ISMAC) (setq org-babel-C-compiler "clang")) -(load! "+pomodoro-telegram.el") ;;; org-export @@ -208,3 +207,14 @@ (setq org-icalendar-use-scheduled '(event-if-todo event-if-not-todo)) (setq org-icalendar-use-deadline '(event-if-todo event-if-not-todo)) (setq org-icalendar-combined-agenda-file "~/Dropbox/org.ics") + + +(use-package! org-pomodoro-music-controller + :after org-pomodoro + :config + (customize-set-variable 'org-pomodoro-music-player-args '("--player=cider")) + ) + +(use-package! org-pomodoro-telegram-notifier + :after org-pomodoro + )