Api call to get and set current selected tool?

I’ve used this workaround made by Grum999 a bunch of times in plugins, tested previously on 5.2.9.