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

Notify yourself periodically using Growl Apps
You can use Growl to create your own notifications, assuming you've installed the included growlnotify extra (installation instructions). Here is an example of how to notify yourself every 10 minutes about something useful like "dont forget to drink something." Open Terminal and if your shell is the bash shell, then run the following command at the prompt:
for ((i=0; i<1000; i++)); do sleep 600s && growlnotify \
-s -m "dont forget to drink"; done
This will remind you every 10 minutes to go get a drink.

[robg adds: To kill the command, just hit Control-C. You can change the delay, the message, the loop length, etc.]
    •    
  • Currently 2.80 / 5
  You rated: 4 / 5 (5 votes cast)
 
[20,111 views]  

Notify yourself periodically using Growl | 15 comments | Create New Account
Click here to return to the 'Notify yourself periodically using Growl' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Notify yourself periodically using Growl
Authored by: papplegate on Sep 28, '07 07:46:44AM

Did not try it yet, but a very nice hint. Short and simple.



[ Reply to This | # ]
Notify yourself periodically using Growl
Authored by: fracai on Sep 28, '07 08:33:00AM
If you really want this to go on forever ( instead of for just under a week ... :) ) you could use the following.
for ((;;)); do sleep 600s && echo running; done
Note the use of "for ((;;))". A for loop like that is my preferred method of infinite looping. Also, you don't need the "s" to indicate seconds for sleep. It's informative, but the default is seconds. If you want this to go every 10 minutes, you could just use "10m" as the argument to sleep.
for ((;;)); do sleep 10m && echo running; done
Replace the "echo with the growlnotify command of course

---
i am jack's amusing sig file

