Toggling Dock position via Apple Script

I want to toggle my Dock position between the left side and the bottom of the screen, depending on the context I’m in.

To do this…

Save this Apple Script.

tell application “System Events” to tell dock preferences

if screen edge is bottom then

set screen edge to left

else if screen edge is left then

set screen edge to bottom

end if

end tell

Make a new Keyboard Maestro global macro that runs it.

I assigned ⇧⌥⌘D to toggle the Dock.

Here’s a demo in action.