Saturday, January 26, 2013

Quick script to remind you to stretch

Late last week, I hurt myself a little bit doing hang clean and jerks.  I over-extended my arm when bringing weight down between reps.  I think it had more to do with limited mobility, the fact that I drive a desk all day long and how I sleep with my arms curled up on my chest.

My coaches said my front rack needed work and I needed more mobility in triceps.  So, at home, I've been working on my front rack and triceps stretches.  But at work, I needed to make sure I did something too.  So, I wrote a quick little script to remind me to stretch every so often, with a pop-up window and an alert sound.

As a prerequisite, other than the normal packages installed in an Ubuntu 12.04 Desktop install, the
vorbis-tools package.

Find your desired alert sound.  You can find many sounds in
/usr/share/sounds/ubuntu/
/usr/share/sounds/gnome/default/alerts/

Create the file, stretch_reminder.sh using your favorite text editor.  Step it up and use vi!

#!/bin/bash
# Alert with sound and popup to remind you to stretch
ogg123 /usr/share/sounds/ubuntu/stereo/system-ready.ogg &
zenity --warning --display=:0.0 --text="It's time to stretch." 
exit 0

Schedule the script in your crontab

$ crontab -e

and then enter the following line
*/30 8-17 * * * /path/to/your/script/stretch_reminder.sh > /dev/null >&1

The crontab entry as written will run every thirty minutes, between 8am and 5pm and won't email you success (or failure) notices each time it runs.

This script has been running all week long for me at work and its been great. I do a few stretches for my forearm, right there in my chair and by the end of the week, I was almost as good as new.  I didn't miss any CrossFit time and I was able to get through my days without pain!

No comments: