Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Brewfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ cask "google-chrome"
cask "docker-desktop"
cask "1password"
cask "1password-cli" # `op`
cask "sizeup" # keyboard-driven window manager
cask "rectangle" # keyboard-driven window manager
cask "clipy" # clipboard manager with history
cask "thaw" # menu bar manager — succeeded Ice
cask "keyboardcleantool" # blocks input for keyboard cleaning
Expand Down
22 changes: 12 additions & 10 deletions macos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ One-time system setup for fresh macOS installs. Not a stow package.
```bash
bash macos/defaults.sh # apply
bash macos/defaults.sh --check # report drift, write nothing, exit 1 if any
bash macos/defaults.sh --capture # re-copy SizeUp's live shortcuts into SizeUp.plist
bash macos/defaults.sh --capture # re-copy Rectangle's live shortcuts into RectangleConfig.json
```

Idempotent — safe to re-run. `bootstrap.sh` prompts to run it; `doctor.sh` calls
Expand All @@ -26,7 +26,8 @@ apply writes. Booleans are normalised before comparison, since `defaults read`
prints `0`/`1` rather than `false`/`true`.

Nested values (dicts, arrays) use type `plist`: the row's value names a file in
`macos/` holding that key's value. Apply passes the XML straight to
`macos/` holding that key's value; `file:path` reads it from the dict at key
path `path` inside the file, which may be plist or JSON. Apply passes the XML straight to
`defaults write`, which keeps every type; check compares the XML `plutil`
renders from both sides.

Expand All @@ -38,14 +39,15 @@ an explicit check branch.

Read `SETTINGS` for the exact list. In summary: appearance, keyboard, text
substitution, trackpad, Dock, Finder, screen saver, menu bar, and
per-app defaults for SizeUp and Clipy. Beyond the table:

- **SizeUp** — every shortcut and window size, stored as `plist` rows backed by
[`SizeUp.plist`](SizeUp.plist). After changing SizeUp's preferences, run
`bash macos/defaults.sh --capture` and commit the diff. Capture copies only
the keys listed in `SETTINGS`, so usage counters, update timestamps, and window
positions in the same domain stay out of the repo; a new key needs its row
added first. Quit and relaunch SizeUp after an apply so it picks the values up.
per-app defaults for Rectangle and Clipy. Beyond the table:

- **Rectangle** — every shortcut, stored as `plist` rows backed by the
`shortcuts` dict of [`RectangleConfig.json`](RectangleConfig.json), Rectangle's
own export format. After changing shortcuts, either export from Rectangle's
settings over that file or run `bash macos/defaults.sh --capture` (which
rewrites it as compact JSON), then commit the diff. A new shortcut needs its
row added first. Quit and relaunch Rectangle after an apply so it picks the
values up. It launches at login via `LOGIN_ITEM_APPS`.

- **Dock contents** — populated via `dockutil` from `DOCK_APPS`. Entries whose app doesn't exist on this macOS version are skipped rather than aborting the run.
- **Screen saver** — password required immediately. *Best-effort:* since Ventura this pane is partly system-managed and the write may not stick; `--check` shows it as drift if so.
Expand Down
20 changes: 20 additions & 0 deletions macos/RectangleConfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"bundleId" : "com.knollsoft.Rectangle",
"defaults" : {},
"shortcuts" : {
"bottomHalf" : { "keyCode" : 125, "modifierFlags" : 1835008 },
"bottomLeft" : { "keyCode" : 125, "modifierFlags" : 917504 },
"bottomRight" : { "keyCode" : 124, "modifierFlags" : 917504 },
"center" : { "keyCode" : 8, "modifierFlags" : 1835008 },
"leftHalf" : { "keyCode" : 123, "modifierFlags" : 1835008 },
"maximize" : { "keyCode" : 46, "modifierFlags" : 1835008 },
"nextDisplay" : { "keyCode" : 124, "modifierFlags" : 786432 },
"previousDisplay" : { "keyCode" : 123, "modifierFlags" : 786432 },
"restore" : { "keyCode" : 44, "modifierFlags" : 1835008 },
"rightHalf" : { "keyCode" : 124, "modifierFlags" : 1835008 },
"topHalf" : { "keyCode" : 126, "modifierFlags" : 1835008 },
"topLeft" : { "keyCode" : 123, "modifierFlags" : 917504 },
"topRight" : { "keyCode" : 126, "modifierFlags" : 917504 }
},
"version" : "1"
}
197 changes: 0 additions & 197 deletions macos/SizeUp.plist

This file was deleted.

