Files
dotemacs/config-linux.el
T
Willem van den Ende 0b267d04c5 fix(linux): port startup and dictation fixes from the private working copy
Fixes that only existed on the Linux machine (unpushed commit and
uncommitted work there), without which a fresh clone breaks on Linux:

- config.el resolved coe-xx/mostalive/qwan against ~/.doom.d, but the
  config lives at ~/.config/doom, so (require 'coe-xx) aborted startup
  with "Cannot open load file". Resolve them against doom-user-dir.

- lisp/live-dictate.el only spoke whisper.cpp's POST /inference, which
  Lemonade (the Linux transcription server) does not serve -- every
  utterance came back as a not_found object and was dropped silently.
  It now auto-detects between /inference and the OpenAI-compatible
  /v1/audio/transcriptions endpoint, remembers which one answered,
  reports unusable replies, reads the VAD peak from the high byte of
  little-endian PCM16 (the low byte made silence look like speech),
  prints the peak level on stop, and gains M-x live-dictate-reload,
  wired into doom-after-reload-hook on both OSes.

- config.el hardcoded the macOS org-directory (~/MyDocuments, inside
  iCloud). Where the notes live is now owned by config-linux.el
  (~/Documents) and config-mac.el (~/MyDocuments), and the OS leaf
  loads before org and org-roam load below instead of after them.
  Blog export targets stay in the OS files, where they belong.

- mostalive/my-org-roam.el: compute org-agenda-files by listing the
  daily/ directory instead of org-roam-db-query at load time, and
  defer the full org-roam DB sync to idle time. Doom advises the first
  DB query of a session into a full org-roam-db-sync, which SHA1s all
  ~8.4k notes before the first frame is drawn (blank-screen startup).

Also correct the ~/.doom.d paths in AGENTS.md, the export-test header
and README that the sanitization base predated the fix for.
2026-11-27 17:57:37 +01:00

106 lines
5.3 KiB
EmacsLisp

;;; config-linux.el --- Linux-specific configuration -*- lexical-binding: t; -*-
;; Loaded from config.el on GNU/Linux machines only; config-mac.el is the
;; macOS counterpart. Anything with a Linux path, a Linux binary, or a
;; backend that only exists on this box belongs here rather than in the
;; shared config.el.
;;
;; Machine-specific settings that should not be committed at all (API keys,
;; checkouts in unusual places) belong in config-local.el, which is
;; gitignored -- see config-local.example.el.
;;; Where the notes live
;;
;; Owned per machine (config.el loads this file before org and org-roam, so
;; these are in place in time). Linux keeps them on the local disk, next to
;; everything else under ~/Documents; ~/MyDocuments on the mac is inside
;; iCloud, which is not where these notes belong. Override in
;; config-local.el if a checkout moves.
(setq org-directory "~/Documents/qwan/essays/willem"
org-default-notes-file (expand-file-name "notes.org" org-directory)
org-roam-directory org-directory)
;; Elixir language server. The shared config.el deliberately does not
;; configure this: a single value cannot be right on both machines, and
;; pointing eglot at a binary that may not exist is worse than leaving it at
;; Emacs' default. So each OS file owns it. Here: prefer `expert' if it is
;; installed, else any elixir-ls on PATH, else leave eglot alone rather than
;; configuring a server that cannot start.
(with-eval-after-load 'eglot
(let ((server (cond ((executable-find "expert")
'("expert" "--stdio"))
((executable-find "language_server.sh")
(list (or (executable-find "bash") "sh")
(executable-find "language_server.sh"))))))
(when server
(setf (alist-get '(elixir-mode elixir-ts-mode heex-ts-mode)
eglot-server-programs
nil nil #'equal)
server))))
;; Blog export destinations. Upstream keeps these in the shared config.el as
;; ~/MyDocuments/..., which does not exist on this machine; here the jekyll
;; checkout lives under ~/Documents/.... Both are home-relative, so if a
;; checkout ever moves, override it in config-local.el.
(setq org-roam-export-blog-firehose-root "~/dev/elixir/firehose"
org-roam-export-jekyll-root "~/Documents/qwan/sites/qwaneu.github.io")
;;; Speech-to-text (whisper.el + streaming dictation)
;;
;; Linux only for now: this needs whisper.el installed, a Lemonade server
;; listening on :13305, and an ffmpeg that can capture from PulseAudio. On
;; macOS none of that is set up yet, so the whole block lives here rather
;; than in the shared config.el. Porting it is a feature, not a move: pick
;; an audio input (see `live-dictate-ffmpeg-input-format'/`-device'), install
;; `whisper' via packages.el, and point `live-dictate-server-url' at a
;; reachable backend.
;;
;; `whisper' and `websocket' (for live-dictate) are declared in packages.el,
;; so these autoloads exist on a fresh install.
(add-load-path! "lisp")
(autoload #'live-dictate "live-dictate" nil t)
(autoload #'live-dictate-reload "live-dictate" nil t)
(use-package! whisper
:commands (whisper-run whisper-file whisper-select-language)
:init
(map! :leader
(:prefix ("A" . "+ai")
:desc "Whisper record/transcribe" "w" #'whisper-run
:desc "Whisper transcribe file" "W" #'whisper-file
:desc "Whisper select language" "l" #'whisper-select-language
:desc "Live dictate (streaming)" "d" #'live-dictate))
:config
(setopt whisper-install-whispercpp nil ; no whisper.cpp needed, remote API only
whisper-server-mode 'openai ; use OpenAI-compatible transcription API
whisper-openai-api-baseurl "http://localhost:13305/"
whisper-openai-api-key "not-needed" ; Lemonade ignores auth, but whisper.el requires a non-nil key
whisper-openai-model "Whisper-Large-v3-Turbo"
whisper-language "en"
whisper-translate nil ; t would POST to /translations instead
whisper-return-cursor 'end))
;; live-dictate talks to the same Lemonade server. Lemonade only serves the
;; OpenAI-compatible endpoint (/v1/audio/transcriptions), not whisper.cpp's
;; /inference, and it rejects requests that do not name a model it has
;; loaded -- so point it at the whisper model Lemonade actually serves. If
;; the endpoint ever disappears, live-dictate falls back to /inference and
;; says so instead of silently dropping the transcript.
(with-eval-after-load 'live-dictate
(setopt live-dictate-server-url "http://localhost:13305"
live-dictate-openai-model "Whisper-Large-v3-Turbo"
live-dictate-debug nil))
;; `require' keeps the first copy of a library it reads, so edits to
;; lisp/live-dictate.el are invisible until Emacs restarts -- `doom/reload'
;; reloads config.el but not the library. Drop and re-read it afterwards;
;; the `with-eval-after-load' settings above then run again. By hand:
;; `M-x live-dictate-reload'.
(add-hook 'doom-after-reload-hook
(defun live-dictate--reload-after-doom-reload ()
"Re-read lisp/live-dictate.el if it has been loaded."
(when (featurep 'live-dictate)
(live-dictate-reload))))
;;; config-linux.el ends here