 (put 'jobhours-string 'risky-local-variable t)
 
 (defun jobhours-update-string ()
-  (setq jobhours-string (get-jobhours-string)))
+  (setq jobhours-string (jobhours-get-string)))
 
 (defun jobhours-setup-modeline ()
   (run-at-time 0 300 #'jobhours-update-string)

           (color-hsl-to-rgb h (* s (min 1 cloudiness)) l))))

(defun jobhours-make-text-properties (logged-in disc dir &optional color)
  (list :background (or color
                        (jobhours-dim-color (if (< disc 0)
                                                "#ffff00000000"
                                              "#0000ffff0000")
                                            (abs disc)))
        :foreground (if logged-in
                        (if (< dir 0)
                            "#0000ffffffff"
                          "yellow")
                      "#000000000000")
        :weight (if logged-in 'bold 'light)))

(defun get-jobhours-string ()
  (with-temp-buffer
    (call-process "jobhours" nil t nil (expand-file-name jobhours-file))


           (logged-in             (alist-get 'logged-in details))
           (current-period        (alist-get 'current-period details))
           (ideal-total           (alist-get 'ideal-total details))
           (ideal-remaining       (alist-get 'ideal-remaining details))
           (ideal-expected-exact  (alist-get 'ideal-expected-exact details))
           (real-completed        (alist-get 'real-completed details))
           (real-expected         (alist-get 'real-expected details))
           (real-expected-inact   (alist-get 'real-expected-inact details))
           (real-remaining        (alist-get 'real-remaining details))
           (real-this-remaining   (alist-get 'real-this-remaining details))
           (expectation (- real-remaining ideal-remaining))
           (expectation-days (floor (/ expectation 8.0)))
           (expectation-hours (mod expectation 8.0))
           (ideal-progress (/ ideal-expected-exact ideal-total))
           (real-discrepancy-perc-diff
            (/ (- real-completed ideal-expected-exact)
               ideal-total))
           (real-discrepancy-nominal-hours (/ (- 8.0 real-expected-inact) 2.0))
           (properties
            (apply-partially #'jobhours-make-text-properties
                             logged-in real-discrepancy-nominal-hours
                             expectation)))

      (delete-region (point-min) (point-max))

      (insert "  ")
      (insert (pcase current-period
                (`Holiday    "?")
                (`OffFriday  "!")
                (`HalfFriday "/")
                (`RegularDay "|")
                (`NotWorking "∙")))
      (insert " ")
      (when (< expectation 0)
        (insert "+"))
      (when (> expectation-days 0)
        (insert (format "%dd " expectation-days)))
      (insert (format "%.1fh" (abs expectation)))
      (insert "  ")

      ;; Color the whole "time bar" a neutral, light grey
      (add-face-text-property (point-min) (point-max)
                              (funcall properties "grey75"))

      ;; Darken a percentage of the bar, starting from the left, to show what
      ;; percentage of the time period has been worked. Color it based on the
      ;; current progress.
      (add-face-text-property
       (max 1 (- (point-max) (floor (* (point-max) ideal-progress))))
       (point-max) (funcall properties))

      (buffer-string))))