[ Reply to This | # ]

Notify yourself periodically using Growl
Authored by: fracai on Sep 28, '07 08:34:22AM

Heh,

You could also set up a launchd process to run every 600 seconds... but that's just silly. ;)

---
i am jack's amusing sig file



[ Reply to This | # ]
Using cron
Authored by: lullabud on Sep 28, '07 01:57:18PM
Hah, I think it's amusing that I'm not the only one who has growl reminding himself to get up and drink water. :) I do it with cron though, every hour...

0 10-17 * * 1-5 /usr/local/bin/growlnotify -s -m "Drink some water" -I "/Users/dho/Documents/icons/drinX/Xwater/" &> /dev/null

[ Reply to This | # ]
Notify yourself periodically using Growl
Authored by: S Barman on Sep 28, '07 09:48:52PM
Actually, the 's' and 'm' does not work on the "standard" version of sleep. You will have to convert it to the number of seconds. How about a much shorter version:
while sleep 600; do growlnotify -s -m 'Take a Drink!'; done
I am a fan of short and simple!!
:-)


[ Reply to This | # ]
Notify yourself periodically using Growl
Authored by: devan on Sep 28, '07 08:45:30AM
I had to do something like this to let myself know when my battery's getting drained. I've taken my battery icon out of the menu bar, and put status on my desktop, using GeekTool. (Details here, in the comments. Not the point.) The problem is, my 20% battery power warnings no longer show up. So I used growlnotify and a launchd agent to alert myself when things get low. Using launchd, I run this shell script (which I've called batteryAlert.sh and placed in /usr/local/bin) every 300 seconds:
#!/bin/bash
# get battery charge (in mA, I think)
rem=`system_profiler SPPowerDataType | grep "Remaining" | cut -c 33-36`
# is charge less than 800 (out of a possible 4300 or so)?
if [ "$rem" -lt "800" ]
then
# tell me about it using growl
	/usr/local/bin/growlnotify -n batteryAlert -p High "Battery getting low..."
fi
If you wanted an alternative to using growlnotify, try going with AppleScript, replacing the line containing the growlnotify call with the following:
osascript -e 'tell application "Finder"' -e "activate" -e "display dialog "Battery getting low..."" -e 'end tell'
This has the disadvantage of requiring you to click "OK" to dismiss the dialog; maybe there's a better way...

[ Reply to This | # ]
Notify yourself periodically using Growl
Authored by: wallybear on Oct 01, '07 02:12:57AM
If you want to dismisss the dialog automatically, just change the command to this:

display dialog "Battery getting low..." buttons {"OK"} giving up after 2

the "buttons" part is optional, it makes the dialog showing only the OK button the "giving up" part makes the dialog dismiss itself after x seconds (2 in the example).

[ Reply to This | # ]
Low battery warning AppleScript
Authored by: TinyApps.Org on Dec 27, '09 04:49:56PM
Thanks for the script! Here it is updated for Snow Leopard with the AppleScript typo fixed as well:
#!/bin/bash

rem=`system_profiler SPPowerDataType | grep "Charge remaining" | sed 's/[^0-9]//g'`

if [ "$rem" -lt "800" ]

then

osascript -e 'tell application "Finder"' -e "activate" -e 'display dialog "Low battery warning"' -e 'end tell'

fi


[ Reply to This | # ]
Notify yourself periodically using Growl
Authored by: keyslapper on Sep 28, '07 10:55:45AM
How about crontab? This is Unix, after all. I know, not certified Unix, but just you wait ...

Enter the following in your crontab file:

0,30 7-5 * * 1-5 /usr/local/bin/growlnotify -s -m "dont forget to drink" This will have the operating system notify you every half hour, from 7:00 AM to 5:00 PM, Monday thru Friday. That way, you don't have to remember the command, you don't have to manage a script, and you don't have to remember it. come in to work and it'll start nagging you to drink.

BTW, crontab use on Tiger is locked down pretty tight. Check here for hints on using crontab:
[link:]http://www.macosxhints.com/article.php?story=2001020700163714 I had to write the crontab to a temp file then install the temp file by typing 'crontab /tmp/crontab.[something]'. You could also save the temp file to your home directory as ~/crontab and install it from there.

[ Reply to This | # ]
Notify yourself periodically using Growl
Authored by: rwmitchell on Sep 28, '07 11:02:15AM

What do you mean crontab is locked down tight?

crontab -e

works for me. If you have any trouble, be sure to set:

setenv EDITOR vi

I've got a bunch of crontab entries. Using an Airport Express and Airfoil, I have the computer wake me up to music. On the hour I get and play the latest CNN podcast, announce the time and weather (again using AEs throughout the house). The fun just never stops with cron.



[ Reply to This | # ]
launchd
Authored by: SeanAhern on Sep 28, '07 01:47:17PM

You might benefit from exploring "launchd", the new way of doing crontab-like things. Launchd is actually much more powerful than cron, and people are encouraged to move to it and avoid the legacy cron, though it still works just fine.



[ Reply to This | # ]
launchd vs. cron
Authored by: jdw2004 on Sep 28, '07 02:22:32PM
Firstly, I would actually not particularly recommend cron, simply because that crontab will run whether or not you're logged in. Not that it makes a big difference in practice, of course, but it's just cleaner not to run stuff that you know will fail sometimes.

That said, I vastly prefer cron to launchd. Can I ask what you feel makes launchd is "much more powerful"? than cron? Yes, launchd has some features that cron does not have, like setting niceness or IO priority. But do you know why those features are not in cron? THEY DON'T BELONG THERE. We already have separate tools to control these things. Why should they be built into a scheduling tool? This is part of the Unix philosophy, which Apple just does not "get". Cron is stable, simple, well-understood, ubiquitous, and documented by an open standard. Launchd is a big hairball that's none of those things.

[ Reply to This | # ]

launchd vs. cron
Authored by: delight1 on Sep 28, '07 03:57:06PM

wouldn't a users's crontab only be run when they are logged in?



[ Reply to This | # ]
launchd vs. cron
Authored by: sjk on Sep 28, '07 05:03:51PM
wouldn't a users's crontab only be run when they are logged in?
Nope, cron runs crontabs whether or not corresponding users are logged in. If you want "only run if logged in" behavior for specific cron tasks they'd have to somehow check the login status (e.g. using a wrapper script).

[ Reply to This | # ]
Notify yourself periodically using Growl
Authored by: eno on Sep 30, '07 08:43:30AM

You get a drink every 10 minutes?????!!!



[ Reply to This | # ]