Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Set different startup times for different days' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Set different startup times for different days
Authored by: krunk7 on Apr 21, '08 06:31:40PM

To expand upon the suggestion above, you could write a script which set the schedule for the following week and put that in your cron to run weekly.

A script that set two wakes (6:30am and 5:30pm) and two sleeps (9am and 10:30pm) for each day would look something like this: (ruby)

#!/usr/bin/ruby
#

def build_schedule(wake, shutdown)
  days = {'Sunday' => Array.new, 
          'Monday' => Array.new,  
          'Tuesday' => Array.new, 
          'Wednesday' => Array.new,
          'Thursday' => Array.new,
          'Friday' => Array.new, 
          'Saturday' => Array.new}
  t = Time.now
  t = t + (60*60*24)
  days.each do |k,d|
    days[t.strftime('%A')] = [t.strftime("%m/%d/%y #{wake}"), t.strftime("%m/%d/%y #{shutdown}")]
    t = t + (60*60*24)
  end
  days
end

sched1 = build_schedule("6:30:00","9:00:00")
sched2 = build_schedule("17:30:00", "22:30:00")

[sched1,sched2].each do |s|
  s.each do |k, v|
    wake = "pmset schedule wakeorpoweron '#{v[0]}'"
    shutdown = "pmset schedule shutdown '#{v[1]}'"
    system(wake)
    system(shutdown)
  end
end



[ Reply to This | # ]