Mage Bubble/Barrier macro. Cast when no barrier present?

im looking to see if there is a macro that will cast bubble/barrier when there isnt one active instead of it casting it everytime its off CD regardless if its active or not.