Stateful, small-yet-robust cron - mostly meant for managing my routines by generating Taskwarrior tasks. Though you can probably extend it to do pretty much everything. If you're brave enough.
I'm open sourcing it because @oneacik liked it
What's wrong with crontab
or native recurring tasks?
TODO: elaborate
Disclaimer: I don't intend to keep this section up to date, maybe will autogenerate in the future, whatever
The source is small enough that I recommend going through it for a comprehensive overview
-
making simple things simple
let's say for the sake of the argument that as per Papa Peterson you'd like to clean your room every week:
class CleanRoom(Weekly): task = T("clean the room!")
-
reasonable defaults
- example: create tags are automatically tagged with
+cron
anduntil
is set for their recurrence date (so a Weekly task hasuntil:7d
) - there are already present durations for week, month, etc.
- example: create tags are automatically tagged with
-
escape hatch
TODO: show shell for browser for example
-
deep Taskwarrior integration - interval rollover
# TODO: provide code example
TODO: explain this feature
-
making complex things possible
# TODO: provide code example mkPeriodic + class override
git clone [email protected]:allgreed/cron.git
mkdir mycron
# or whatever you want to call it
cd $_
ln -s ../cron/cron.py cron.py
ln -s ../cron/default.nix default.nix
cat << EOF > mycron.py
from cron import main, Task as T, Weekly
# here go your Recurrings
...
if __name__ == "__main__":
main()
EOF
write an actual Recurring
and then
nix-shell
python3 mycron.py
- specific purpose - my use case will Trump all other concerns
- straightforward - at the same time I believe that my use case is common enough that there should be something already. I couldn't find anything, so I'm doing this. This is not innovative, surprises are a bug, this is not a place of honor.
- optionally a bit clever - re:epistemological value of programming - while coding this I'm learning more about routines and recurrence - this leads to ideas, however they're a) optional b) specific - example: interval rollover (which needs to be explicitly enabled)
- nix
direnv
(nix-env -iA nixpkgs.direnv
)- configured direnv shell hook
- some form of
make
(nix-env -iA nixpkgs.gnumake
)
Hint: if something doesn't work because of missing package please add the package to default.nix
instead of installing it on your computer. Why solve the problem for one if you can solve the problem for all? ;)
make init
make help