Skip to content

Instantly share code, notes, and snippets.

@vrybas
Created September 25, 2009 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vrybas/193564 to your computer and use it in GitHub Desktop.
Save vrybas/193564 to your computer and use it in GitHub Desktop.
Improved system 'sleep'. Could be used like: $ sleeptill 1 7 30 && mplayer -o loop superannoyingringer.mp3 =)
#!/usr/bin/ruby
# == SleepTill ==
#
# Improved system 'sleep'. Could be used like:
# $ sleeptill 1 7 30 && mplayer -o loop superannoyingringer.mp3 =)
require 'rubygems'
require 'active_support'
if (ARGV.length == 0) || (ARGV[0] == '--help')
puts "USAGE: sleeptill [day](0 - today, 1 - tomorrow, etc.) [hour](0-23) [minute](0-59)\n"
else
ARGV.collect!(&:to_i)
seconds = (Date.today + ARGV[0].days + ARGV[1].hours + ARGV[2].minutes) - Time.now
system "sleep #{seconds.round}" unless seconds < 0
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment