These days, using the power button to lock your Android seems a little old-fashioned. Thanks to third-party apps and mods, you could seamlessly lock your device using a double-tap, a swipe, and even gravity, or you could just throw it in your pocket, all of which help prevent additional wear and tear on your power button. Now, we've got another method for you—just shake.
Firstly, let's ensure that your device is prepared. You will need to be running Android 4.0 (Jelly Bean) or higher. You'll also need to be rooted, have the Xposed Framework installed, and enable "Unknown sources" for the installation of apps from outside of Google Play.
Alternatively, you can download Shaky directly from the Google Play Store ("Unknown sources" does not have to be enabled for this option).
After installation, make sure to properly activate the module.
With the module activated, open the Shaky interface from your app drawer and toggle on the service. You can also opt to leave the screen on when locking the device or "Automatically Resecure" your device after a given time. Once you've made your changes, restart your device and start shakin'.
If you want another way to combat wear and tear on your device's power button, try out Volume Power, which lets you unlock your device using the volume buttons.