Only works if your username is "user": fixing hardcoded home paths
A voice-control tool hardcoded /home/user in its scripts and systemd unit, so it broke for every other account. $HOME and systemd's %h fixed it.
opencode-voice adds push-to-talk voice control for the OpenCode CLI on Hyprland/Wayland: hold a key, speak, release. It is a set of shell scripts, a Python transcription daemon and a systemd user service.
The symptom#
Reading the code, I noticed several scripts and the systemd unit pointed at /home/user/.... That only works if your login name is literally user. On any other account:
- the scripts put a directory that does not exist on
PATH, OPENCODE_BINpoints at a binary that is not there,- the systemd service cannot start, because its
ExecStartpath does not exist.
I reported it as issue #1. I found it by reading the code, not by running it on a second account, and the issue says so.
The fix#
Shell scripts get the home directory from $HOME, and systemd user units get it from the %h specifier.
# before
export PATH="/home/user/.opencode/bin:/home/user/.local/bin:/usr/bin:/bin"
OPENCODE_BIN="/home/user/.opencode/bin/opencode"
# after
export PATH="$HOME/.opencode/bin:$HOME/.local/bin:/usr/bin:/bin"
OPENCODE_BIN="${OC_VOICE_OPENCODE:-$HOME/.opencode/bin/opencode}"
# opencode-voice.service
# %h expands to the user's home; edit if the repo lives elsewhere.
ExecStart=%h/Projects/opencode-voice/voice-daemon.sh
OC_VOICE_OPENCODE is a new, optional override for people who installed OpenCode somewhere else. The default location is unchanged, and the README mentions the new variable.
Testing, honestly#
I was on Windows, so I could not run the project’s unit tests (they execute the shell scripts directly). What I did check:
bash -non every script andpython -m py_compileon the Python files.- A dry run as a pretend user:
HOME=/home/alice OC_VOICE_DRYRUN=1 bash voice-cmd.sh "open opencode and start working"resolves the binary to/home/alice/.opencode/bin/opencode, andOC_VOICE_OPENCODE=/opt/ocoverrides it. grep -rn /home/userover the repository finds nothing.
The pull request listed what was and was not tested, and the maintainer merged it the same day.