Linux port: first run, packaging, single instance, privacy and wiring
CI / test (push) Has been cancelled

First run and backend
- The companion opens without Ollama or a model (OFFLINE / SETUP REQUIRED),
  opens Settings > Language model and picks the model up once downloaded.
- Model, provider and GPU changes apply without restarting (Ollama is
  restarted when launch settings change); no silent fallback from API mode.
- Fatal startup errors are shown in a window; the fallback avatar loads
  again; the shipped Capri artwork is used when nothing was imported.

Packaging and tooling
- packaging/arch/PKGBUILD, capri.desktop (KWin ScreenShot2 key), icons,
  artwork under /usr/share/capri/assets, Gitea Actions CI.
- xtask: `icons` and `release-check` (no private data or credentials).

Runtime
- One instance per data folder (flock + control socket): second launch
  shows the window; capri stop / restart / toggle / status (JSON, starts
  nothing) / doctor / setup / diagnostics export / purge.
- A foreign program on the Ollama port is refused; an Ollama left behind
  by Capri is replaced.

Privacy and security
- No raw Ollama log on disk; API keys are never saved in plaintext (old
  ones move to the keyring); refused credential notes are stored as
  [Credentials omitted]; launched apps get an allow-listed environment.

Fixes
- Stop/Escape silence the voice; saved voice effects apply to replies;
  settings_control glitch settings apply; distinct KWin cursor scripts;
  KDE window capture authorized for source builds; Linux wording.
- Voice pack references zipped with Windows separators are found.

Wired features
- Initiatives, request router, resource monitor, "clip that", questions
  about a snapshot, sleep mode, tap reactions, stopwatch, attachments,
  Internet mode button, voice-synced subtitles, wake visuals, dictation
  draft, tray switches, Spotify seek/shuffle/repeat; computer-control
  planner and classifier follow model switches and API mode.
- Approval cards: one shown, 8 queued, deduplicated, cancelled on stop,
  failure, lock or pause; one Application access switch.

Desktop
- Compositor detection (no black overlay on i3 without picom), i3lock
  detection, unsupported desktops reported at startup, screenshot-only
  control without AT-SPI, fontconfig fallbacks, translatable feature
  pages with French translations.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
nocodeandClaude Opus 5.5 committed 2026-11-12 20:15:49 +01:00
1 parent a2abf01280
commit 844435f21f
73 files changed
+4834 -517

No files matched your search