63 changes: 29 additions & 34 deletions macos/defaults.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# bash macos/defaults.sh apply everything
# bash macos/defaults.sh --check report drift, write nothing, exit 1 if any
# bash macos/defaults.sh --capture copy live values of plist-type settings
# (SizeUp's shortcuts) into their data files
# (Rectangle's shortcuts) into their data files
#
# Settings live in one SETTINGS table consumed by every mode, so a check can
# never fall out of sync with what apply writes.
Expand Down Expand Up @@ -42,9 +42,10 @@ note_ok() { [[ "$MODE" == check ]] && echo " ✓ $*"; return 0; }
# domain -g is the global domain in -currentHost scope; NSGlobalDomain elsewhere
# type bool | int | string
# plist → value names a file in macos/ holding <key>'s value, for
# nested dicts/arrays (user scope only). The rows double as
# the allowlist --capture copies, so volatile or private keys
# in the same domain never reach the repo.
# nested dicts/arrays (user scope only); file:path reads
# <key> from the dict at key path <path> inside the file. The
# rows double as the allowlist --capture copies, so volatile or
# private keys in the same domain never reach the repo.
# ---------------------------------------------------------------------------
SETTINGS=(
# ---- Appearance ----
Expand Down Expand Up @@ -107,29 +108,21 @@ SETTINGS=(
"user|com.apple.controlcenter|NSStatusItem VisibleCC NowPlaying|bool|true"

# ---- Third-party apps ----
"user|com.irradiatedsoftware.SizeUp|MenuEnabled|bool|false"
"user|com.irradiatedsoftware.SizeUp|suppressMenuBarDisabledPopup|bool|true"
"user|com.irradiatedsoftware.SizeUp|CenterResizeEnabled|bool|false"
"user|com.irradiatedsoftware.SizeUp|ShortcutsDisabled|bool|false"
# One row per SizeUp action: its shortcut (ComboCode/ComboFlags) and, for
# sizing actions, the window rect as screen fractions (X/Y/Width/Height).
"user|com.irradiatedsoftware.SizeUp|Center|plist|SizeUp.plist"
"user|com.irradiatedsoftware.SizeUp|Down|plist|SizeUp.plist"
"user|com.irradiatedsoftware.SizeUp|Full Screen|plist|SizeUp.plist"
"user|com.irradiatedsoftware.SizeUp|Left|plist|SizeUp.plist"
"user|com.irradiatedsoftware.SizeUp|Lower Left|plist|SizeUp.plist"
"user|com.irradiatedsoftware.SizeUp|Lower Right|plist|SizeUp.plist"
"user|com.irradiatedsoftware.SizeUp|Next Monitor|plist|SizeUp.plist"
"user|com.irradiatedsoftware.SizeUp|Prev Monitor|plist|SizeUp.plist"
"user|com.irradiatedsoftware.SizeUp|Right|plist|SizeUp.plist"
"user|com.irradiatedsoftware.SizeUp|SnapBack|plist|SizeUp.plist"
"user|com.irradiatedsoftware.SizeUp|Space Above|plist|SizeUp.plist"
"user|com.irradiatedsoftware.SizeUp|Space Below|plist|SizeUp.plist"
"user|com.irradiatedsoftware.SizeUp|Space Next|plist|SizeUp.plist"
"user|com.irradiatedsoftware.SizeUp|Space Prev|plist|SizeUp.plist"
"user|com.irradiatedsoftware.SizeUp|Up|plist|SizeUp.plist"
"user|com.irradiatedsoftware.SizeUp|Upper Left|plist|SizeUp.plist"
"user|com.irradiatedsoftware.SizeUp|Upper Right|plist|SizeUp.plist"
# One row per Rectangle action's shortcut, read from the "shortcuts" dict of
# Rectangle's own export format.
"user|com.knollsoft.Rectangle|bottomHalf|plist|RectangleConfig.json:shortcuts"
"user|com.knollsoft.Rectangle|bottomLeft|plist|RectangleConfig.json:shortcuts"
"user|com.knollsoft.Rectangle|bottomRight|plist|RectangleConfig.json:shortcuts"
"user|com.knollsoft.Rectangle|center|plist|RectangleConfig.json:shortcuts"
"user|com.knollsoft.Rectangle|leftHalf|plist|RectangleConfig.json:shortcuts"
"user|com.knollsoft.Rectangle|maximize|plist|RectangleConfig.json:shortcuts"
"user|com.knollsoft.Rectangle|nextDisplay|plist|RectangleConfig.json:shortcuts"
"user|com.knollsoft.Rectangle|previousDisplay|plist|RectangleConfig.json:shortcuts"
"user|com.knollsoft.Rectangle|restore|plist|RectangleConfig.json:shortcuts"
"user|com.knollsoft.Rectangle|rightHalf|plist|RectangleConfig.json:shortcuts"
"user|com.knollsoft.Rectangle|topHalf|plist|RectangleConfig.json:shortcuts"
"user|com.knollsoft.Rectangle|topLeft|plist|RectangleConfig.json:shortcuts"
"user|com.knollsoft.Rectangle|topRight|plist|RectangleConfig.json:shortcuts"
"user|com.clipy-app.Clipy|kCPYPrefShowStatusItemKey|bool|false"
)

Expand All @@ -148,7 +141,7 @@ DOCK_APPS=(

# Apps to register as login items.
LOGIN_ITEM_APPS=(
"/Applications/SizeUp.app"
"/Applications/Rectangle.app"
"/Applications/Mullvad VPN.app"
"/Applications/Amphetamine.app"
"/Applications/Thaw.app"
Expand Down Expand Up @@ -193,12 +186,14 @@ write_default() {
fi
}

# process_plist_setting <domain> <key> <file> — a nested value stored under
# <key> in <file>. `defaults write` accepts the XML document as-is and keeps
# every type; check compares both sides as plutil-rendered XML.
# process_plist_setting <domain> <key> <file>[:<path>] — a nested value stored
# under <key> (or <path>.<key>) in <file>, which may be plist or JSON.
# `defaults write` accepts the XML document as-is and keeps every type; check
# compares both sides as plutil-rendered XML.
process_plist_setting() {
local domain="$1" key="$2" file="$3" actual want
want="$(plutil -extract "$key" xml1 -o - "$file")"
local domain="$1" key="$2" file="${3%%:*}" actual want src="$2"
[[ "$3" == *:* ]] && src="${3#*:}.$key"
want="$(plutil -extract "$src" xml1 -o - "$file")"

if [[ "$MODE" == apply ]]; then
defaults write "$domain" "$key" "$want"
Expand All @@ -212,7 +207,7 @@ process_plist_setting() {
echo " ! $domain $key is unset — ${file##*/} left unchanged" >&2
return 0
fi
plutil -replace "$key" -xml "$actual" "$file"
plutil -replace "$src" -xml "$actual" "$file"
echo " ✓ captured $domain $key"
return 0
fi
Expand Down
Loading