Skip to content

Commit 4284ea8

Browse files
committed
fix: closes #113
1 parent f6cdfec commit 4284ea8

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

bin/hyprwhspr

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,24 @@
66
SCRIPT_DIR="$(cd "$(dirname $(readlink -f "$0"))" && pwd)"
77
PACKAGE_ROOT="$(dirname "$SCRIPT_DIR")"
88

9+
# Determine the library directory
10+
# Development: lib/cli.py exists directly under PACKAGE_ROOT
11+
# Installed: lib/hyprwhspr/cli.py under PACKAGE_ROOT (e.g., ~/.local/lib/hyprwhspr/)
12+
if [ -f "$PACKAGE_ROOT/lib/cli.py" ]; then
13+
LIB_DIR="$PACKAGE_ROOT/lib"
14+
elif [ -f "$PACKAGE_ROOT/lib/hyprwhspr/cli.py" ]; then
15+
LIB_DIR="$PACKAGE_ROOT/lib/hyprwhspr"
16+
else
17+
echo "Error: Cannot find hyprwhspr library files." >&2
18+
echo "Searched in:" >&2
19+
echo " $PACKAGE_ROOT/lib/cli.py" >&2
20+
echo " $PACKAGE_ROOT/lib/hyprwhspr/cli.py" >&2
21+
exit 1
22+
fi
23+
924
# Set environment variables
1025
export HYPRWHSPR_ROOT="$PACKAGE_ROOT"
11-
export PYTHONPATH="$PACKAGE_ROOT/lib:$PYTHONPATH"
26+
export PYTHONPATH="$LIB_DIR:$PYTHONPATH"
1227

1328
# Find system Python, avoiding mise/pyenv/asdf/homebrew managed versions
1429
# CLI commands use system Python since deps are installed via package manager
@@ -50,21 +65,21 @@ fi
5065
# Help handling: route any -h/--help or leading "help" to CLI help
5166
for arg in "$@"; do
5267
if [[ "$arg" == "-h" || "$arg" == "--help" ]]; then
53-
exec "$CLI_PYTHON" "$PACKAGE_ROOT/lib/cli.py" --help
68+
exec "$CLI_PYTHON" "$LIB_DIR/cli.py" --help
5469
fi
5570
done
5671

5772
if [[ "$1" == "help" ]]; then
58-
exec "$CLI_PYTHON" "$PACKAGE_ROOT/lib/cli.py" --help
73+
exec "$CLI_PYTHON" "$LIB_DIR/cli.py" --help
5974
fi
6075

6176
# Subcommands: route to CLI if recognized
6277
# 'test' needs venv Python since it loads the transcription backend
6378
if [[ "$1" == "test" ]]; then
64-
exec "$PYTHON_CMD" "$PACKAGE_ROOT/lib/cli.py" "$@"
79+
exec "$PYTHON_CMD" "$LIB_DIR/cli.py" "$@"
6580
fi
6681
if [[ "$1" =~ ^(setup|install|config|waybar|systemd|status|model|validate|uninstall|backend|state|mic-osd|keyboard|record)$ ]]; then
67-
exec "$CLI_PYTHON" "$PACKAGE_ROOT/lib/cli.py" "$@"
82+
exec "$CLI_PYTHON" "$LIB_DIR/cli.py" "$@"
6883
fi
6984

7085
# Set up CUDA library path if CUDA is installed
@@ -90,4 +105,4 @@ if [ -d "/opt/rocm" ]; then
90105
fi
91106

92107
# Default: run main application with venv Python
93-
exec "$PYTHON_CMD" "$PACKAGE_ROOT/lib/main.py" "$@"
108+
exec "$PYTHON_CMD" "$LIB_DIR/main.py" "$@"

0 commit comments

Comments
 (0)