When my phone isn't plugged into the charger, it's in my pocket, so vibration suffices for notifying me of a phone call or text message. But unlike my previous phone, it doesn't vibrate loudly enough for me to reliably hear it when it's not in my pocket. So I'd like to automatically change the sound profile to "Sound" when I plug in the phone, and "Vibrate only" when I unplug it. How can I do that?
I have experience in administering Linux PCs and servers, but I'm unfamiliar with Android internals, so I wouldn't know where to begin to write a shell script for this.