Adds the alert-me stumpwm module.

This commit is contained in:
Florian MARGAINE 2015-08-18 19:04:01 +02:00
parent fab12e07ff
commit ed1701d009
4 changed files with 64 additions and 0 deletions

18
util/alert-me/README.org Normal file
View file

@ -0,0 +1,18 @@
** Usage
Put:
#+BEGIN_SRC lisp
(load-module "alert-me")
#+END_SRC
In your =~/.stumpwmrc=, and the =alert-me-at= command will be available.
** Example
Run =C-t :=, type =alert-me-at=, then =18=, =52=, =meeting with
foo=. At 18:52, stumpwm will remind you 3 times every 10 seconds that
you have a meeting with foo.
The remainder 3 times is because stumpwm might hide the message if
you're switching between windows.

View file

@ -0,0 +1,8 @@
(asdf:defsystem #:alert-me
:serial t
:description "Alert me that an event is coming"
:author "Florian Margaine <florian@margaine.com>"
:license "GPLv3"
:depends-on (:bordeaux-threads :stumpwm)
:components ((:file "package")
(:file "alert-me")))

View file

@ -0,0 +1,36 @@
(in-package #:alert-me)
(stumpwm:defcommand alert-me-at (alert-hour alert-minute message) ((:number "hour: ") (:number "minute: ") (:string "message: "))
"Alert me at some point in time."
(unless (validate-alert alert-hour alert-minute message)
(error "One of the parameters is either empty or wrong."))
(bordeaux-threads:make-thread
#'(lambda ()
(loop
do (sleep 5)
when (multiple-value-bind (seconds minute hour)
(get-decoded-time)
(declare (ignore seconds))
(and (= alert-hour hour) (= alert-minute minute)))
do (repeat-with-delay 10 3
#'(lambda (count)
(stumpwm:message "The time for ~A is now! (~D/3 remainder)"
message (1+ count))))))
:name (format nil "Alert thread: ~A" message)))
(defun validate-alert (alert-hour alert-minute message)
(unless (or alert-hour alert-minute message)
(return-from validate-alert nil))
(multiple-value-bind (seconds minute hour)
(get-decoded-time)
(declare (ignore seconds))
(when (> hour alert-hour)
(return-from validate-alert nil))
(when (>= minute alert-minute)
(return-from validate-alert nil)))
t)
(defun repeat-with-delay (delay times fn)
(dotimes (i times)
(apply fn `(,i))
(sleep delay)))

View file

@ -0,0 +1,2 @@
(defpackage #:alert-me
(:use :cl))