Currently I have a little script I run to set my overclock before I lauch the game:

#!/bin/sh

nvidia-settings -l
nvidia-settings -a GPUOverclockingState=1
nvidia-settings -a GPU2DClockFreqs=350,1261 -a GPU3DClockFreqs=452,1261


Then after I'm done playing I disable the overclock manually by running:

nvidia-settings -a GPUOverclockingState=0


What I'd like is a script that will run nvidia-settings then run the game and on exit set my overclock state back to 0. Is this do-able?