Routinized

Get a Routine!

Routinized is just a convenient way to add some structure to your day. It turns a routine and a set of commands into a crontab. Easy. You can customize everything.

Why?

Well, I wanted to start work listening to "Working Man" by Rush, and then be reminded to do some pushups, stretch every so often to prevent screen lock, and have it be flexible enough that I could extend it with additional verbs.

Cron was a natural fit as I wanted to use as much operating system level things as I could, rather than run a scheduler. I also wanted it to be customizable.

It's fun. Share. Make it more fun.

Think of it as sharing smart periodic scripts for local use.

Installation

Install it:

$ gem install routinized
$ rbenv rehash # if necessary

Usage

Once installed, it's time to make your dotfiles...everything lives in .routinized.

$ routinized bootstrap

This makes all sorts of files for you:

~/.routinized/master.rb # your master routine
~/.routinized/config.json # location of binaries wrappers might need
~/.routinized/wrappers/* # wrappers around binaries to make cron entries
~/.routinized/commands/* # Ruby scripts executed from cron itself

After you've made all sorts of changes, you can generate and install the crontab via:

$ routinized install

Over time, more commands will be available (contribute some!), upgrading is as easy as:

$ routinized upgrade

(depending on the command, you might need to customize config.json)

Wrappers and Commands

In short, wrappers are Ruby transformations that turn into a command line that lives in the crontab.

Commands are executed from the command line and execute Ruby code.

So a wrapper is executed when building the crontab, a command is executed every time the cron entry runs.

The 'pipe' wrapper makes use of Parallel which can be installed via:

$ brew install parallel

It's basically a smarter xargs.

Routine

Since this is a layer on top of whenever, you can do things like:

# Morning Routine
#
# Go to WORK!
every :weekday, :at => '8:00am' do
  command say 'Go to Work'
  command itunes_play('Rush',"World",'Working Man')
end

every :weekday, :at => '8:45am' do
  command say 'Read Hacker News'
  command osx_notify('HN',"Grab a coffee and read Hacker News")
end

# Stretch Break every 30 minutes during the work week
every '*/30 9-16 * * 1-5' do
  command osx_notify('Stretch',"Take a short break and stretch")
end

# Lunch!
every :weekday, :at => '12:00pm' do
  command say 'Time for Lunch'
  command osx_notify('Lunch','Time to eat some food')
end

# Stop Working
every :weekday, :at => '5:15pm' do
  command say 'Good work Zack, go home'
  command itunes_play('Rush','Rio','Spirit')
  command osx_notify('Go Home','Time to stop working dear chap.')
end

Currently it is brainless, in more than one way I'm sure, but in this context I mean without persistent memory storage. That will be added at some point.

Acknowledgements

This is really just a thin shim on top of the whenever gem, thanks!

Also was inspired by the idea of a simplified Hubot/Huginn for personal use.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request