63

We know why it is moving: Why does my dock keep moving back to my other monitor?

Now, how can we stop it? Some terminal command or even paid software?

SuitUp
  • 806
  • 1
  • 6
  • 7

6 Answers6

23

You cannot "just" stop it, unfortunately.

You have some options to keep it in the same place, but they have drawbacks:

A) Keep the dock on the left or right side of the desktop. That way it will stay in place.

or

B) In Preferences => Mission Control, uncheck "Displays have separate Spaces". Now the dock will stay in place, but monitors will switch spaces together rather than independently.

jksoegaard
  • 77,783
  • 3
    You don't lose Spaces functionality, merely change how it works. You would then have 2 displays in each Space & they will switch together rather than independently. For some people [me included], this is preferred functionality. – Tetsujin May 28 '16 at 11:37
  • 5
    Yes, that's right - but depending on how you want it to work, you would loose the effect of having seperate spaces for each display. If you really want that, then you're out of luck. If you don't care for that, then this solution is really good. – jksoegaard May 28 '16 at 13:16
  • 3
    The problem I'm seeing with losing the spaces functionality is that if you full screen an application the other displays go dark because they can't share a space with a fullscreen space. So instead of fullscreening an application you need to maximize it in a new space which has its own drawbacks. Or is there a way around that too? – Jens Bodal Oct 04 '18 at 17:29
  • Looks like disabling the Preferences > Mission Control > "Displays have separate spaces" setting now also disables the menu bar on all other non-primary monitors too.

    The dock no longer switches monitors as you'd want though, so that part is at least still working as expected.

    – Scott Kingsley Clark Mar 28 '22 at 01:22
  • 1
    It seems like any time I have a question "How to get rid of some annoying shit on my MacBook", the answer is either "you can't" or "you kinda can, but there are some drawbacks". I use both an iPhone and a MacBook, and I find both a pain in the ass... – Gene Pavlovsky Oct 11 '22 at 07:31
  • @GenePavlovsky Perhaps you should buy a different kind of product the next - or consider installing Linux on your MacBook, which will allow much easier customization (though it might still require super-user or even developer skills for some types of customization). – jksoegaard Oct 11 '22 at 09:27
  • @jksoegaard I'm a front-end developer, the hardware is provided by my employer. With the mobile version of our site, we have iOS-specific issues much more often than Android (especially during that time of the year when Apple releases a new iOS, we spend a week or two fixing various weird bugs). To better debug things on an iPhone, you have to connect it to a MacBook. In my private life, I still use old ThinkPads (most recent pair are an X230 and a W530), running mostly Windows but I'm planning to switch back to Linux, miss my Linux days (when I was a sysadming and then a back-end dev). – Gene Pavlovsky Oct 12 '22 at 11:57
  • @GenePavlovsky I assume you're talking about using the web inspector on your MacBook Pro to debug issues in Mobile Safari? - If that is the case, then no, you do not necessarily need a MacBook for that. You can use a PC instead. – jksoegaard Oct 12 '22 at 12:19
  • @jksoegaard Yes that's what I meant. Do you mean the (non-free) https://inspect.dev/ tool? Or something else? In the company I work for, it's quite difficult to get a given piece of software approved to be used, especially if the software is not well known. Our IT security department is quite strict... – Gene Pavlovsky Oct 13 '22 at 13:20
  • Yes, it was exactly the Inspect tool, I was thinking about. It's not exactly a tool that is "not well known", it is used by thousands and thousands of front end developers at even the largest companies in the world. There's also free and open source tools that do the same Inspect, although not as polished. – jksoegaard Oct 13 '22 at 16:37
2

Although you can't stop it happening, you can reset its position by restarting the Dock process:

sudo killall Dock

