install: venv at ~/.local/lib/blitztext with --copies; source-independent after install

Moves the venv out of the source tree to ~/.local/lib/blitztext so it works on
CIFS/SMB shares (--copies avoids the lib64 symlink that CIFS rejects). Copies
the blitztext package into site-packages so the cloned source folder can be
deleted immediately after running install.sh. Adds a ~/.local/bin/blitztext
launcher and installs hicolor icons.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
mARTin-B78 2026-06-08 20:17:07 +02:00
parent b0b7a8c95e
commit 0ce4f8e7ac

View File

@ -1,49 +1,75 @@
#!/usr/bin/env bash
# Set up Blitztext for Linux: create a venv, install deps, check host tools,
# and write the default config. Run from the linux/ directory.
# Install Blitztext for Linux (no root needed).
#
# Creates a self-contained venv at ~/.local/lib/blitztext (outside any CIFS
# share, using --copies so no symlinks are needed), copies the package into it,
# and writes a launcher to ~/.local/bin/blitztext. The source folder can be
# deleted after this script finishes.
set -euo pipefail
cd "$(dirname "$0")"
VENV=".venv"
APPDIR="$HOME/.local/lib/blitztext"
VENV="$APPDIR/venv"
BIN="$HOME/.local/bin/blitztext"
echo "==> Checking host tools"
need_pkg=()
command -v xdotool >/dev/null || need_pkg+=("xdotool")
command -v xdotool >/dev/null || need_pkg+=("xdotool")
command -v notify-send >/dev/null || need_pkg+=("libnotify-bin")
if ! command -v pw-record >/dev/null && ! command -v arecord >/dev/null && ! command -v parecord >/dev/null; then
need_pkg+=("pipewire-bin (or alsa-utils)")
need_pkg+=("pipewire-bin (or alsa-utils)")
fi
if ((${#need_pkg[@]})); then
echo " Missing host tools: ${need_pkg[*]}"
echo " On Ubuntu/Debian: sudo apt install xdotool libnotify-bin pipewire-bin"
echo " (continuing — install them before running the daemon)"
if (( ${#need_pkg[@]} )); then
echo " Missing host tools: ${need_pkg[*]}"
echo " On Ubuntu/Debian: sudo apt install xdotool libnotify-bin pipewire-bin"
echo " (continuing — install them before running the app)"
fi
# --system-site-packages lets the venv see an apt-installed PyGObject (python3-gi)
# for the optional system-tray mode; harmless if it's not installed.
echo "==> Creating venv at $VENV"
python3 -m venv --system-site-packages "$VENV"
mkdir -p "$APPDIR"
# --copies avoids lib64->lib symlinks that fail on CIFS/SMB shares.
# --system-site-packages lets the venv see apt-installed python3-gi for the tray.
python3 -m venv --copies --system-site-packages "$VENV"
"$VENV/bin/pip" install --upgrade pip -q
"$VENV/bin/pip" install -r requirements.txt
"$VENV/bin/pip" install -q -r requirements.txt
echo "==> Installing blitztext package"
# Copy the package into site-packages so this source folder can be deleted.
cp -r blitztext "$VENV/lib/python"*/site-packages/
echo "==> Writing default config (if absent)"
"$VENV/bin/python" -m blitztext config-path
echo "==> Installing launcher → $BIN"
mkdir -p "$(dirname "$BIN")"
cat > "$BIN" <<EOF
#!/bin/sh
exec "$VENV/bin/python" -m blitztext "\$@"
EOF
chmod +x "$BIN"
# Copy icons to hicolor so the app shows up properly in the tray / launcher.
ICON_DIR="$HOME/.local/share/icons/hicolor"
PKG_DIR="$(cd "$(dirname "$0")" && pwd)"
for s in 32 48 64 128 256; do
SRC="$PKG_DIR/packaging/blitztext_${s}.png"
if [ -f "$SRC" ]; then
DEST="$ICON_DIR/${s}x${s}/apps/blitztext.png"
mkdir -p "$(dirname "$DEST")"
cp "$SRC" "$DEST"
fi
done
gtk-update-icon-cache -qf "$ICON_DIR" 2>/dev/null || true
cat <<EOF
Done. To start it:
Done! Blitztext is installed at $APPDIR
$VENV/bin/python -m blitztext tray # system tray (needs: sudo apt install python3-gi)
$VENV/bin/python -m blitztext gui # control-panel window
$VENV/bin/python -m blitztext run # headless, hotkeys only
Start it:
blitztext tray # system tray
blitztext gui # control-panel window
Edit your config (hotkeys, Whisper model, rewrite endpoint) at:
(Make sure ~/.local/bin is in your PATH — it is by default on Ubuntu.)
\$($VENV/bin/python -m blitztext config-path)
For the rewrite workflows, export your key first, e.g.:
export OPENAI_API_KEY=sk-...
To run it in the background on login, see blitztext.service in this folder.
You can now delete the source folder if you cloned it just for installation.
EOF