time.lisp 638 B

123456789101112131415161718192021222324
  1. (in-package :stumpwm)
  2. (defvar *force-free-time* nil)
  3. (defcommand toggle-free-time () ()
  4. (if *force-free-time*
  5. (setf *force-free-time* nil)
  6. (setf *force-free-time* t)))
  7. (defvar *force-work-time* nil)
  8. (defcommand toggle-work-time () ()
  9. (if *force-work-time*
  10. (setf *force-work-time* nil)
  11. (setf *force-work-time* t)))
  12. (defun free-time? ()
  13. (if *force-work-time*
  14. nil
  15. (let ((day-of-week "%u")
  16. (hour (parse-integer (time-format "%k"))))
  17. (or *force-free-time*
  18. (> (parse-integer (time-format day-of-week)) 5)
  19. (or (>= hour 18)
  20. (< hour 10))))))