mirror of
https://github.com/stumpwm/stumpwm-contrib.git
synced 2026-09-10 07:26:25 -04:00
Adds the alert-me stumpwm module.
This commit is contained in:
parent
fab12e07ff
commit
ed1701d009
18
util/alert-me/README.org
Normal file
18
util/alert-me/README.org
Normal 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.
|
||||
8
util/alert-me/alert-me.asd
Normal file
8
util/alert-me/alert-me.asd
Normal 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")))
|
||||
36
util/alert-me/alert-me.lisp
Normal file
36
util/alert-me/alert-me.lisp
Normal 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)))
|
||||
2
util/alert-me/package.lisp
Normal file
2
util/alert-me/package.lisp
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
(defpackage #:alert-me
|
||||
(:use :cl))
|
||||
Loading…
Reference in a new issue