From 5702cfa639948fcfc9235dd8298b7081cfd60f07 Mon Sep 17 00:00:00 2001 From: Swiss-Mac-User Date: Sun, 5 May 2024 08:50:24 +0200 Subject: [PATCH] =?UTF-8?q?Adds=20various=20macOS=20settings=20&=20Gaming?= =?UTF-8?q?=20App=20=C2=ABHeroic=C2=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit macOS settings: Apple Messages & Music apps, fn-Key functionality, draggable windows, Trash bin auto-cleanup, Mouse acceleration. --- Applications/Heroic.sh | 27 +++++++++++++ README.md | 76 +++++++++++++++++++++++-------------- Usersettings/Finder.sh | 12 ++++++ Usersettings/Keyboard.sh | 23 +++++++++++ Usersettings/Messages.sh | 8 ++++ Usersettings/Music.sh | 7 ++++ Usersettings/Screenshots.sh | 7 ++-- Usersettings/Trackpad.sh | 13 +++++-- config.default.sh | 33 ++++++++++------ run.sh | 35 ++++++++++++++++- 10 files changed, 194 insertions(+), 47 deletions(-) create mode 100644 Applications/Heroic.sh create mode 100644 Usersettings/Keyboard.sh create mode 100644 Usersettings/Messages.sh create mode 100644 Usersettings/Music.sh diff --git a/Applications/Heroic.sh b/Applications/Heroic.sh new file mode 100644 index 0000000..7ba37a9 --- /dev/null +++ b/Applications/Heroic.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env zsh + +# Transmission.app +function installAppHeroicGamesLauncher(){ + # --> App version to use + local version="2.14.1" + local platform="-arm64" + # --> Set Download URL + if checkIfAppleSilicion; then + # ...for ARM-based Apple Silicon Macs + local downloadUrl="https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher/releases/download/v$version/Heroic-$version-macOS-arm64.dmg" + else + # ...for Intel-based Macs + platform="" + local downloadUrl="https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher/releases/download/v$version/Heroic-$version-macOS-x64.dmg" + fi + # --> Download + downloadFromUrl "downloadUrl" "Heroic.dmg" + # --> Mount & copy + # (Cannot use unmountFile() function due to Volume having a different name than the App) + hdiutil attach "$downloadFolder/Heroic.dmg" -quiet + cp -r "/Volumes/Heroic $version$platform/Heroic.app" "$downloadFolder" + # --> Unmount & move + hdiutil unmount "/Volumes/Heroic $version-$platform" -force -quiet + moveApplication "Heroic.app" +} +export -f installAppHeroicGamesLauncher diff --git a/README.md b/README.md index bbd346c..363a9d3 100644 --- a/README.md +++ b/README.md @@ -1,53 +1,88 @@ Automate your macOS setup === -**Welcome to the macOS Scripted Setup!
This project helps Mac users quickly and easily set up a new computer or useraccount by automatically configuring a range of system settings and installing commonly used applications.** +**Welcome to the macOS Scripted Setup.
This project helps Mac users quickly and easily set up a new computer or useraccount by automatically configuring a range of system settings and installing commonly used applications.** + +> [!TIP] +> The scripted setup was tested on Intel-based Macs & Apple Silicon Macs +> On macOS 12 Monterey up to macOS 14 Sonoma + ## What is this? +The macOS Scripted Setup is **perfect for users who want to save time and avoid the hassle of manually changing settings and installing apps**. The whole project, but particularly the configuration file, is **portable** - so you can keep them on a USB-stick for the next Mac setup. Give it a try and streamline your new Mac setup process! + ![Screenshot of macOS Scripted Setup in action](/README_demo.png?raw=true) The script is easy to use and can be run directly from the Terminal application, as a regular user or admin user. It automatically performs a series of commands to change default macOS settings and download applications. It's designed to be widely backward and forward compatible with various macOS versions. -**All settings can be configured!** Some features include enabling the firewall, setting better security features, customising the Finder, Dock, and Mission Control for better productivity; and many more. Additionally, the script installs applications such as browsers, media players, productivity apps, and web development tools. +**All settings can be configured.** Some features include enabling the firewall, setting better security features, customising the Finder, Dock, and Mission Control for better productivity; and many more. Additionally, the script installs applications such as browsers, media players, productivity apps, and web development tools. -The macOS Scripted Setup is **perfect for users who want to save time and avoid the hassle of manually changing settings and installing apps**. The whole project, but particularly the configuration file, is **portable** - so you can keep them on a USB-stick for the next Mac setup. Give it a try and streamline your new Mac setup process! +### What is being done exactly? -## How to use +
+See what features, settings, and applications can be changed / installed + +### The script can change the following settings: + +* FileVault, macOS Firewall, Mission Control, Control Centre, Finder, Dock, git, SSH Key, adds Userhome folders, Menu bar clock, Fast User Switching, and [more](https://github.com/Swiss-Mac-User/macOS-scripted-setup/tree/installer/Usersettings). -P.s.: the scripts were tested successfully on Apple Silicon Mac and macOS 13 Ventura. +### …and is capable of installing these Apps: + +Some Apps are downloaded from the official websites, other are added through Homebrew or its Mac App Store CLI extension. + +* 1Password, AlDente, Beyond Compare, Boop, Brave, Composer, Discord, Docker, eqMac, Fig, Firefox, Fork, GasMask, Git, Google Chrome, Homebrew, Keka, LinearMouse, MAMP, Nova, Pixelmator Pro, Quick Look plugins, Rosetta 2, Safari extensions, Sequel Ace, SonarQube, Spotify, Steam, Strongbox, Telegram, Transmission, Tresorit, Warp, Xcode Command Line Tools, Xnapper, and [more](https://github.com/Swiss-Mac-User/macOS-scripted-setup/tree/installer/Applications). +
+ + +## How to use ### 📥 Download macOS Scripted Setup -Fast and easy download with this command in the `Terminal.app`: +Automatic download with this command in the `Terminal.app` from Applications » Utilities: ```bash curl -SL "https://github.com/Swiss-Mac-User/macOS-scripted-setup/archive/refs/heads/installer.zip" | tar xz -C "$HOME/Downloads" && open "$HOME/Downloads/macOS-scripted-setup-installer" ``` -Alternatively you can manually download & extract the latest «Source code (zip)» [from Releases](/../../releases) to your `~/Downloads/` folder. +→ Alternatively you can manually download & extract the latest «Source code (zip)» [from Releases](/../../releases) to your `~/Downloads/` folder. ### ⚙️ Configure your preferences 1. Duplicate the file `config.default.sh` as `config.sh` -2. Open `config.sh` with TextEdit +2. Open `config.sh` in a Text editor (e.g. `TextEdit.app`) + +3. …and change all settings to your personal preferences, using `true`/`false`. + +> [!WARNING] +> If no `config.sh`-file is present, the setup will use the default configs from `config.default.sh`! + +#### Advanced settings +
+Configuring custom bash commands to run + +If you want to run additional bash commands as part of the setup, you can duplicate the template-file `mycommands.template.sh` as `mycommands.sh`, and populate it with any commands. These custom commands will be executed LAST in the whole setup (see the `run.sh` file). + +
-3. …and change all settings to your personal preferences, using `true`/`false`.
(Note: if no `config.sh` is present, it will fall back to the default configs) ### 🚀 Start the scripted Setup -Maybe now is the time to go and get a coffee ☕️… +Maybe now is the time to [grab a coffee ☕️](https://bmc.link/swissmacuser/)… 1. Open the «Terminal.app» from Applications » Utilities -2. Paste the following command to the Terminal.app, and start the setup by pressing `Return`: +2. Paste the following command to the Terminal.app: ```bash cd ~/Downloads/macOS-scripted-setup-installer/ && chmod +x ./run.sh && ./run.sh ``` -Watch the magic happen… and occasionally interact when instructions show up (e.g. sign-in on the Mac App Store-App). +3. Now start the setup by pressing `Return` & watch the magic happen… + +> [!TIP] +> **Occasionally you have to interact** when instructions show up, such as to sign-in on the Mac App Store. #### ✨ That's it - happy installation! :) @@ -61,23 +96,6 @@ Report an [Issue](/../../issues) or start a [new Discussion](/../../discussions) Feel free to [fork this project](/../../fork) and add Pull Requests for any suggested changes or additions! - -## Advanced settings - -If you want to run additional bash commands as part of the setup, you can duplicate the template-file `mycommands.template.sh` as `mycommands.sh`, and populate it with any commands. These custom commands will be executed LAST in the whole setup (see the `run.sh` file). - -### What is being done? - -The script changes the following settings: - -* FileVault, macOS Firewall, Mission Control, Control Centre, Finder, Dock, git, SSH Key, adds Userhome folders, Menu bar clock, Fast User Switching, and more. - -…and is capable of installing these Apps: - -* Xcode Command Line Tools, Homebrew, Rosetta 2, Keka, Quick Look plugins, 1Password, Safari extensions, Beyond Compare, Discord, Fig, Firefox, Google Chrome, Pixelmator Pro, Spotify, Strongbox, Telegram, Transmission, Tresorit, Warp, Xnapper, Git, Boop, Composer, Docker, SonarQube, Fork, GasMask, MAMP, Nova, Sequel Ace, and others. - -Some Apps are downloaded from the official websites, other are added through Homebrew or its Mac App Store CLI extension. - ---

