Category filter

Script to customize Dock preferences on Mac

The Dock on macOS devices is a small panel that allows you to quickly access files, folders, and applications. Apple provides various options to customize the position, Dock size, and animation effects of the Dock using the Dock and Menu Bar tab under System Preferences. However, configuring the Dock on multiple endpoints can be a cumbersome task for the IT department of any organization. Execute a custom script on target endpoints to remotely configure Dock settings on a granular level with Hexnode UEM.

Scripting Language – Bash

File extension – .sh

Disclaimer:

The sample scripts provided below are adapted from third-party open-source sites.

Show active apps

Execute the command below to display only the currently running apps in the Dock.

Replace true with false to reset to defaults.

Change Dock position

The orientation property specifies the orientation of the Dock on the home screen. Replace <position> with either of the values left, right, or bottom to align the Dock on the home screen with respect to it.

Single app mode

The single app mode displays only the application that is currently in use. All other open applications and windows will be minimized into the Dock.

Change Dock size

Replace <dock size> with an integer indicating the Dock’s preferred size. The lesser the number, the smaller the icon size. Most Macs appear to have a default size of around 48. You can go as low as 1, making the dock difficult to access.

Change Dock animation style

Replace <effect name> with either of the values suck, gene or scale, which indicate the various app minimization effects supported by Apple.

Add apps

The script below adds the specified applications to the Dock.

Replace <app1> with the name of the application you want to add to the Dock and <app1 path> with the app path. You can add more apps to the Dock using the same format.

For example:

The above script adds the following apps to the dock:

  1. Launchpad
  2. Safari
  3. Google Chrome
  4. Slack
  5. Zoom
  6. Reminders
  7. Notes
  8. System Preferences
Notes:

  • The currently opened apps and certain permanent apps like Finder and Bin will be retained in the Dock.
  • Make sure the apps are installed on the device before executing the script. The dock shows a “?” mark in the corresponding position if the apps are not present.
  • Enclose the app path within double quotes if the app name contains 2 or more words separated by spaces. For instance, consider the case of how the “Google Chrome” app is specified in the above script.

Reset to default state

Executing the command below will reset the Dock to the default state.

Remove apps

Pre-requisites:

  1. This script requires Homebrew and dockutil packages to be installed on the devices.
  2. You can either use the Mac Live Terminal or the device’s built-in Terminal window to install them.
    • For devices running versions below macOS 12.3, the following set of commands helps you with it.
    • For devices running macOS version 12.3 or later, the following set of commands will help you install dockutil.

Executing the script below will remove the specified app from the Dock. The app remains installed on the device and can be accessed via other methods.

For example,

/usr/local/bin/dockutil --remove 'FaceTime' --allhomes

Mask hidden apps

Executing the script below will dim the icon of the hidden application. This script comes in handy when you are using the keyboard shortcut Command (⌘) + H to hide an application on a Mac. When you do so, the application that you are hiding will appear as a dimmed icon in the dock, helping you differentiate it from the other icons available on the dock. However, the apps that were hidden before the script execution won’t be dimmed.

In the above script, if you specify ‘no’ next to the ‘-boolean’ option, the hidden apps won’t be dimmed.

Disable auto hide delay or modify auto hide animation duration

This script works only if the “Automatically hide and show the Dock” setting is enabled on the device end. By executing the script below, you can either disable the delay or adjust the duration within which the auto hide animation should complete. The auto hide animation duration depends on the integer value given in the script. A value of ‘0’ indicates no delay, ‘1’ indicates the Dock will take 1 second to complete the auto-hide animation, ‘2’ indicates the Dock will take 2 seconds to complete the auto-hide animation.

Notes:

  • The above commands apply to the logged-in user at the time of the script execution.
  • It is recommended to manually validate the script execution on a system before executing the action in bulk.
  • Hexnode will not be responsible for any damage/loss to the system on the behavior of the script.

  • Sample Script Repository