+8 -1
View File
@@ -165,6 +165,12 @@ async fn fetch(client: &reqwest::Client, url: &reqwest::Url, total: u64, partial
Ok(())
}
/// Index of the member named `wanted` (`/`-separated). Archives made on Windows may store
/// `\` as the separator (the CapriCore voice pack has `references\neutral.wav`), so both match.
pub fn member_index<R: std::io::Read + std::io::Seek>(zip: &zip::ZipArchive<R>, wanted: &str) -> Option<usize> {
zip.index_for_name(wanted).or_else(|| (0..zip.len()).find(|&i| zip.name_for_index(i).and_then(Result::ok).is_some_and(|n| n.replace('\\', "/") == wanted)))
}
/// Extracts the named files found under `prefix` (the folder holding them inside the archive) into `dest`.
/// Names are relative paths; anything else in the archive is ignored. Each file is limited to `max_bytes`.
pub fn extract_named(archive: &Path, prefix: &str, names: &[String], dest: &Path, max_bytes: u64) -> Result<()> {
@@ -172,7 +178,8 @@ pub fn extract_named(archive: &Path, prefix: &str, names: &[String], dest: &Path
for name in names {
ensure!(!name.split('/').any(|p| p.is_empty() || p == ".." || p == "."), "Invalid archive member {name}");
let full = if prefix.is_empty() { name.clone() } else { format!("{prefix}/{name}") };
let mut entry = zip.by_name(&full).with_context(|| format!("Archive is missing {name}"))?;
let index = member_index(&zip, &full).with_context(|| format!("Archive is missing {name}"))?;
let mut entry = zip.by_index(index)?;
ensure!(entry.is_file() && entry.size() <= max_bytes, "Archive member {name} is too large");
let target = dest.join(name);
std::fs::create_dir_all(target.parent().unwrap())?;
+25 -1
View File
@@ -102,6 +102,9 @@ struct Inner {
devices: Mutex<Vec<InputDevice>>,
}
/// Turn ids of voice previews (they keep the effects being previewed).
const PREVIEW_PREFIX: &str = "preview:";
/// Cheap to clone; every method is non-blocking unless noted.
#[derive(Clone)]
pub struct VoiceHandle(Arc<Inner>);
@@ -339,9 +342,30 @@ impl VoiceHandle {
self.0.voice.lock().enabled
}
/// Language of the loaded voice, when Capri can speak (`None` when the voice is off).
pub fn spoken_language(&self) -> Option<String> {
let voice = self.0.voice.lock();
voice.enabled.then(|| voice.language.clone()).flatten()
}
/// Speaks a short fixed line (tap cue) like a preview: never stored in the history.
/// Ignored while something else is spoken.
pub fn speak_line(&self, text: &str) {
if self.speaking() || self.spoken_language().is_none() {
return;
}
let id = format!("cue:{}", uuid::Uuid::new_v4());
self.begin_turn(&id, false);
self.queue(&id, text, true);
}
/// `TurnEvent::Started`. `from_microphone`: the turn answers a [`VoiceEvent::Submit`] (enables follow-up listening).
pub fn begin_turn(&self, turn_id: &str, from_microphone: bool) {
self.stop_speaking();
// Replies use the saved effects (a preview configures its own just before).
if !turn_id.starts_with(PREVIEW_PREFIX) {
self.0.effects.lock().configure(&self.0.store.section::<VoiceEffects>());
}
let voice = self.0.voice.lock();
let speaking = voice.enabled && voice.language.is_some();
let language = voice.language.clone().unwrap_or_default();
@@ -430,7 +454,7 @@ impl VoiceHandle {
ensure!(!self.0.playback.busy(), "Wait for the current reply or preview to finish.");
let saved = self.0.store.section::<VoiceEffects>();
self.0.effects.lock().configure(&effects.unwrap_or(saved));
let id = format!("preview:{}", uuid::Uuid::new_v4());
let id = format!("{PREVIEW_PREFIX}{}", uuid::Uuid::new_v4());
self.begin_turn(&id, false);
self.queue(&id, preview_text(&language), true);
Ok(())
+28 -3
View File
@@ -125,16 +125,19 @@ pub fn installed(speech: &Path, language: &str, quality: &str) -> bool {
pub fn extract_reference(pack: &Path, target: &Path) -> Result<()> {
use std::io::Read;
let mut zip = zip::ZipArchive::new(std::fs::File::open(pack)?)?;
let profile_name = zip.file_names().find_map(|n| n.ok().filter(|n| n.ends_with("voice-profile.json")).map(|n| n.to_string())).context("The Capri voice pack has no profile")?;
// Names are compared with `/` separators: the v1.0.4 pack was zipped on Windows (`references\neutral.wav`).
let profile_name = zip.file_names().find_map(|n| n.ok().map(|n| n.replace('\\', "/")).filter(|n| n.ends_with("voice-profile.json"))).context("The Capri voice pack has no profile")?;
let prefix = profile_name.trim_end_matches("voice-profile.json").to_string();
let mut profile = String::new();
zip.by_name(&profile_name)?.take(64 << 10).read_to_string(&mut profile)?;
let index = crate::download::member_index(&zip, &profile_name).context("The Capri voice pack has no profile")?;
zip.by_index(index)?.take(64 << 10).read_to_string(&mut profile)?;
let profile: serde_json::Value = serde_json::from_str(&profile)?;
let reference = &profile["references"]["neutral"];
let (file, sha) = (reference["file"].as_str().context("No neutral reference")?, reference["sha256"].as_str().context("No reference checksum")?);
ensure!(file.starts_with("references/") && file.ends_with(".wav") && !file.contains(".."), "Invalid reference name");
let mut wav = Vec::new();
zip.by_name(&format!("{prefix}{file}"))?.take(50 << 20).read_to_end(&mut wav)?;
let index = crate::download::member_index(&zip, &format!("{prefix}{file}")).with_context(|| format!("The Capri voice pack is missing {file}"))?;
zip.by_index(index)?.take(50 << 20).read_to_end(&mut wav)?;
ensure!(hex::encode(<sha2::Sha256 as sha2::Digest>::digest(&wav)) == sha, "Voice pack checksum mismatch");
std::fs::create_dir_all(target.parent().unwrap())?;
capri_core::fsutil::write_atomic(target, &wav)
@@ -453,6 +456,28 @@ mod tests {
let target = dir.path().join("voices/capri-neutral.wav");
extract_reference(&pack, &target).unwrap();
assert_eq!(std::fs::read(&target).unwrap(), wav);
// The published v1.0.4 pack was zipped on Windows: `\` separators, profile at the root.
let windows = dir.path().join("windows.zip");
let mut zip = zip::ZipWriter::new(std::fs::File::create(&windows).unwrap());
zip.start_file("voice-profile.json", zip::write::SimpleFileOptions::default()).unwrap();
zip.write_all(profile.to_string().as_bytes()).unwrap();
zip.start_file("references\\neutral.wav", zip::write::SimpleFileOptions::default()).unwrap();
zip.write_all(&wav).unwrap();
zip.finish().unwrap();
let target = dir.path().join("voices/from-windows.wav");
extract_reference(&windows, &target).unwrap();
assert_eq!(std::fs::read(&target).unwrap(), wav);
}
/// Against the published pack: `CAPRI_VOICE_PACK=…/capri-en-v1.zip cargo test -- --ignored`.
#[test]
#[ignore = "needs the downloaded CapriCore v1.0.4 voice pack"]
fn published_voice_pack_reference() {
let pack = std::path::PathBuf::from(std::env::var_os("CAPRI_VOICE_PACK").expect("CAPRI_VOICE_PACK"));
let dir = tempfile::tempdir().unwrap();
let target = dir.path().join("capri-neutral.wav");
extract_reference(&pack, &target).unwrap();
assert!(load_wav(&target).unwrap().len() > 24_000, "at least one second of voice");
}
#[test]
+53 -52
View File
@@ -4,6 +4,7 @@ use capri_core::{Section, SettingsStore};
use crate::install::Phase;
use crate::settings::{CallSettings, MusicSettings, SPEECH_LANGUAGES, SpeechSettings, VoiceEffects, VoiceSettings};
use crate::{VoiceHandle, effects};
use capri_core::i18n::t;
// TODO: saves on every slider step; debounce if disk writes start to matter.
/// Saves a section when the page changed it.
@@ -47,12 +48,12 @@ pub fn settings_ui(ui: &mut egui::Ui, store: &SettingsStore, voice: &VoiceHandle
ui.colored_label(ui.visuals().error_fg_color, error);
}
install_status(ui, voice);
egui::CollapsingHeader::new("Speech").default_open(true).show(ui, |ui| speech(ui, store, voice));
egui::CollapsingHeader::new("Microphone").default_open(true).show(ui, |ui| microphone(ui, store, voice));
egui::CollapsingHeader::new("Voice model").show(ui, |ui| voice_model(ui, store, voice));
egui::CollapsingHeader::new("Voice effects").show(ui, |ui| voice_effects(ui, store, voice));
egui::CollapsingHeader::new("Music listening").show(ui, |ui| music(ui, store, voice));
egui::CollapsingHeader::new("Call audio").show(ui, |ui| call(ui, store, voice));
egui::CollapsingHeader::new(t("Speech")).default_open(true).show(ui, |ui| speech(ui, store, voice));
egui::CollapsingHeader::new(t("Microphone")).default_open(true).show(ui, |ui| microphone(ui, store, voice));
egui::CollapsingHeader::new(t("Voice model")).show(ui, |ui| voice_model(ui, store, voice));
egui::CollapsingHeader::new(t("Voice effects")).show(ui, |ui| voice_effects(ui, store, voice));
egui::CollapsingHeader::new(t("Music listening")).show(ui, |ui| music(ui, store, voice));
egui::CollapsingHeader::new(t("Call audio")).show(ui, |ui| call(ui, store, voice));
}
fn install_status(ui: &mut egui::Ui, voice: &VoiceHandle) {
@@ -61,7 +62,7 @@ fn install_status(ui: &mut egui::Ui, voice: &VoiceHandle) {
Phase::Installing => {
ui.horizontal(|ui| {
ui.label(format!("Installing: {} {}", status.stage, status.detail));
if ui.button("Cancel").clicked() {
if ui.button(t("Cancel")).clicked() {
voice.cancel_install();
}
});
@@ -71,7 +72,7 @@ fn install_status(ui: &mut egui::Ui, voice: &VoiceHandle) {
ui.colored_label(ui.visuals().warn_fg_color, status.error.unwrap_or_default());
}
Phase::Ready => {
ui.label("Speech components are installed.");
ui.label(t("Speech components are installed."));
}
Phase::Idle => {}
}
@@ -80,42 +81,42 @@ fn install_status(ui: &mut egui::Ui, voice: &VoiceHandle) {
fn speech(ui: &mut egui::Ui, store: &SettingsStore, voice: &VoiceHandle) {
edit::<SpeechSettings>(store, ui, |ui, s| {
language_combo(ui, "Recognition language", &mut s.recognition_language, &["follow", "auto"], SPEECH_LANGUAGES);
egui::ComboBox::from_label("Recognition model").selected_text(s.asr_model.as_str()).show_ui(ui, |ui| {
egui::ComboBox::from_label(t("Recognition model")).selected_text(s.asr_model.as_str()).show_ui(ui, |ui| {
for (id, label, ..) in crate::asr::MODELS {
ui.selectable_value(&mut s.asr_model, id.to_string(), *label);
}
});
ui.add(egui::Slider::new(&mut s.trailing_silence_seconds, 0.5..=5.0).step_by(0.1).suffix(" s").text("End-of-speech pause"));
if ui.button("Reset pause").clicked() {
ui.add(egui::Slider::new(&mut s.trailing_silence_seconds, 0.5..=5.0).step_by(0.1).suffix(" s").text(t("End-of-speech pause")));
if ui.button(t("Reset pause")).clicked() {
s.trailing_silence_seconds = 1.0;
}
ui.checkbox(&mut s.wake_word, "Wake phrase: Capri / Hey, Capri");
ui.checkbox(&mut s.auto_send, "Send recognized speech automatically");
ui.checkbox(&mut s.barge_in, "Interrupt Capri by speaking");
ui.checkbox(&mut s.follow_up, "Keep listening after Capri asks a question");
ui.add_enabled(s.follow_up, egui::Slider::new(&mut s.follow_up_seconds, 5..=30).suffix(" s").text("Follow-up window"));
egui::ComboBox::from_label("Wake sound").selected_text(s.wake_sound.as_str()).show_ui(ui, |ui| {
ui.checkbox(&mut s.wake_word, t("Wake phrase: Capri / Hey, Capri"));
ui.checkbox(&mut s.auto_send, t("Send recognized speech automatically"));
ui.checkbox(&mut s.barge_in, t("Interrupt Capri by speaking"));
ui.checkbox(&mut s.follow_up, t("Keep listening after Capri asks a question"));
ui.add_enabled(s.follow_up, egui::Slider::new(&mut s.follow_up_seconds, 5..=30).suffix(" s").text(t("Follow-up window")));
egui::ComboBox::from_label(t("Wake sound")).selected_text(s.wake_sound.as_str()).show_ui(ui, |ui| {
ui.selectable_value(&mut s.wake_sound, "tone".to_string(), "Tone");
ui.selectable_value(&mut s.wake_sound, "off".to_string(), "Off");
});
ui.add(egui::Slider::new(&mut s.wake_volume, 0.0..=1.0).text("Wake volume"));
ui.checkbox(&mut s.asr_gpu, "Use the GPU for recognition (needs a CUDA build)");
ui.add(egui::Slider::new(&mut s.cpu_threads, 1..=8).text("CPU threads"));
ui.add(egui::Slider::new(&mut s.wake_volume, 0.0..=1.0).text(t("Wake volume")));
ui.checkbox(&mut s.asr_gpu, t("Use the GPU for recognition (needs a CUDA build)"));
ui.add(egui::Slider::new(&mut s.cpu_threads, 1..=8).text(t("CPU threads")));
});
let installed = voice.recognition_installed();
ui.label(if installed { "Recognition model installed." } else { "Recognition model not installed." });
if !installed && ui.button("Install speech recognition").clicked() {
if !installed && ui.button(t("Install speech recognition")).clicked() {
report(ui, voice.install_speech(true, false));
}
}
fn microphone(ui: &mut egui::Ui, store: &SettingsStore, voice: &VoiceHandle) {
let mut on = voice.microphone_on();
if ui.checkbox(&mut on, "Microphone (off at every launch)").changed() {
if ui.checkbox(&mut on, t("Microphone (off at every launch)")).changed() {
report(ui, voice.set_microphone(on));
}
ui.add(egui::ProgressBar::new(voice.microphone_level()).desired_width(160.0).text("Level"));
if ui.button("Refresh devices").clicked() {
ui.add(egui::ProgressBar::new(voice.microphone_level()).desired_width(160.0).text(t("Level")));
if ui.button(t("Refresh devices")).clicked() {
voice.refresh_devices();
}
let devices = voice.input_devices();
@@ -127,8 +128,8 @@ fn microphone(ui: &mut egui::Ui, store: &SettingsStore, voice: &VoiceHandle) {
} else {
format!("Unavailable — {}", s.microphone_label)
};
egui::ComboBox::from_label("Input device").selected_text(selected).show_ui(ui, |ui| {
if ui.selectable_label(s.microphone_device.is_empty(), "System default").clicked() {
egui::ComboBox::from_label(t("Input device")).selected_text(selected).show_ui(ui, |ui| {
if ui.selectable_label(s.microphone_device.is_empty(), t("System default")).clicked() {
(s.microphone_device, s.microphone_label) = (String::new(), String::new());
}
for d in &devices {
@@ -138,35 +139,35 @@ fn microphone(ui: &mut egui::Ui, store: &SettingsStore, voice: &VoiceHandle) {
}
});
});
ui.label("Changing the device or pause applies the next time the microphone starts.");
ui.label(t("Changing the device or pause applies the next time the microphone starts."));
}
fn voice_model(ui: &mut egui::Ui, store: &SettingsStore, voice: &VoiceHandle) {
let mut on = voice.voice_enabled();
if ui.checkbox(&mut on, "Speak replies (off at every launch)").changed() {
if ui.checkbox(&mut on, t("Speak replies (off at every launch)")).changed() {
report(ui, voice.set_voice_enabled(on));
}
edit::<VoiceSettings>(store, ui, |ui, v| {
language_combo(ui, "Voice language", &mut v.speech_language, &["follow"], SPEECH_LANGUAGES);
egui::ComboBox::from_label("Quality").selected_text(v.quality.as_str()).show_ui(ui, |ui| {
egui::ComboBox::from_label(t("Quality")).selected_text(v.quality.as_str()).show_ui(ui, |ui| {
ui.selectable_value(&mut v.quality, "balanced".to_string(), "Balanced (quantized, ~1.2 GB)");
ui.selectable_value(&mut v.quality, "full".to_string(), "Full (float32, ~3.3 GB)");
});
ui.add(egui::Slider::new(&mut v.cpu_threads, 1..=16).text("CPU threads"));
ui.add(egui::Slider::new(&mut v.cpu_threads, 1..=16).text(t("CPU threads")));
});
ui.label("English: Chatterbox Turbo. Other languages: Chatterbox Multilingual. Both use Capri's reference voice.");
ui.label(t("English: Chatterbox Turbo. Other languages: Chatterbox Multilingual. Both use Capri's reference voice."));
if voice.voice_installed() {
ui.label("Voice installed for this language.");
} else if ui.button("Install Capri's voice for this language").clicked() {
ui.label(t("Voice installed for this language."));
} else if ui.button(t("Install Capri's voice for this language")).clicked() {
report(ui, voice.install_speech(false, true));
}
}
fn voice_effects(ui: &mut egui::Ui, store: &SettingsStore, voice: &VoiceHandle) {
edit::<VoiceEffects>(store, ui, |ui, e| {
ui.checkbox(&mut e.enabled, "Effects");
ui.checkbox(&mut e.enabled, t("Effects"));
let mut preset = e.preset.clone();
egui::ComboBox::from_label("Preset").selected_text(preset.as_str()).show_ui(ui, |ui| {
egui::ComboBox::from_label(t("Preset")).selected_text(preset.as_str()).show_ui(ui, |ui| {
for p in effects::PRESETS.iter().chain(&["custom"]) {
ui.selectable_value(&mut preset, p.to_string(), *p);
}
@@ -188,15 +189,15 @@ fn voice_effects(ui: &mut egui::Ui, store: &SettingsStore, voice: &VoiceHandle)
] {
ui.add(egui::Slider::new(value, 0..=max).text(label));
}
ui.add(egui::Slider::new(&mut e.carrier_hz, 20..=200).suffix(" Hz").text("Carrier"));
ui.add(egui::Slider::new(&mut e.carrier_hz, 20..=200).suffix(" Hz").text(t("Carrier")));
if *e != before {
e.preset = "custom".into();
}
if ui.button("Reset").clicked() {
if ui.button(t("Reset")).clicked() {
*e = VoiceEffects::default();
}
});
if ui.button("Preview voice").clicked() {
if ui.button(t("Preview voice")).clicked() {
report(ui, voice.preview_voice(None));
}
}
@@ -216,40 +217,40 @@ fn music(ui: &mut egui::Ui, store: &SettingsStore, voice: &VoiceHandle) {
};
ui.label(label);
if state.listening {
if ui.button("Stop music listening").clicked() {
if ui.button(t("Stop music listening")).clicked() {
voice.set_music(false);
}
} else if ui.button("Start music listening").clicked() {
} else if ui.button(t("Start music listening")).clicked() {
voice.set_music(true);
}
edit::<MusicSettings>(store, ui, |ui, m| {
if ui.checkbox(&mut m.enabled, "Music animations").changed() && m.enabled && !state.listening {
if ui.checkbox(&mut m.enabled, t("Music animations")).changed() && m.enabled && !state.listening {
voice.set_music(true);
}
ui.checkbox(&mut m.notes, "Floating notes");
ui.checkbox(&mut m.motion, "Beat motion");
ui.checkbox(&mut m.auto_bpm, "Follow the detected tempo (off: 110 BPM)");
ui.checkbox(&mut m.notes, t("Floating notes"));
ui.checkbox(&mut m.motion, t("Beat motion"));
ui.checkbox(&mut m.auto_bpm, t("Follow the detected tempo (off: 110 BPM)"));
});
ui.label("System playback is analysed in memory only; nothing is recorded or sent.");
ui.label(t("System playback is analysed in memory only; nothing is recorded or sent."));
}
fn call(ui: &mut egui::Ui, store: &SettingsStore, voice: &VoiceHandle) {
if voice.call_active() {
ui.label("Virtual cable active: choose \"Capri-call-microphone\" as the microphone in your call app.");
ui.label(t("Virtual cable active: choose \"Capri-call-microphone\" as the microphone in your call app."));
let mut share = voice.share_replies();
if ui.checkbox(&mut share, "Share Capri's replies in the call").changed() {
if ui.checkbox(&mut share, t("Share Capri's replies in the call")).changed() {
voice.set_share_replies(share);
}
if ui.button("Remove the virtual cable").clicked() {
if ui.button(t("Remove the virtual cable")).clicked() {
voice.remove_call_cable();
}
} else if ui.button("Create the virtual call cable").clicked() {
} else if ui.button(t("Create the virtual call cable")).clicked() {
report(ui, voice.create_call_cable());
}
edit::<CallSettings>(store, ui, |ui, c| {
ui.checkbox(&mut c.mix_microphone, "Mix my microphone into the call");
ui.checkbox(&mut c.allow_model, "Allow model-selected replies in calls");
ui.add(egui::Slider::new(&mut c.call_voice_volume, 0..=100).text("Capri's level in the call"));
ui.checkbox(&mut c.mix_microphone, t("Mix my microphone into the call"));
ui.checkbox(&mut c.allow_model, t("Allow model-selected replies in calls"));
ui.add(egui::Slider::new(&mut c.call_voice_volume, 0..=100).text(t("Capri's level in the call")));
});
}