To run this, simply run ./organizeDock.js
in a Terminal while in the directory that this script is saved.
Created
June 26, 2025 12:23
-
-
Save thomasstep/32f45acbe40f65bb01b4a10f2ab8ee7f to your computer and use it in GitHub Desktop.
Organize Mac Dock
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env osascript -l JavaScript | |
const app = Application.currentApplication(); | |
app.includeStandardAdditions = true; | |
function run(input, parameters) { | |
const appsToRemove = [ | |
'App Store', | |
'Pages', | |
'Notes', | |
]; | |
const sysEvents = Application('System Events'); | |
appsToRemove.forEach((app) => { | |
try { | |
sysEvents.processes['Dock'].lists[0].uiElements.byName(app).actions['AXShowMenu'].perform(); | |
delay(0.5); | |
sysEvents.processes['Dock'].lists[0].uiElements.byName(app).menus[0].menuItems['Options'].click(); | |
delay(0.5); | |
sysEvents.processes['Dock'].lists[0].uiElements.byName(app).menus[0].menuItems['Options'].menus[0].menuItems['Remove from Dock'].click(); | |
delay(0.5); | |
} catch (err) { | |
console.log(`Error removing ${app}`); | |
console.log(err); | |
} | |
}); | |
const appsToOpen = [ | |
'Slack', | |
'Activity Monitor', | |
]; | |
appsToOpen.forEach((app) => { | |
try { | |
Application(app).activate(); | |
console.log(`Opened ${app}`); | |
} catch (err) { | |
console.log(`Error opening ${app}`); | |
console.log(err); | |
} | |
}); | |
return input; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment