Okay for real this time, THIS one should work with everything. Probably.
Lua Code:
local oSetAttribute = getmetatable(ActionButton1).__index.SetAttribute
hooksecurefunc(getmetatable(ActionButton1).__index, 'SetAttribute', function(self, attribute)
if attribute ~= 'showgrid' or GetCVar('alwaysShowActionBars') ~= '0' then return end
oSetAttribute(self, 'showgrid', GetCursorInfo() and 1 or 0)
if not HasAction(self.action) then self:Hide() end
end)
I added a check for the cvar too so it should honor the setting.