rest.lisp 903 B

1234567891011121314151617181920212223242526
  1. (in-package :stumpwm)
  2. (defvar *notify-to-rest* t)
  3. (defvar *notify-to-rest-period* (* 60 20))
  4. (defcommand toggle-notify-to-rest () ()
  5. (if *notify-to-rest*
  6. (setf *notify-to-rest* nil)
  7. (setf *notify-to-rest* t)))
  8. (defcommand notify-to-rest-set-period (period) ((:string "Period of notifications in seconds: "))
  9. (if *notify-to-rest-period*
  10. (setf *notify-to-rest-period* period)
  11. (setf *notify-to-rest-period* 3600)))
  12. (defcommand notify-to-rest () ()
  13. (sb-thread:make-thread
  14. (lambda ()
  15. (loop while (or *notify-to-rest* *work-time*)
  16. do (progn (run-shell-command
  17. (format nil "notify-send --urgency=critical ~s"
  18. (format nil "Take a break. Next notification in ~a seconds."
  19. *notify-to-rest-period*)))
  20. (sleep *notify-to-rest-period*))))
  21. :name "notify-to-rest"))