#!/bin/bash
echo "--- Installing homebrew ---"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
(echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"

echo "--- Downloading Brewfile ---"
curl -o Brewfile https://share.zotan.services/macx-resources/Brewfile

echo "--- Running brew bundle ---"
brew bundle

echo "--- Running postinstall steps ---"
echo "Configuring pinentry-mac"
mkdir -p ~/.gnupg
echo "pinentry-program /opt/homebrew/bin/pinentry-mac" >> ~/.gnupg/gpg-agent.conf

echo "Configuring dock autohide"
defaults write com.apple.dock autohide -int 1
defaults write com.apple.dock autohide-delay -int 0
defaults write com.apple.dock autohide-time-modifier -float 0.4
killall Dock

echo "Disabling font smoothing"
defaults -currentHost write -g AppleFontSmoothing -int 0



####
echo
echo "All done. Please reboot to make sure everything is applied."
