Last active
March 19, 2020 12:42
-
-
Save phuctm97/6546dbd640469e0653f484940f26e7b1 to your computer and use it in GitHub Desktop.
Automation script to configure macOS preferences from command line
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
#!/bin/bash | |
osascript -il JavaScript prefs.js |
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
// Options. | |
const prefs = { | |
appearance: { | |
appearance: "blue", // the overall look of buttons, menus and windows. | |
fontSmoothing: true, // is font smoothing on? | |
fontSmoothingStyle: "automatic", // the method used for smoothing fonts ("automatic", "light", "medium", "standard" or "strong"). | |
highlightColor: "blue", // color used for hightlighting selected text and lists ("blue", "gold", "graphite", "green", "orange", "purple", "red" or "silver"). | |
recentApplicationsLimit: 0, // the number of recent applications to track. | |
recentDocumentsLimit: 0, // the number of recent documents to track. | |
recentServersLimit: 0, // the number of recent servers to track. | |
scrollBarAction: "jump to next page", // the action performed by clicking the scroll bar. | |
smoothScrolling: true, // is smooth scrolling used? | |
darkMode: true // use dark menu bar and dock. | |
}, | |
dock: { | |
animate: true, // is the animation of opening applications on or off? | |
autohide: true, // is autohiding the dock on or off? | |
dockSize: 0.25, // size/height of the items (between 0.0 (minimum) and 1.0 (maximum)). | |
magnification: false, // is magnification on or off? | |
magnificationSize: 0, // maximum magnification size when magnification is on (between 0.0 (minimum) and 1.0 (maximum)). | |
minimizeEffect: "genie", // minimization effect ("genie" or "scale"). | |
screenEdge: "left", // location on screen ("bottom", "left" or "right"). | |
} | |
}; | |
// Configurations. | |
const App = Application.currentApplication(); | |
App.includeStandardAdditions = true; | |
App.strictPropertyScope = true; | |
App.strictCommandScope = true; | |
App.strictParameterType = true; | |
const SystemEvents = Application("System Events"); | |
// Apply. | |
function apply() { | |
for(let k in prefs.appearance) { | |
SystemEvents.appearancePreferences[k] = prefs.appearance[k]; | |
} | |
for(let k in prefs.dock) { | |
SystemEvents.dockPreferences[k] = prefs.dock[k]; | |
} | |
} | |
// Check. | |
function check() { | |
const currPrefs = { | |
appearance: {}, | |
dock: {} | |
}; | |
for(let k in prefs.appearance) { | |
currPrefs.appearance[k] = SystemEvents.appearancePreferences[k](); | |
} | |
for(let k in prefs.dock) { | |
currPrefs.dock[k] = SystemEvents.dockPreferences[k](); | |
} | |
return currPrefs; | |
} | |
function run() { | |
console.log(JSON.stringify(check(), null, 2)); | |
} |
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
#!/bin/bash | |
# Install XCode command line tools. | |
xcode-select --install | |
# Install Homebrew. | |
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment