I had trouble finding a modern toggle macro for addons - the following works and I wanted it to be searchable for posterity.
I find this useful for ConsolePort, when I accidentally forget to toggle it on when on my couch and I want to toggle it back on with one button on my controller!
/run local t={"ConsolePort"}for i=1,#t do if C_AddOns.IsAddOnLoaded(t[i]) then C_AddOns.DisableAddOn(t[i],UnitName("player")) else C_AddOns.EnableAddOn(t[i],UnitName("player")) end end C_UI.Reload()
Notes:
- You need to replace the example addon name ConsolePort in the code with your own addon name. Be sure not to remove the quotations or any other surrounding code.
- Make sure to use the addon identifier (e.g. “ConsolePort”) not the display name for users (e.g. “Console Port” with a space). When hovering over an addon in the addon menu in-game, the former appears as a subtitle underneath the display name. Sometimes they’re the same.
- If you want to check multiple addons, you should be able to add them with commas (e.g. t={“ConsolePort”, “BugSack”}.