chore(emacs): Orgnaise emacs modules in packages

This commit is contained in:
js0ny 2025-03-05 13:42:07 +00:00
parent 869e6ed042
commit 8f452172a5
5 changed files with 104 additions and 9 deletions

View file

@ -1,4 +1,3 @@
org-pomo-music.el
.custom.el .custom.el
local.el local.el
themes/ themes/

View file

@ -50,7 +50,7 @@
;; `load-theme' function. This is the default: ;; `load-theme' function. This is the default:
(setq doom-theme 'catppuccin) (setq doom-theme 'catppuccin)
(setq catppuccin-flavor 'mocha) (setq catppuccin-flavor 'mocha)
;(catppuccin-reload) ;(catppuccin-reload)
;; This determines the style of line numbers in effect. If set to `nil', line ;; 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'. ;; 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 ;; You can also try 'gd' (or 'C-c c d') to jump to their definition and see how
;; they are implemented. ;; they are implemented.
(add-to-list 'load-path (expand-file-name "lisp" doom-user-dir))
(after! wakatime-mode (after! wakatime-mode
(global-wakatime-mode) (global-wakatime-mode)
(setq wakatime-cli-path "~/.local/bin/wakatime")) (setq wakatime-cli-path "~/.local/bin/wakatime"))

View file

@ -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

View file

@ -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 'org-pomodoro)
(require 'request) (require 'request)
(defcustom org-pomodoro-telegram-bot-token "" (defcustom org-pomodoro-telegram-bot-token ""
"你的 Telegram Bot Token。" "Your Telegram bot token."
:type 'string :type 'string
:group 'org-pomodoro) :group 'org-pomodoro)
(defcustom org-pomodoro-telegram-chat-id "" (defcustom org-pomodoro-telegram-chat-id ""
"接收通知的 Telegram Chat ID。" "Your Telegram chat ID."
:type 'string :type 'string
:group 'org-pomodoro) :group 'org-pomodoro)
(defcustom org-pomodoro-telegram-break-end-message "休息时间结束" (defcustom org-pomodoro-telegram-break-end-message "休息时间结束"
"休息结束时发送的消息。" "The message to send when a break ends."
:type 'string :type 'string
:group 'org-pomodoro) :group 'org-pomodoro)
(defun org-pomodoro-send-telegram-message (message) (defun org-pomodoro-send-telegram-message (message)
"使用 Telegram bot 发送消息。" "Send a message to the Telegram chat.
MESSAGE is the message to send."
(interactive) (interactive)
(when (and (not (string-empty-p org-pomodoro-telegram-bot-token)) (when (and (not (string-empty-p org-pomodoro-telegram-bot-token))
(not (string-empty-p org-pomodoro-telegram-chat-id))) (not (string-empty-p org-pomodoro-telegram-chat-id)))
@ -40,7 +46,7 @@
) )
(defun org-pomodoro-telegram-break-finished-hook () (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)) (org-pomodoro-send-telegram-message org-pomodoro-telegram-break-end-message))
(add-hook 'org-pomodoro-break-finished-hook #'org-pomodoro-telegram-break-finished-hook) (add-hook 'org-pomodoro-break-finished-hook #'org-pomodoro-telegram-break-finished-hook)

View file

@ -199,7 +199,6 @@
(if (bound-and-true-p ISMAC) (if (bound-and-true-p ISMAC)
(setq org-babel-C-compiler "clang")) (setq org-babel-C-compiler "clang"))
(load! "+pomodoro-telegram.el")
;;; org-export ;;; org-export
@ -208,3 +207,14 @@
(setq org-icalendar-use-scheduled '(event-if-todo event-if-not-todo)) (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-use-deadline '(event-if-todo event-if-not-todo))
(setq org-icalendar-combined-agenda-file "~/Dropbox/org.ics") (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
)