Worked for me like @Allan or @Scott Reed suggested.

  • 1
    It would be helpful if you indicated how just killing the dock solved the issue. – Steve Chambers Oct 09 '20 at 21:43
  • So it reads the new settings and does not require a reboot. – Martlark May 04 '21 at 04:56
  • 1
    It's not difficult to reset the Dock's position, but my main annoyance with this is that all the windows that I had previously maximized on that screen where the Dock (unwantedly) moved, are now not fully maximized (their height is reduced by the height of the Dock), and I have to re-maximize each window... – Gene Pavlovsky Oct 11 '22 at 07:30
2

Old thread, but I spent some time looking for an answer to this. There used to be a plist preference to change this behavior, but Apple removed it.

I think the "extended display" behavior, when you uncheck "Displays have separate spaces," is even worse in various other ways, such as not remembering your window positions if the display sleeps momentarily. I even considered a few overkill third-party software solutions to manipulate the behavior of multiple displays on macOS, but it turns out the simplest thing to do is just set the "autohide" delay to an impossibly high number. Even if you have autohide turned off, macOS uses this setting to determine how long it takes for the Dock to move between displays.

So, defaults write com.apple.dock autohide-delay -float 9999999; killall Dock & Bob's your uncle. In the unlikely event that you leave the cursor at the bottom of your secondary screen for too long and move the Dock to an unwanted position, you can just reduce the delay to fix it, and then extend it again.

aratuk
  • 21
1

This is a pretty old post and I've been trying to achieve this as well, but there doesn't seem to be an official way to achieve this in macOS Sonoma yet.

I use three monitors for work and was very annoyed by the Dock jumping between monitors when I just touch bottom! (Mac sometimes ruins my user experience in places like this...)

Fortunately, among the previously posted answers, the Shell Script written by aratuk worked very well for me. (Thanks aratuk!)

However, there are times when I want to use this function at home rather than at work, and entering this command every time is quite a hassle... So I wrote a small AppleScript that can solve this with a mouse click. I hope this helps others who have the same needs as me.

enter image description here

If click 'Disable Auto-hide', It will never jump between monitor. You can easily revert option to click 'Enable Auto-hide'.

Here is whole code :

-- Get the current delay value
set currentDelayValue to do shell script "defaults read com.apple.dock autohide-delay"

-- Determine if auto-hide is currently enabled or disabled if currentDelayValue as number = 1 then set currentStatus to "Enabled" else set currentStatus to "Disabled" end if

-- Construct the description with a neater format set description to "This setting can be particularly useful for users with multiple monitors to prevent the Dock from annoyingly jumping between screens.

(Current Dock auto-hide status is " & currentStatus & ")"

-- Display the dialog with options and current delay value display dialog "Would you like to enable or disable Dock auto-hide delay?" & return & return & description buttons {"Cancel", "Enable Auto-hide", "Disable Auto-hide"} default button "Enable Auto-hide" cancel button "Cancel" with icon note

-- Get the button choice set buttonChoice to button returned of the result

-- Handle the user's choice if buttonChoice is "Enable Auto-hide" then set delayValue to "1" set successMessage to "Successfully enabled Dock auto-hide" else if buttonChoice is "Disable Auto-hide" then set delayValue to "9999999" set successMessage to "Successfully disabled Dock auto-hide" else display notification "Operation aborted by user." with title "Script Aborted" return end if

-- Construct the command with the chosen delay value set command to "defaults write com.apple.dock autohide-delay -float " & delayValue & "; killall Dock" do shell script command

-- Check the exit status of the shell command set exitStatus to the result

if exitStatus = "" then display notification successMessage with title "Command Executed" else display notification "Command execution failed with error: " & exitStatus with title "Command Failed" end if

kms
  • 11
0

My solution is to create a new shortcut with ICanHazShortcut with the terminal command "killall Dock". When you press the shortcut key you designate, it will move the dock back to the primary monitor.

Allan
  • 101,432
0

This used to be one annoying issue I used to have. What I do these days is, if the doc accidentally switch to my secondary monitor, I right click on it > make position on screen to 'left'> then do the same to make the position on screen to 'middle'. This will switch it back to the main screen. Hope this helps :)