metent / uair

An extensible pomodoro timer
MIT License
93 stars 7 forks source link

Added time_format option and implemented it. #6

Closed ectoplast closed 1 year ago

ectoplast commented 1 year ago

This is a great customizable pomodoro timer! So I use it daily. But I needed some other time formatting in the Polybar (e.g. 01:23 == 1m 23s) because the humantime formatted view jumps to often for me. As an example when the time switches from "1m 01s" to "1m" it changes the length too obvious for me and that distracts me. So I implemented an alternative configurable view. In the configuration you can add time_format = "MinSec" and the view turns into 'min:sec'. If it is not added, then the default view in humantime is showed like in the past. Please have a look at the screenshot how it looks in my polybar view now.

If you find it useful, I would be happy if you could add this feature :)

DeepinScreenshot_select-area_20230202104738

metent commented 1 year ago

Thanks for this! I was planning to add something like this, but with different semantics. We can have time_format which is a format string containing format specifiers similar to that of strftime. However, an extension in the form of an additional flag following % may be required which says "if the quantity expressed by the format specifier with the flag is zero, then skip it and the text between it and the next format specifier". For example, if we consider the flag to be *,

2 minutes, 30 seconds with the format string %*H:%M:%S will become 02:30 and with the format string %*-Hh %*-Mm %-Ss, it will become 2m 30s.

With this, we get

Let me know your thoughts about this. I'll try to implement this and if I find that it introduces a lot of complexity, I'll consider merging this PR.

ectoplast commented 1 year ago

Thank you for checking my solution!

My first thought was also using something like strftime. For sake of simplicity I proposed the static option.

Of course your solution will be much more customizable! I will also be glad to use it :)

metent commented 1 year ago

Closing in favour of #7.