fabriceb / gcalcron

Simple multi-platform GUI for CRON: manage your tasks scheduling with Google Calendar !
42 stars 13 forks source link

support for 'macros' #10

Open ndbroadbent opened 12 years ago

ndbroadbent commented 12 years ago

Here's an idea for a feature that I think would be really useful. It's also something that I would be very happy to write, but I wanted to first hear your thoughts. I currently have a task that shuts down my desktop computer at 10:30pm on workdays, otherwise I tend to stay up all night working on projects like this... So in the description of the event, I have the following lines:

-10: DISPLAY=:0 notify-send "Shutting down computer in 10 minutes"
-5: DISPLAY=:0 notify-send "Shutting down computer in 5 minutes"
-3: DISPLAY=:0 notify-send "Shutting down computer in 3 minutes" "Please save your work"
-1: DISPLAY=:0 notify-send Shutting down computer in 1 minute" "Please save your work"
poweroff

I would like to replace this with something like:

macro: shutdown

This would cause the script to search a macros folder in the application directory, or maybe the users HOME directory, for a file called shutdown. It would then simply replace that line in the description with the contents of the macro file, and parse the final result. This means that macros could be combined with commands, or even other macros, to create complex tasks.

What do you think?

fabriceb commented 12 years ago

I think this is a nice idea. I can give you a typical use-case:

Some topics to debate:

ndbroadbent commented 12 years ago

Yep, that's a great use-case. I was also wondering about the macro name being in the title, and I think that might be useful. Perhaps both title and description could be supported, somehow?

I was thinking that macros could be stored in a ~/.gcalcron2/macros directory, and the settings could be moved to ~/.gcalcron2/settings.json.

Only supporting macros would definitely improve security, but it would also reduce flexibility. It means that you would always need to create a new macro on the server, even for 1 line tasks that happen only once. So I'm not too sure about that.

I've just implemented simple macro support on my macros branch. It includes the changes to ~/.gcalcron2 that I mentioned above, but I'm not sure about that. Maybe macros could be stored in the GCalCron2 directory, in a macros directory? That directory could be added to .gitignore.