Sorry for spamming!
The last version I posted gave worse layout than the original (because I
had replaced \center-column by \column which seems to look better for
dotted durations in the denominator).
So maybe better to use:
\version "2.22.0"
notetime =
#(define-music-function (count unit) (index? ly:duration?)
(let* ((unit-length (ly:duration-length unit))
(unit-numerator (ly:moment-main-numerator unit-length))
(unit-denominator (ly:moment-main-denominator unit-length))
(build-column (if (positive? (ly:duration-dot-count unit))
make-column-markup make-center-column-markup))
(timesig-entries (list
(markup (#:number (number->string count)))
(markup #:note unit DOWN)))
(timesig-markup (markup
#:override '(baseline-skip . 0.5)
(build-column timesig-entries))))
#{
\once\override Staff.TimeSignature.stencil =
#(lambda (grob) (grob-interpret-markup grob timesig-markup))
\time #(cons (* count unit-numerator) unit-denominator)
#}))
{
\notetime 4 4
\repeat unfold 8 { a8 b c' d' e' }
\notetime 4 4.
\repeat unfold 8 { a8 b c' d' e' }
}