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 speed

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 Notes and Screenshot apps to the Dock.

Notes:

  • The currently opened apps and certain permanent apps like Finder and Bin will be retained in the Dock.

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. The following set of commands helps you with it.

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

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