66SCRIPT_DIR=" $( cd " $( dirname $( readlink -f " $0 " ) ) " && pwd) "
77PACKAGE_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
1025export 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
5065# Help handling: route any -h/--help or leading "help" to CLI help
5166for 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
5570done
5671
5772if [[ " $1 " == " help" ]]; then
58- exec " $CLI_PYTHON " " $PACKAGE_ROOT /lib /cli.py" --help
73+ exec " $CLI_PYTHON " " $LIB_DIR /cli.py" --help
5974fi
6075
6176# Subcommands: route to CLI if recognized
6277# 'test' needs venv Python since it loads the transcription backend
6378if [[ " $1 " == " test" ]]; then
64- exec " $PYTHON_CMD " " $PACKAGE_ROOT /lib /cli.py" " $@ "
79+ exec " $PYTHON_CMD " " $LIB_DIR /cli.py" " $@ "
6580fi
6681if [[ " $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" " $@ "
6883fi
6984
7085# Set up CUDA library path if CUDA is installed
@@ -90,4 +105,4 @@ if [ -d "/opt/rocm" ]; then
90105fi
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