Skip to content

Commit 9aa4da6

Browse files
committed
fixed a if-fi and sounddevice bug in the script
1 parent 18341e4 commit 9aa4da6

File tree

1 file changed

+30
-21
lines changed

1 file changed

+30
-21
lines changed

packaging/postinstall.sh

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -37,26 +37,6 @@ fi
3737

3838
echo "voxd installed. Each user should run: voxd --setup"
3939

40-
# Audio tip: suggest Pulse/ALSA plugins if 'pulse' input is missing
41-
if command -v python >/dev/null 2>&1; then
42-
if ! python - <<'PY' 2>/dev/null; then
43-
exit 0
44-
fi
45-
import sys
46-
try:
47-
import sounddevice as sd # type: ignore
48-
names = [str(d.get('name','')).lower() for d in sd.query_devices()]
49-
has_pulse = any('pulse' in n for n in names)
50-
if not has_pulse:
51-
print('[voxd] Tip: No "pulse" device detected. Install your distro\'s pulse shim and ALSA plugins:')
52-
print(' - Debian/Ubuntu: sudo apt install alsa-plugins pavucontrol (ensure pulseaudio or pipewire-pulse active)')
53-
print(' - Fedora/openSUSE: sudo dnf install alsa-plugins-pulseaudio pavucontrol (ensure pipewire-pulseaudio active)')
54-
print(' - Arch: sudo pacman -S alsa-plugins pipewire-pulse pavucontrol')
55-
except Exception:
56-
pass
57-
PY
58-
fi
59-
6040
# Create a local virtualenv to ensure missing Python deps (e.g., sounddevice) are available
6141
# We inherit system site-packages to avoid duplicating distro Python libs
6242
APPDIR="/opt/voxd"
@@ -100,7 +80,7 @@ if [ -n "$PY" ]; then
10080
# Upgrade pip quietly; then install minimal extras that may be missing from repos
10181
"$VPY" -m pip install --upgrade --disable-pip-version-check pip >/dev/null 2>&1 || true
10282
# Ensure core runtime dependencies inside app venv (covers Leap mismatches)
103-
"$VPY" -m pip install --disable-pip-version-check --no-input sounddevice>=0.5 psutil numpy requests pyyaml tqdm pyperclip >/dev/null 2>&1 || true
83+
"$VPY" -m pip install --disable-pip-version-check --no-input "sounddevice>=0.5" psutil numpy requests pyyaml tqdm pyperclip >/dev/null 2>&1 || true
10484
# Ensure platformdirs (imported by voxd.core.config); install only if missing
10585
"$VPY" - <<'PY' 2>/dev/null || "$VPY" -m pip install --disable-pip-version-check --no-input platformdirs >/dev/null 2>&1 || true
10686
try:
@@ -132,4 +112,33 @@ PY
132112
fi
133113
fi
134114

115+
# Audio tip: suggest Pulse/ALSA plugins if 'pulse' input is missing
116+
# Prefer venv Python if available; else fall back to a system Python
117+
AUDIO_PY=""
118+
if [ -x "$APPDIR/.venv/bin/python" ]; then
119+
AUDIO_PY="$APPDIR/.venv/bin/python"
120+
elif [ -n "${PY:-}" ]; then
121+
AUDIO_PY="$PY"
122+
elif command -v python3 >/dev/null 2>&1; then
123+
AUDIO_PY="python3"
124+
elif command -v python >/dev/null 2>&1; then
125+
AUDIO_PY="python"
126+
fi
127+
if [ -n "$AUDIO_PY" ]; then
128+
"$AUDIO_PY" - <<'PY' 2>/dev/null || true
129+
import sys
130+
try:
131+
import sounddevice as sd # type: ignore
132+
names = [str(d.get('name','')).lower() for d in sd.query_devices()]
133+
has_pulse = any('pulse' in n for n in names)
134+
if not has_pulse:
135+
print('[voxd] Tip: No "pulse" device detected. Install your distro\'s pulse shim and ALSA plugins:')
136+
print(' - Debian/Ubuntu: sudo apt install alsa-plugins pavucontrol (ensure pulseaudio or pipewire-pulse active)')
137+
print(' - Fedora/openSUSE: sudo dnf install alsa-plugins-pulseaudio pavucontrol (ensure pipewire-pulseaudio active)')
138+
print(' - Arch: sudo pacman -S alsa-plugins pipewire-pulse pavucontrol')
139+
except Exception:
140+
pass
141+
PY
142+
fi
143+
135144

0 commit comments

Comments
 (0)