Skip to main content

macOS Automation

This setup includes macOS-specific automation and preferences.

Defaults / Settings

The raw scripts live here:

They are applied via hooks:

These scripts can change system behavior. Expect that some changes require a logout/restart to fully take effect.

If you want to disable this category entirely, the most direct approach is to remove or comment out the relevant hook scripts in home/.chezmoiscripts/.

Core Apply Workflow

  1. Review local dotfiles changes:
chezmoi diff
  1. Apply:
chezmoi apply
  1. Reboot/log out if settings did not visually update yet.

You can also run .osx scripts directly while debugging:

bash home/.osx.core
bash home/.osx.extra

Hammerspoon

Key pieces:

In init.lua, Hyper is configured as ctrl+alt+cmd.

This setup pulls the EmmyLua.spoon via externals:

Workflow:

  • Edit modules under home/dot_hammerspoon/.
  • Reload Hammerspoon config from the app menu.
  • Verify configured keybindings in init.lua and module files.

Karabiner

Workflow:

  • Edit karabiner.json.
  • Import/reload through Karabiner-Elements.
  • Validate by testing the modified key mapping directly.

Alfred

Note: this directory is currently ignored by chezmoi via home/.chezmoiignore. It is kept in the repo as a reference/backup rather than being automatically installed.

Custom App Icons

Note: home/app_icons/ is ignored by chezmoi via home/.chezmoiignore. The script reads icon assets from the repo source directory.

Scheduled jobs (crontab)

A user crontab is installed (replacing the existing one) from a repo-managed file:

The hook is a thin wrapper that runs crontab "$CHEZMOI_SOURCE_DIR/crontab"; the hash trigger means it only re-installs when the file changes. The shipped entry kills the macOS git fsmonitor--daemon every 5 minutes, working around the daemon's tendency to wedge or pin CPU on large repos.

*/5 * * * * /usr/bin/pkill -f ".../git-core/git fsmonitor--daemon" >/dev/null 2>&1

Edit home/crontab and chezmoi apply to change the schedule, or run crontab -l to inspect the installed table. To opt out, remove the hook script and clear the entry with crontab -e.

Verification

Check a few high-signal defaults:

defaults read -g KeyRepeat
defaults read com.apple.screencapture location
defaults read net.freemacsoft.AppCleaner SUAutomaticallyUpdate

Check icon command wiring:

command -v ,apply-app-icons

Troubleshooting

  • defaults changes did not apply:
    • restart affected apps (Finder, Dock, SystemUIServer) or reboot.
  • ,apply-app-icons fails:
  • Hook runs but nothing changed:
    • confirm the script hash-trigger input actually changed.