{"id":88,"date":"2006-03-28T23:25:22","date_gmt":"2006-03-28T23:25:22","guid":{"rendered":"http:\/\/westafer.com\/b\/wordpress\/?p=88"},"modified":"2006-03-28T23:25:22","modified_gmt":"2006-03-28T23:25:22","slug":"simple_clock","status":"publish","type":"post","link":"https:\/\/westafer.com\/b\/words\/2006\/03\/28\/simple_clock\/","title":{"rendered":"Simple Clock"},"content":{"rendered":"<p>\nOK, so I have trouble getting up in the morning. I&#8217;m constantly late and unfocused; well, that&#8217;s what I&#8217;m told. Anyway, I wrote a clock for myself in AppleScript with some borrowed code and some of my own and here it is. The magic of the script takes place in a crontab. The crontab is really simple to make, but it means a trip to the Terminal. I know, I know, I&#8217;m supposed to use launchd, and I will get around to that, but the crontab is faster for me. Here&#8217;s the script:\n<\/p>\n<div style=\"width: 90%; margin-left: auto; margin: right: auto; line-height: auto; padding: .5em; font-family: Courier, Times, serif; color: black; border: 1px dotted gray; font-size: 10px;\">\n<pre>\ntell application \"Finder\"\nset volume 10\nend tell\nset volInt to 60\ntell application \"iTunes\"\nset sound volume to volInt\nset song repeat of user playlist \"wfae\" to one\nplay track 1 of user playlist \"wfae\"\nend tell\nset whichButton to \"\"\nrepeat until whichButton = \"No, I'm up!\"\ndisplay dialog \"Snooze?\" buttons {\"No, I'm up!\",\n\"SNOOZE\"} default button \"SNOOZE\"\nset whichButton to (button returned of result)\nset sleep to \"sleep\"\nif whichButton = \"SNOOZE\" then\ntell application \"iTunes\"\npause\nend tell\ndo shell script \"\/bin\/tcsh -c '\/bin\/sleep 300'\"\ntell application \"iTunes\"\nif volInt < 100 then\nset volInt to volInt + 10\nset sound volume to volInt\nend if\nplay\nend tell\nend if\nend repeat\ntell application \"iTunes\"\nset song repeat of user playlist \"wfae\" to all\nset volInt to 60\nset sound volume to volInt\nplay track 2 of user playlist \"wfae\"\nend tell\n<\/pre>\n<p>\n<\/div>\n<p>Save this as an Application and put it somewhere. Mine's in my home directory.<br \/>\nOpen the Terminal and type:<\/p>\n<pre>\ncrontab -e\n<\/pre>\n<p>Type the following (crontab -e spits you into vim)<\/p>\n<pre>\n15    8    *    *    *    open    iTunesWakeUp.app\n<\/pre>\n<p>The spaces inbetween the items are tabs. One mustn't forget the tabs, oh best beloved.<\/p>\n<pre>type :qw\n<\/pre>\n<p>and you'll get a nice message from the Terminal:<\/p>\n<pre>\ncrontab: installing new crontab\n<\/pre>\n<p>You can check it by typing crontab -l<\/p>\n<p>Now, go to sleep and wake up to iTunes.<\/p>\n<p style=\"width: 98%; font-style: italic;\">A few gotchas:<br \/>\nI've pointed my alarm at track one of the playlist \"wfae\". This can be whichever of your playlists you choose. BTW, track one on my alarm is the sound of an alarm bell.<br \/>\nTrack two is the live stream from WFAE, the NPR news station in Charlotte, NC.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>OK, so I have trouble getting up in the morning. I&#8217;m constantly late and unfocused; well, that&#8217;s what I&#8217;m told. Anyway, I wrote a clock for myself in AppleScript with some borrowed code and some of my own and here it is. The magic of the script takes place in a crontab. The crontab is [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-88","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/westafer.com\/b\/words\/wp-json\/wp\/v2\/posts\/88","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/westafer.com\/b\/words\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/westafer.com\/b\/words\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/westafer.com\/b\/words\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/westafer.com\/b\/words\/wp-json\/wp\/v2\/comments?post=88"}],"version-history":[{"count":0,"href":"https:\/\/westafer.com\/b\/words\/wp-json\/wp\/v2\/posts\/88\/revisions"}],"wp:attachment":[{"href":"https:\/\/westafer.com\/b\/words\/wp-json\/wp\/v2\/media?parent=88"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/westafer.com\/b\/words\/wp-json\/wp\/v2\/categories?post=88"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/westafer.com\/b\/words\/wp-json\/wp\/v2\/tags?post=88"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}