Cursor changed monitors trigger

I would like to be able to trigger an action whenever my cursor moves from one monitor to another.

In particular I'd like to use this with another requested feature so that whichever monitor my cursor is on is the primary monitor. This way things like new windows and the app switcher would always appear on the monitor my cursor is on (rather than whichever monitor last showed the dock which is for some reason the standard behavior).