This would be possible using the forementioned locationservice extension
If I understand correctly, after shaking you like to open your app immediately even if the device is locked to then send a sms with the latest location? The latest version of the alarmmanager extension would be able to open the app also above the lockscreen, see also here
To detect the shaking see the already provided example here Run app in background, that fires an alarm whenever phone is shaking - #4 by Taifun
Taifun