mac
The mac module manages common macOS preferences from Lua: Dock, Finder, input, hot corners, hostname, Touch ID for sudo, and lower-level defaults writes.
local mac = require("rootbeer.mac")Configure macOS
mac.dock({
autohide = true,
tile_size = 48,
position = "bottom",
show_recents = false,
minimize_effect = "scale",
})
mac.finder({
show_extensions = true,
show_hidden = true,
show_path_bar = true,
default_view = "list",
search_scope = "current",
})
mac.hot_corners({
top_right = "notification_center",
bottom_left = "lock_screen",
})
mac.input({
tap_to_click = true,
key_repeat_rate = 2,
initial_key_repeat = 15,
})
mac.hostname({ name = "my-mac" })
mac.touch_id_sudo()Write Custom Defaults
For preferences that don't have a helper yet, use mac.defaults() directly:
mac.defaults({
{ domain = "com.apple.LaunchServices", key = "LSQuarantine", type = "bool", value = false },
{ domain = "NSGlobalDomain", key = "NSAutomaticSpellingCorrectionEnabled", type = "bool", value = false },
})API Reference
mac.defaults(entries)
Writes macOS defaults entries. Each entry runs defaults write domain key -type value.
Parameters
entriesmac.DefaultEntry[]mac.dock(cfg)
Configures the macOS Dock and restarts it to apply changes.
Parameters — cfg: mac.DockConfig
autohidebooleanoptionalfalse.autohide_delaynumberoptionalautohide is true.large_sizenumberoptionalmagnification is true.magnificationbooleanoptionalminimize_effect"genie"|"scale"|"suck"optionalminimize_to_appbooleanoptionalposition"bottom"|"left"|"right"optionalshow_recentsbooleanoptionaltile_sizenumberoptionalmac.finder(cfg)
Configures macOS Finder and restarts it to apply changes.
Parameters — cfg: mac.FinderConfig
default_view"column"|"gallery"|"icon"|"list"optionalsearch_scope"current"|"mac"|"previous"optionalshow_extensionsbooleanoptionalshow_hiddenbooleanoptionalshow_path_barbooleanoptionalshow_status_barbooleanoptionalmac.hostname(cfg)
Sets the macOS hostname via scutil. Sets ComputerName, HostName, and LocalHostName. Requires sudo to take effect.
Parameters — cfg: mac.HostnameConfig
namestringmac.hot_corners(cfg)
Configures macOS hot corners.
Parameters — cfg: mac.HotCorner
bottom_left"disabled" | "mission_control" | "app_windows" | "desktop" | "start_screensaver" | "disable_screensaver" | "notification_center" | "launchpad" | "quick_note" | "lock_screen" | "display_sleep"optionalbottom_right"disabled" | "mission_control" | "app_windows" | "desktop" | "start_screensaver" | "disable_screensaver" | "notification_center" | "launchpad" | "quick_note" | "lock_screen" | "display_sleep"optionaltop_left"disabled" | "mission_control" | "app_windows" | "desktop" | "start_screensaver" | "disable_screensaver" | "notification_center" | "launchpad" | "quick_note" | "lock_screen" | "display_sleep"optionaltop_right"disabled" | "mission_control" | "app_windows" | "desktop" | "start_screensaver" | "disable_screensaver" | "notification_center" | "launchpad" | "quick_note" | "lock_screen" | "display_sleep"optionalmac.input(cfg)
Configures macOS input preferences (keyboard and trackpad).
Parameters — cfg: mac.InputConfig
initial_key_repeatnumberoptionalkey_repeat_ratenumberoptionalnatural_scrollingbooleanoptionaltap_to_clickbooleanoptionalmac.touch_id_sudo()
Enables Touch ID for sudo by writing /etc/pam.d/sudo_local. This is the Apple-recommended method that persists across macOS updates. Requires sudo to take effect.
mac.DefaultEntry
domainstring"com.apple.dock", "NSGlobalDomain").keystringtype"bool"|"float"|"int"|"string"valueboolean|string|number