I wish to have a shortcut which switches the priority (i.e. primary, secondary) of the displays (laptop + external).
PS: I am aware that there's a dedicated button/shortcut to do this but, at least mine, cycles through all configurations (i.e. different resolutions). I want to cycle between two configurations only.
It turned out I already wrote it, as part of this question. Since it is another question, below an outtake of that one:
It toggles (switches between the two) the primary screen.
To use:
copy the script into an empty file, save it as
toggle_primary.py
Add it to a shortcut key: choose: System Settings > "Keyboard" > "Shortcuts" > "Custom Shortcuts". Click the "+" and add the command: