egg-timer.scm 972 B

123456789101112131415161718192021222324
  1. (use-modules (zenity))
  2. (let* ((length (or (zenity-list "What would you like to time?"
  3. '("Time" "Operation")
  4. '(("10s" "Count to ten..")
  5. ("5m" "Soft boiled egg")
  6. ("8m" "Hard boiled egg")
  7. ("45m" "Baked potato"))
  8. #:height 250)
  9. (exit)))
  10. (seconds (case (string->symbol (car length))
  11. ((10s) 10)
  12. ((5m) (* 5 60))
  13. ((8m) (* 8 60))
  14. ((45m) (* 45 60))
  15. (else (error "Could not understand the time command"))))
  16. (progress (zenity-progress "Timing.." #:auto-close #t)))
  17. (let loop ((remaining seconds))
  18. (progress (round (* 100 (/ (- seconds remaining) seconds))))
  19. (sleep 1)
  20. (unless (<= remaining 0)
  21. (loop (- remaining 1))))
  22. (zenity-info "Done!"))