Appearance
系统设置
本章将介绍 macOS 系统设置,包括系统偏好设置、配置管理和个性化定制。
系统设置概述
打开系统设置
bash
# 方法一:点击苹果菜单 → 系统设置
# 方法二:Spotlight 搜索 "系统设置"
# 方法三:命令行打开
open "x-apple.systempreferences:"
# 打开特定设置面板
open "x-apple.systempreferences:com.apple.preference.network"
open "x-apple.systempreferences:com.apple.preference.sound"
open "x-apple.systempreferences:com.apple.preference.displays"系统设置结构
text
macOS Ventura 及以后版本的系统设置结构:
系统设置
├── Apple ID
├── Wi-Fi
├── 蓝牙
├── 网络
├── 通知
├── 声音
├── 聚焦
├── 屏幕使用时间
├── 通用
│ ├── 关于本机
│ ├── 软件更新
│ ├── 存储空间
│ ├── AirDrop 与接力
│ ├── 登录项
│ └── 外观
├── 外观
├── 辅助功能
├── 控制中心
├── 侧边栏
├── Siri 与聚焦
├── 隐私与安全性
├── 桌面与程序坞
├── 显示器
├── 墙纸
├── 屏幕保护程序
├── 电池
├── 键盘
├── 触控板
├── 鼠标
├── 打印机与扫描仪
└── 用户与群组通用设置
关于本机
bash
# 查看系统信息
system_profiler SPHardwareDataType
# 查看软件信息
system_profiler SPSoftwareDataType
# 查看完整系统报告
system_profiler
# 查看序列号
system_profiler SPHardwareDataType | grep "Serial Number"
# 查看内存信息
system_profiler SPMemoryDataType
# 查看存储信息
system_profiler SPStorageDataType外观设置
bash
# 设置外观模式
# 浅色模式
defaults write NSGlobalDomain AppleInterfaceStyle -string "Light"
# 深色模式
defaults write NSGlobalDomain AppleInterfaceStyle -string "Dark"
# 自动切换
defaults delete NSGlobalDomain AppleInterfaceStyle
# 设置强调色
defaults write NSGlobalDomain AppleAccentColor -int 4
# 颜色值:-1=蓝色, 0=红色, 1=橙色, 2=黄色, 3=绿色, 4=蓝色, 5=紫色, 6=粉色
# 重启相关服务
killall Dock语言和地区
bash
# 查看当前语言
defaults read NSGlobalDomain AppleLanguages
# 设置语言
defaults write NSGlobalDomain AppleLanguages -array "zh-Hans"
# 设置地区
defaults write NSGlobalDomain AppleLocale -string "zh_CN"
# 设置时区
sudo systemsetup -settimezone "Asia/Shanghai"
# 列出可用时区
sudo systemsetup -listtimezones桌面与程序坞
Dock 设置
bash
# 设置 Dock 大小
defaults write com.apple.dock tilesize -int 48
# 启用放大效果
defaults write com.apple.dock magnification -bool true
defaults write com.apple.dock largesize -int 96
# 自动隐藏 Dock
defaults write com.apple.dock autohide -bool true
# 隐藏动画时间
defaults write com.apple.dock autohide-delay -float 0.5
# 显示/隐藏动画速度
defaults write com.apple.dock autohide-time-modifier -float 0.5
# 在 Dock 中显示最近使用的应用
defaults write com.apple.dock show-recents -bool true
# 重启 Dock 使设置生效
killall Dock桌面设置
bash
# 设置桌面壁纸
osascript -e 'tell application "Finder" to set desktop picture to POSIX file "/path/to/image.jpg"'
# 设置所有桌面的壁纸
for i in {1..10}; do
osascript -e "tell application \"System Events\" to tell desktop $i to set picture to \"/path/to/image.jpg\""
done
# 查看当前壁纸
osascript -e 'tell application "System Events" to get picture of every desktop'
# 设置壁纸填充方式
# fill: 填充, fit: 适应, stretch: 拉伸, center: 居中, tile: 平铺
defaults write com.apple.desktop Background '{default = {ImageFilePath = "/path/to/image.jpg"; Placement = "fill"; };}'显示器设置
分辨率设置
bash
# 查看显示器信息
system_profiler SPDisplaysDataType
# 列出可用分辨率
# 系统设置 → 显示器 → 分辨率
# 使用 displayplacer 工具
brew install displayplacer
# 列出显示器配置
displayplacer list
# 设置分辨率
displayplacer "id:<DISPLAY_ID> res:1920x1080 scaling:on origin:(0,0) degree:0"
# 设置 HiDPI 模式
displayplacer "id:<DISPLAY_ID> res:1920x1080 scaling:off origin:(0,0) degree:0"夜览模式
bash
# 开启夜览模式
# 系统设置 → 显示器 → 夜览
# 使用命令行(需要 blueutil)
brew install blueutil
# 查看夜览状态
# 通过 AppleScript
osascript -e 'tell application "System Events" to tell process "System Settings" to click menu item "Night Shift" of menu "Window"'
# 设置色温(需要第三方工具)
# 推荐使用 f.lux 或 NightOwl
brew install --cask flux声音设置
音量控制
bash
# 设置音量(0-100)
osascript -e "set volume output volume 50"
# 静音
osascript -e "set volume output muted true"
# 取消静音
osascript -e "set volume output muted false"
# 获取当前音量
osascript -e "output volume of (get volume settings)"
# 使用 SwitchAudioSource 管理音频设备
brew install switchaudio-osx
# 列出音频设备
SwitchAudioSource -a
# 切换输出设备
SwitchAudioSource -s "设备名称" -t output
# 切换输入设备
SwitchAudioSource -s "设备名称" -t input声音效果
bash
# 设置提示音
defaults write com.apple.systemsound com.apple.sound.beep.sound -string "/System/Library/Sounds/Glass.aiff"
# 设置提示音音量
defaults write NSGlobalDomain com.apple.sound.beep.volume -float 0.5
# 启用界面声音效果
defaults write NSGlobalDomain com.apple.sound.uiaudio.enabled -int 1
# 启动音效(Intel Mac)
sudo nvram StartupMute=%00 # 启用
sudo nvram StartupMute=%01 # 禁用键盘设置
键盘快捷键
bash
# 查看快捷键设置
defaults read com.apple.symbolichotkeys AppleSymbolicHotKeys
# 设置键盘重复速度
defaults write NSGlobalDomain KeyRepeat -int 2
# 设置重复前延迟
defaults write NSGlobalDomain InitialKeyRepeat -int 15
# 启用功能键
defaults write com.apple.keyboard FnState -bool true
# 重启设置服务
killall SystemUIServer输入法设置
bash
# 查看输入法列表
defaults read com.apple.HIToolbox AppleEnabledInputSources
# 切换输入法快捷键
# 系统设置 → 键盘 → 输入法
# 使用 im-select 工具
brew install im-select
# 查看当前输入法
im-select
# 切换输入法
im-select com.apple.keylayout.ABC触控板和鼠标
触控板设置
bash
# 启用轻点来点按
defaults write com.apple.AppleMultitouchTrackpad Clicking -bool true
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true
# 启用三指拖移
defaults write com.apple.AppleMultitouchTrackpad TrackpadThreeFingerDrag -bool true
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadThreeFingerDrag -bool true
# 设置滚动方向(自然/传统)
# 自然滚动
defaults write NSGlobalDomain com.apple.swipescrolldirection -bool true
# 传统滚动
defaults write NSGlobalDomain com.apple.swipescrolldirection -bool false
# 设置触控板速度
defaults write NSGlobalDomain com.apple.trackpad.scaling -float 1.5
# 重启相关服务
killall Dock鼠标设置
bash
# 设置鼠标速度
defaults write NSGlobalDomain com.apple.mouse.scaling -float 3.0
# 设置滚动速度
defaults write NSGlobalDomain com.apple.scrollwheel.scaling -float 1.0
# 启用辅助点击
defaults write com.apple.driver.AppleBluetoothMultitouch.mouse MouseButtonMode -string "TwoButton"
# 重启设置
killall SystemUIServer电源管理
电池设置
bash
# 查看电池状态
pmset -g batt
# 查看电源设置
pmset -g
# 设置睡眠时间(分钟)
sudo pmset -a displaysleep 10
sudo pmset -a sleep 30
# 设置硬盘休眠
sudo pmset -a disksleep 10
# 禁止睡眠
sudo pmset -a disablesleep 1
# 恢复默认设置
sudo pmset -a restoresettings
# 查看电池健康度
system_profiler SPPowerDataType | grep "Cycle Count"
system_profiler SPPowerDataType | grep "Condition"节能设置
bash
# 查看当前电源配置
pmset -g custom
# 电池模式设置
sudo pmset -b sleep 15 # 电池模式下 15 分钟后睡眠
sudo pmset -b displaysleep 5 # 电池模式下 5 分钟后关闭显示器
# 电源适配器模式设置
sudo pmset -c sleep 60 # 接电源时 60 分钟后睡眠
sudo pmset -c displaysleep 15 # 接电源时 15 分钟后关闭显示器
# 启用 Power Nap
sudo pmset -a powernap 1
# 查看唤醒历史
pmset -g log | grep -e "Sleep.*due to" -e "Wake.*due to"用户与群组
用户管理
bash
# 查看用户列表
dscl . list /Users | grep -v '^_'
# 查看用户信息
id 用户名
# 创建用户
sudo sysadminctl -addUser 新用户名 -password 密码 -fullName "用户全名"
# 删除用户
sudo sysadminctl -deleteUser 用户名
# 修改密码
sudo sysadminctl -resetPasswordFor 用户名 -newPassword 新密码
# 启用/禁用用户
sudo sysadminctl -secureTokenOn 用户名 -password 密码管理员权限
bash
# 查看管理员组
dscl . read /Groups/admin GroupMembership
# 添加用户到管理员组
sudo dscl . append /Groups/admin GroupMembership 用户名
# 从管理员组移除用户
sudo dscl . delete /Groups/admin GroupMembership 用户名
# 查看用户权限
dscl . read /Users/用户名 AuthenticationAuthority系统启动项
登录项管理
bash
# 查看登录项
osascript -e 'tell application "System Events" to get the name of every login item'
# 添加登录项
osascript -e 'tell application "System Events" to make login item at end with properties {path:"/Applications/AppName.app", hidden:false}'
# 删除登录项
osascript -e 'tell application "System Events" to delete login item "AppName"'
# 查看启动代理
launchctl list | grep -v com.apple
# 查看启动项文件
ls ~/Library/LaunchAgents/
ls /Library/LaunchAgents/
ls /Library/LaunchDaemons/LaunchAgent 配置
xml
<!-- 创建 LaunchAgent 配置文件 -->
<!-- 保存为 ~/Library/LaunchAgents/com.example.app.plist -->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.example.app</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/script.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
</dict>
</plist>bash
# 加载 LaunchAgent
launchctl load ~/Library/LaunchAgents/com.example.app.plist
# 卸载 LaunchAgent
launchctl unload ~/Library/LaunchAgents/com.example.app.plist
# 查看状态
launchctl list | grep com.example.app小结
本章介绍了 macOS 系统设置的主要内容:
- 系统设置概述:了解设置面板结构
- 通用设置:外观、语言、地区配置
- 桌面与程序坞:Dock 和桌面定制
- 显示器设置:分辨率、夜览模式
- 声音设置:音量和音频设备管理
- 键盘设置:快捷键和输入法
- 触控板和鼠标:手势和指针设置
- 电源管理:电池和节能设置
- 用户管理:账户和权限配置
- 启动项:登录项和 LaunchAgent
下一步
下一章我们将学习 网络配置,了解 macOS 网络设置方法。
