配置指南
altgo 使用 TOML 格式的配置文件,所有字段都有默认值,只需修改你需要的部分。
配置文件位置
~/.config/altgo/altgo.toml
转写引擎配置
本地 whisper.cpp(推荐,无需 API 密钥)
[transcriber]
engine = "local"
model = "~/models/ggml-base.bin"
whisper_path = ""
language = "zh"
云端 Whisper API
[transcriber]
engine = "api"
api_key = "sk-your-key"
api_base_url = "https://api.openai.com"
model = "whisper-1"
language = "zh"
也可以通过环境变量设置密钥:
export ALTGO_TRANSCRIBER_API_KEY="sk-your-key"
润色配置
altgo 支持通过 LLM 对转写文本进行润色。
润色级别
| 级别 | 效果 | 需要 API 密钥 |
|---|---|---|
none | 不润色,直接输出转写文本 | 否 |
light | 修正标点和错别字 | 是 |
medium | 修正语法、改善语序通顺度 | 是 |
heavy | 结构化重写,适合正式文档 | 是 |
配置示例
[polisher]
level = "medium"
protocol = "openai"
api_key = "sk-your-key"
api_base_url = "https://..."
model = "your-model"
支持的 Provider
OpenAI
[polisher]
protocol = "openai"
api_key = "sk-your-key"
api_base_url = "https://api.openai.com"
model = "gpt-3.5-turbo"
DeepSeek
[polisher]
protocol = "openai"
api_key = "sk-your-key"
api_base_url = "https://api.deepseek.com"
model = "deepseek-chat"
Anthropic
[polisher]
protocol = "anthropic"
api_key = "sk-ant-your-key"
api_base_url = "https://api.anthropic.com"
model = "claude-sonnet-4-20250514"
本地 Ollama
[polisher]
protocol = "openai"
api_key = "ollama"
api_base_url = "http://localhost:11434"
model = "qwen2.5:7b"
环境变量覆盖密钥:
export ALTGO_POLISHER_API_KEY="sk-your-key"
按键配置
与 configs/altgo.toml 一致;默认触发键为 右 Alt 的 keysym 名 Alt_R。若在设置页使用「按下以设置」,会写入 linux_evdev_code 字段。
[key_listener]
key_name = "Alt_R" # 触发键(示例:右 Alt;左 Alt 可用 Alt_L)
long_press_threshold_ms = 200 # 长按判定阈值 (ms)
double_click_interval_ms = 300 # 双击判定间隔 (ms)
min_press_duration_ms = 100 # 最短按下时长,过滤 IME 抖动
录音配置
[recorder]
sample_rate = 16000 # 采样率
channels = 1 # 声道数
输出配置
[output]
enable_notify = true # 桌面通知
notify_timeout_ms = 5000
inject_at_cursor = true # 尝试注入到光标位置(预留字段)
prefer_polished = true # 剪贴板/注入优先使用润色成功且非空的文本
Linux 需要可用的 xclip、xsel 或 wl-copy 之一,否则自动写剪贴板会失败(仍可用悬浮窗或历史页复制)。
日志配置
[logging]
level = "info" # debug / info / warn / error
也可以通过环境变量:
RUST_LOG=altgo=debug altgo
优先级
环境变量 > 配置文件 > 代码默认值
| 环境变量 | 覆盖字段 |
|---|---|
ALTGO_TRANSCRIBER_API_KEY | transcriber.api_key |
ALTGO_POLISHER_API_KEY | polisher.api_key |
RUST_LOG | 日志级别 |