aboutsummaryrefslogtreecommitdiff
path: root/modules/home-manager/emacs/config/lisp/timer.el
diff options
context:
space:
mode:
Diffstat (limited to 'modules/home-manager/emacs/config/lisp/timer.el')
-rw-r--r--modules/home-manager/emacs/config/lisp/timer.el25
1 files changed, 25 insertions, 0 deletions
diff --git a/modules/home-manager/emacs/config/lisp/timer.el b/modules/home-manager/emacs/config/lisp/timer.el
new file mode 100644
index 0000000..359fe28
--- /dev/null
+++ b/modules/home-manager/emacs/config/lisp/timer.el
@@ -0,0 +1,25 @@
+;;; timer.el - Sends you a notification after a certain time
+
+(defun timer-do-alert (title body)
+ "Uses `message' and `notifications-notify' to send an alert"
+ (message (format "%s - %s" title body))
+ (notifications-notify :title title :body body))
+
+(defun timer-alert (delay body)
+ "Sends an alert after DELAY containing the message BODY."
+ (interactive "sDelay: \nsBody: ")
+ (let (seconds minutes hours num-string)
+ (dolist (char (delete "" (split-string "3s" "")))
+ (if (seq-contains-p (delete "" (split-string "0123456789" "")) char)
+ (setq num-string (concat num-string char))
+ (progn (cond ((equal char "s") (setq seconds (string-to-number num-string)))
+ ((equal char "m") (setq minutes (string-to-number num-string)))
+ ((equal char "h") (setq hours (string-to-number num-string))))
+ (setq num-string ""))))
+ (unless seconds
+ (setq seconds 0))
+ (unless minutes
+ (setq minutes 0))
+ (unless hours
+ (setq hours 0))
+ (run-at-time (format "%s sec %s min %s hour" seconds minutes hours) nil 'timer-do-alert "Emacs alert" body)))