How to run a function when a current brush was changed?

For example I want to some function run when new brush is selected in a sculpt mode.