diff --git a/Usersettings/Finder.sh b/Usersettings/Finder.sh index ea3abde..e2728a1 100644 --- a/Usersettings/Finder.sh +++ b/Usersettings/Finder.sh @@ -59,6 +59,12 @@ function disableNaturalScrolling(){ } export -f disableNaturalScrolling +# Interface: allow dragging windows anywhere using Command+Control+Click +function enableFullWindowDragzone(){ + defaults write NSGlobalDomain "NSWindowShouldDragOnGesture" -bool TRUE +} +export -f enableFullWindowDragzone + # Interface, disable menu bar transparency function disableTransparencyAndTinting(){ defaults write NSGlobalDomain "AppleEnableMenuBarTransparency" -bool FALSE @@ -148,6 +154,12 @@ function disableEmptyTrashWarning(){ } export -f disableEmptyTrashWarning +# Automatically remove items from the Trash after 30 days +function enableTrashAutoremove30days(){ + defaults write com.apple.finder "FXRemoveOldTrashItems" -bool TRUE +} +export -f enableTrashAutoremove30days + # Add Folder settings (.DS_Store files) function updateApplicationsFolderListColumns(){ if ! checkIfFileExists "$HOME/Applications/.DS_Store"; then diff --git a/Usersettings/Keyboard.sh b/Usersettings/Keyboard.sh new file mode 100644 index 0000000..dda7091 --- /dev/null +++ b/Usersettings/Keyboard.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env zsh + +# Keyboard fn 🌐 key shows Emoji & Symbols popup. Supported values: +# --> 0 = No function / do nothing (default) +# --> 1 = Change keyboard input source +# --> 2 = Show "Emoji & Symbols" +# --> 3 = Start Dictation (press 2x) +function useFnKeyFor(){ + local changeMode=false + local configFnKeyFunctionanlity=$1 + case "$configFnKeyFunctionanlity" in + off) changeMode=0;; + language) changeMode=1;; + emoji) changeMode=2;; + dictation) changeMode=3;; + *) changeMode=false;; + esac + + if [ "$changeMode" != false ]; then + defaults write com.apple.HIToolbox "AppleFnUsageType" -int $changeMode + fi +} +export -f useFnKeyFor diff --git a/Usersettings/Messages.sh b/Usersettings/Messages.sh new file mode 100644 index 0000000..5252245 --- /dev/null +++ b/Usersettings/Messages.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env zsh + +# Show the subject field in Messages (subjects are sent in bold format) +# Source: https://gist.github.com/getaaron/a9dc64b6ea2fa8299af6b7077f4386ae +function enableMessagesSubjectField(){ + defaults write com.apple.MobileSMS "MMSShowSubject" -bool TRUE +} +export -f enableMessagesSubjectField diff --git a/Usersettings/Music.sh b/Usersettings/Music.sh new file mode 100644 index 0000000..f83a774 --- /dev/null +++ b/Usersettings/Music.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env zsh + +# Display «Playing next» Notification +function showNextSongNotification(){ + defaults write com.apple.Music "userWantsPlaybackNotifications" -bool TRUE +} +export -f showNextSongNotification diff --git a/Usersettings/Screenshots.sh b/Usersettings/Screenshots.sh index eb88dcd..c484d5e 100644 --- a/Usersettings/Screenshots.sh +++ b/Usersettings/Screenshots.sh @@ -11,14 +11,15 @@ export -f useNumericScreenshots # Supported file types: png (default), bmp, gif, heic, jpg, jp2, tif, pict, pdf, tga, tiff function saveScreenshotsAs(){ local changeFormat=false - case "$ScreenshotsImageFormat" in + local configUseScreenshotsFormat="$1" + case "$configUseScreenshotsFormat" in png) changeFormat=false;; - bmp|gif|heic|jpg|jp2|tif|pict|pdf|tga|tiff) changeFormat="$ScreenshotsImageFormat";; + bmp|gif|heic|jpg|jp2|tif|pict|pdf|tga|tiff) changeFormat="$configUseScreenshotsFormat";; *) changeFormat=false;; esac # Screenshot format is valid and not default (png): - if [ ! "$changeFormat" ]; then + if [ "$changeFormat" != false ]; then defaults write com.apple.screencapture "type" -string "$changeFormat" fi } diff --git a/Usersettings/Trackpad.sh b/Usersettings/Trackpad.sh index ad38bde..38bb579 100644 --- a/Usersettings/Trackpad.sh +++ b/Usersettings/Trackpad.sh @@ -6,14 +6,21 @@ function enableTrackpadClicking(){ # Enable Single Tap to Click defaults write com.apple.AppleMultitouchTrackpad "Clicking" -int 1 # Enable Right Click + defaults write com.apple.driver.AppleBluetoothMultitouch.mouse MouseButtonMode -string 'TwoButton' defaults write com.apple.AppleMultitouchTrackpad "TrackpadRightClick" -int 1 } export -f enableTrackpadClicking # --> Increase Mouse speed on Trackpads and Mouses function increaseMouseSpeed(){ - # -g = Setting is in .GlobalPreferences.plist - defaults write -g com.apple.trackpad.scaling -int 2 - defaults write -g com.apple.mouse.scaling -float 1.5 + defaults write NSGlobalDomain com.apple.trackpad.scaling -int 2 + defaults write NSGlobalDomain com.apple.mouse.scaling -float 1.5 } export -f increaseMouseSpeed + +# --> Disable Mouse cursor acceleration +function disableMouseAcceleration(){ + defaults write NSGlobalDomain com.apple.mouse.linear -bool YES + +} +export -f disableMouseAcceleration diff --git a/config.default.sh b/config.default.sh index 2df402b..059cf6b 100644 --- a/config.default.sh +++ b/config.default.sh @@ -70,7 +70,7 @@ removeiMovie=false # -- 2.2 Required Applications -- # (others have dependencies for these) installXcodeTools=false -installHomebrew=false +installHomebrew=true installAppStoreApps=true # <-- requires Homebrew=TRUE installRosetta=false @@ -81,7 +81,7 @@ installSyntaxHighlightQuickLook=true # -- 2.4 Install Applications -- install1Password=false installAdGuardSafari=true -installAlDente=true # <-- only supported on MacBooks (MBA, MBP) +installAlDente=false # <-- only supported on MacBooks (MBA, MBP) installBeyondCompare=false installBraveBrowser=false installDiscord=false @@ -89,7 +89,7 @@ installEqMac=false installFigma=false installFirefox=false installGoogleChrome=false -installGrandPerspective=true +installGrandPerspective=false installLinearMouse=false installMacsFanControl=false installMicrosoftOffice=false @@ -115,13 +115,14 @@ installBoop=false installComposer=false # <-- will also install PHP installDocker=false # <-- only installed when MAMP=FALSE useOrbStackOverDocker=false # <-- use OrbStack instead of Docker -installSonarQube=false # <-- only installed when Docker=TRUE installFork=false installGasMask=false installMAMP=false installSequelAce=false +installSonarQube=false # <-- only installed when Docker=TRUE # -- 2.6 Mac Gaming Apps and Games -- +installHeroicGamesLauncher=false installSteam=false installWhisky=false @@ -129,17 +130,26 @@ installWhisky=false # 3. User and App Settings # ------------------------------ # -- 3.1 macOS Layout / User Interface -- +# ---- 3.1.1 Menu Bar ---- dateTimeInMenubar=true -useMissionControl=true enableFastUserswitching=true +useMissionControl=true disableTransparency=true +showBatteryPercentage=true # <-- only applied on MacBooks (MBA, MBP) +# ---- 3.1.2 Window handling ---- +enableFullDraggableWindows=false showScrollbars=true -disableNaturalScrolling=true +# ---- 3.1.3 Text handling ---- disableAnnoyingTextcorrections=true -useRealNamesForContacts=true +# ---- 3.1.4 Keyboard & Mouse ---- +disableNaturalScrolling=true enableTrackpadClicks=true # <-- only applied on MacBooks (MBA, MBP) -showBatteryPercentage=true # <-- only applied on MacBooks (MBA, MBP) fasterMouseCursor=true +fnKeyFunctionanlity='emoji' # Modes: off=Do nothing, emoji=Emojis & Symbols, language=Input sources, dictation=Start Dictation +# ---- 3.1.5 Apple Apps ---- +useRealNamesForContacts=true +showMusicNextSongPlaying=false +showSubjectInMessagesApp=false # -- 3.2 macOS Finder customizations -- customizeFinder=true # <-- If false, below settings will have NO effect @@ -155,11 +165,11 @@ minimalDock=false showLibraryFolder=true addUserApplicationsFolder=true addUserWebsitesFolder=true -# -- 3.4.1 «Games» folder -- +# ---- 3.4.1 «Games» folder ---- addUserGamesFolder=true useCustomGamesFolderIcon=true # <-- Requires Games Folder (addUserGamesFolder=TRUE) useCustomGamesFolderIconURL='https://swissmacuser.ch/wp-content/uploads/2021/06/Games-Folder-Icon-macOS-12-Monterey-detailed.png' -# -- 3.4.2 Wallpapers (Desktop Pictures) -- +# ---- 3.4.2 Wallpapers (Desktop Pictures) ---- downloadWallpapers=true # <-- Required to download any Wallpapers dynamicWallpaperExodus=false dynamicWallpaperFuji=false @@ -167,10 +177,11 @@ dynamicWallpaperISS=false # -- 3.5 Terminal app settings -- enableTerminalUtf8=true -useCustomTerminalTheme=true # <-- Requires the URL from next line to download .terminal Theme file +useCustomTerminalTheme=false # <-- Requires the URL from next line to download .terminal Theme file useCustomTerminalThemeURL='https://gist.githubusercontent.com/oliveratgithub/c9dde424966a7b9b5b7e9d1c28bf8f2e/raw/' useCustomTerminalConfigurations=false # If true, a URL is required to download and apply .zhsrc commands useCustomTerminalConfigurationsURL='' # -- 3.6 Application Hardening -- secureSafariBrowser=true +removeTrashbinItemsPeriodically=true # Auto-remove items from Trash after 30 days diff --git a/run.sh b/run.sh index a5d7d6f..d2140fa 100644 --- a/run.sh +++ b/run.sh @@ -165,6 +165,11 @@ if [ "$fasterMouseCursor" = true ]; then increaseMouseSpeed showinfo "" "confirm" fi +if [ "$fnKeyFunctionanlity" != 'off' ] || [ "$fnKeyFunctionanlity" != false ]; then + showinfo "Changing fn 🌐 key functionality:" "note" + useFnKeyFor "$fnKeyFunctionanlity" + showinfo "" "confirm" +fi # -- Dock -- if [ "$speedupDock" = true ]; then @@ -222,11 +227,19 @@ if [ "$customizeFinder" = true ]; then showVolumeIconsOnDesktop enableSnapToGrid updateApplicationsFolderListColumns + if [ "$enableFullDraggableWindows" = true ]; then + showinfo "Making all windows fully draggable using ⌘Command+^Control+Click:" "note" + enableFullWindowDragzone + fi + if [ "$removeTrashbinItemsPeriodically" = true ]; then + showinfo "Trash bin: automatically remove items after 30 days:" "note" + enableTrashAutoremove30days + fi showinfo "" "confirm" # --> Screenshots showinfo "Improving Screenshots:" "note" - saveScreenshotsAs + saveScreenshotsAs "$useScreenshotsFormat" if [ "$useScreenshotsNumericFilename" = true ]; then useNumericScreenshots fi @@ -249,6 +262,18 @@ if [ "$customizeFinder" = true ]; then restartFinder showinfo "" "confirm" fi +# -- Apple Apps -- +if [ "$showMusicNextSongPlaying" = true ]; then + showinfo "Show «Playing next» notification from Music App:" "note" + showNextSongNotification + showinfo "" "confirm" +fi +if [ "$showSubjectInMessagesApp" = true ]; then + showinfo "Show the Subject field in Messages App:" "note" + enableMessagesSubjectField + showinfo "" "confirm" +fi + # -- Safari -- if [ "$secureSafariBrowser" = true ]; then showinfo "More Privacy and Security for Safari:" "notice" @@ -420,10 +445,18 @@ if [ "$installGrandPerspective" = true ]; then installAppGrandPerspective showinfo "" "confirm" fi +# -- Heroic Games Launcher -- +if [ "$installHeroicGamesLauncher" = true ]; then + showinfo "Installing Heroic Games Launcher:" "note" + installAppHeroicGamesLauncher + showinfo "" "confirm" +fi # -- LinearMouse.app -- if [ "$installLinearMouse" = true ]; then showinfo "Installing LinearMouse:" "note" installAppLinearMouse + showinfo "Disabling Mouse cursor acceleration of macOS:" "note" + disableMouseAcceleration showinfo "" "confirm" fi # -- Macs Fan Control.app --