metent / uair

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

Improve config by reusing sessions. #21

Open DeadlySquad13 opened 5 months ago

DeadlySquad13 commented 5 months ago

Hello, thanks for your package! I really like the extensibility of this tool!

I have read man pages but, unfortunately, it seems that currently it's hard to configure long sequences of sessions without a lot of copy&paste. I understand that you don't change config that often but it really hurts me looking at it when it can be drastically improved without huge changes to configuration schema.

Currently to implement simple pomodoro workflow: "work, rest; work, rest; work, rest; work, big rest" we have to write a long file repeating a lot of configuration which leads to harder maintainablitity. I have seem similar issues (#1) but the proposed solution won't work as we don't want to always repeat "big rest" - we only want it to run once at the end.

I propose to write sessions as we do now but only for declaration. These declarations are then organized into workflow:

[[workflow]]
id = "simple"
name = "Simple pomodoro workflow"
# These are ids of the declared sessions in order we want them to run
workflow = ["work", "rest", "work", "rest", "work", "rest", "work", "big rest"] 

With that we can achieve huge flexibility in how we organize our workflow removing a lot of copypaste. Full configuration of three different workflows can then look something like this:

[defaults]
format = "{percent}\n#{time}\n"

[[sessions]]
id = "work"
name = "Work"
duration = "45m"
command = "notify-send 'Work Done!'"

[[sessions]]
id = "rest"
name = "Rest"
duration = "10m"
command = "notify-send 'Rest Done!' Now strech!"

[[sessions]]
id = "stretch"
name = "Stretch"
duration = "5m"
command = "notify-send 'Make a stretch!'"

[[sessions]]
id = "tea"
name = "Tea"
duration = "5m"
command = "notify-send 'Pour some tea!'"

[[workflow]]
id = "simple"
name = "Simple pomodoro workflow"
# These are ids of the declared sessions in order we want them to run
workflow = ["work", "rest", "work", "rest", "work", "rest", "work", "big rest"]

[[workflow]]
id = "with stretches"
name = "Simple pomodoro workflow with stretches"
# These are ids of the declared sessions in order we want them to run
workflow = ["work", "rest", "stretch", "work", "rest", "stretch", "work", "rest", "stretch", "work", "big rest"] 

[[workflow]]
id = "full"
name = "Full pomorodo-based workflow with some personalized sessions"
workflow = ["work", "rest", "stretch", "work", "rest", "stretch", "tea", "work", "rest", "stretch", "work", "big rest", "tea"] 

If you worry about backwards compatibility, I think it's easy to make old configs work with implementing a simple rule: if a workflow isn't defined, run sessions as earlier - one by one.

I have a lot of programming experience and wish I would help you but I lack experience with Rust specifically so I can't really make a pull request myself. Hope this issue intrigues you - I think it will improve this tool a lot!

metent commented 2 weeks ago

Seems like an interesting idea. I was thinking of reducing boilerplate in cases like these before the id field was added, but couldn't come up with a good way to pre-define multiple session sequences.