Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for 'macros' #10

Open
ndbroadbent opened this issue Jan 9, 2012 · 2 comments
Open

support for 'macros' #10

ndbroadbent opened this issue Jan 9, 2012 · 2 comments

Comments

@ndbroadbent
Copy link
Contributor

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
Copy link
Owner

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

  • you have a recurrent event during weekdays called "wake-up" which is 30 lines long.
  • you want to create a wake-up event on a week-end
  • for the moment you need to copy-paste the current "wake-up" description to your new event
    With your suggestion one would only need to write macro: wakeup

Some topics to debate:

  • should the macro name be in the description or in the title ?
  • what / where should macros be ?
  • what about only accepting macros for security reasons ?

@ndbroadbent
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants