For some time I've been looking at ways of introducing Bible passages, Scripture and a pause for reflection/prayer into my daily life, but haven't done much to implement it.
I like routine, but I'm also not always disciplined enough to follow through with something if it's not put right in front of me.
That means merely setting an alarm or countdown timer in order to remind me to read a passage from the Bible, or pray for something, isn't enough. If I'm in the middle of something, I'll be too lazy/distracted to go and find my Bible (even if it's sitting right next to me) or think of something to pray for.
I need something which provides the essential elements - a selection of verses from the Bible plus a topic to pray about - right in front of me.
This also serves as a reminder to take a break from the computer, even if it's just for half-a-minute.
I am sure there are plenty of applications out there which can do this sort of thing. "Take a break" alerts have been around for years, and getting software to send notifications is now very familiar. However, I'm also quite fussy, so I wanted to see if I could create something myself.
The advantages of a homegrown approach is that it can be completely tailored to my needs (within the confines of what I'm capable of creating with the tools available to me). It can be tweaked whenever required. It's also free and I pretty much know exactly what it's doing, and when.
The techniques described here could be used for any kind of regular reminders, and added to or modified as you require. Hopefully the process I describe below will make it easy for you to change it to your own requirements.
As with most challenges, there are a myriad of ways to complete the task. It depends in part as to what tools are available and how you want the end product to operate.
As this article's title suggests, this is a solution for those using an Apple Mac computer running a reasonably up-to-date version of OS X. Sorry, Windows users, you'll need to look elsewhere.
I've dabbled with the built-in (and free) Automator and AppleScript editors, and these seemed a good place to start.
I wanted the final solution to operate irrespective of what other software was installed, or what I was doing at the time. It also needed to be a little bit bossy and interrupt me, rather than hiding in the background.
That meant I chose the Finder alert system as the best option. It's not fancy by any stretch of the imagination. You can't do much text formatting, or include images, but for simple text alerts (which this is) it seemed the best choice. As we know, the Finder is always running, too.
I didn't want some AppleScript (even a small one) or Automator task sitting running in the background all day, so I decided to write a script which would populate and show the alert once whenever called, and then use a cron job to schedule it to run automatically every half-an-hour.
I looked at using Automator but when I saw that the AppleScript was pretty small I felt that Automator wasn't required.
Thanks to Google, searching out the bits of AppleScript I needed to piece together a complete script, I came up with the following:
Then set up the cron job to run this AppleScript every half hour.
Here we go with the code. I have added comments in which hopefully make it pretty self-explanatory.
You can copy and paste this into a new AppleScript Editor document. Once you've done, save it somewhere you can easily access it again. I put it in the /Documents/Scripts folder and called it "popup scripture prayer script". It will be given a 'scpt' extension.
(* Popup Scripture Prayer Script
-- Set the full path to the scripture text file in the scriptureFile variable
set scriptureFile to "/Users/andymerrett/Documents/scripture and prayer/scripture/scripture.txt"
-- Now open this file for reading
set fileHandle to open for access scriptureFile
-- All separate paragraphs will be read into a list called scriptureList
set scriptureList to paragraphs of (read fileHandle)
-- And the file is closed.
close access fileHandle
-- Now we do the same for the prayer file
-- Set the full path to the prayer text file in the prayerFile variable
set prayerFile to "/Users/andymerrett/Documents/scripture and prayer/prayer/prayer.txt"
-- Now open this file for reading
set fileHandle to open for access prayerFile
-- All separate paragraphs will be read into a list called prayerList
set prayerList to paragraphs of (read fileHandle)
-- And the file is closed.
close access fileHandle
-- Get the number of scriptures loaded and store in numScriptures.
set numScriptures to count of scriptureList
-- Get the number of prayers loaded and store in numPrayers.
set numPrayers to count of prayerList
-- Now pick a scripture by picking a random number from 1 to the number of scriptures
set random_scripture to (random number from 1 to numScriptures)
-- And pick a prayer by picking a random number from 1 to the number of prayers
set random_prayer to (random number from 1 to numPrayers)
-- And then put the text of that scripture into the replyScripture variable.
set replyScripture to item random_scripture of scriptureList
-- And put the text of that prayer into the replyPrayer variable.
set replyPrayer to item random_prayer of prayerList
-- And finally, raise the alert.
-- Get the Finder to be active so the alert doesn't hide in the background.
tell application "Finder" to activate
-- And display the alert in the Finder.
-- The & syntax joins bits of the message together. The 'return' code is a carriage return. The two
-- text variables are inserted so that the scripture and prayer are displayed in the appropriate
tell application "Finder" to display alert "Time to take a break..." & return & return & "Your scripture is: " & replyScripture & return & return & "Pray for: " & replyPrayer
-- That's it!
-- Add or remove items as required to make it your own.
Main points to note are:
You will need to create the two text files using a plain text editor. I use TextEdit, being sure to set it to plain text by going to the Format menu and selecting "Make Plain Text". (I haven't tested it but Rich Text Files may not play well with the script)
As stated previously, these contain separate lines for each scripture or prayer you want to be randomly selected from.
The bit which keeps the whole thing running on schedule is the cron job.
Although cron is deprecated on OS X now in favour of launchd, I haven't got my head around launchd yet. So while cron still works (which it should do as it's pretty core in the Linux world), I've opted for this.
You can find online tutorials on cron if you really want to delve down, but here are the steps I took (if you already have cron jobs you will likely want to add the task to that existing file):
cd ~. After this, check you're there by typing
pwdand you should get something like
/Users/andymerrett(with your username displayed after 'Users/')
nano crontab.txtand hit Enter.
0,30 * * * * osascript ~/Documents/Scripts/popup\ scripture\ prayer\ script.scpt.
This is based on the assumption that you saved your AppleScript file in the same place and with the same name as I gave it (see the code section above). If not, you'll need to replace it with the path to your script. The ~/ at the start of the file path is shorthand for your home directory.
Note there is a tab after the asterisk '*' and before the 'osascript', not spaces. This is important.
If you have spaces in your filename, or any other 'special' characters, you'll need to 'escape' them by using a backslash (\) character beforehand. Don't forget the scpt file extension.
The numbers at the beginning denote when you want the script to run. Putting a 0,30 at the start tells cron you want the script to run both on the hour and on the half-hour, all day, every day. You could make it run only on the hour by replacing with a single zero (0). Make it run every 15 minutes with 0,15,30,45 (no spaces)
MAILTO="". This will suppress the mail.
crontab crontab.txtagain, check there are no errors, and you're good to go.
I hope you found this little tutorial useful. This isn't the most whizzy or foolproof solution, but it does seem to do the job I wanted it to. I hope it works for you, too.
If you have any questions or need help, you can contact me and I'll do my best to assist you.