Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ on the words, and save without leaving the terminal.

The installer detects Apple Silicon, Intel macOS, x86_64 Linux, or 32-bit x86
Linux (`i686`), verifies the release archive, and installs `termleaf` into
Cargo's conventional binary directory:
Cargo's conventional binary directory. On Debian and Ubuntu, it also installs
any missing ALSA runtime packages. This includes the PulseAudio plugin used by
WSLg to route sound to Windows:

```bash
curl --proto '=https' --tlsv1.2 -LsSf \
Expand Down Expand Up @@ -105,14 +107,24 @@ directory's `PATH` entry if other Cargo tools are installed there.

### Build from source

On Debian and Ubuntu, install the build and audio runtime dependencies first:

```bash
sudo apt-get update
sudo apt-get install --yes pkg-config libasound2-dev libasound2-plugins
```

Then build Termleaf:

```bash
git clone https://github.com/andy5090/termleaf.git
cd termleaf
cargo install --path . --locked
```

Linux source builds require the ALSA development package, commonly
`libasound2-dev` on Debian and Ubuntu.
Other Linux distributions need their equivalent ALSA development package and,
when the desktop audio server is PulseAudio or PipeWire, the corresponding ALSA
plugin.

## Keybindings

Expand Down
39 changes: 39 additions & 0 deletions termleaf-installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,43 @@ die() {
exit 1
}

run_as_root() {
if [ "$(id -u)" -eq 0 ]; then
"$@"
elif command -v sudo >/dev/null 2>&1; then
sudo "$@"
else
die "installing Linux audio dependencies requires root or sudo"
fi
}

install_linux_audio_dependencies() {
# CPAL uses ALSA on Linux. On Debian-family systems the PulseAudio ALSA
# plugin is also required to reach WSLg's audio server when no hardware
# ALSA device is exposed inside the distribution.
if ! command -v dpkg-query >/dev/null 2>&1 ||
! command -v apt-get >/dev/null 2>&1; then
return
fi

missing_packages=""
for package_name in libasound2 libasound2-plugins; do

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Install libasound2t64 on Ubuntu 24.04

On a minimal Ubuntu 24.04 (Noble) installation—the WSLg scenario this change targets—libasound2 is a virtual package rather than an installable package. I checked apt-get install --simulate --yes libasound2 on Noble, which reports that it is provided by libasound2t64 and then fails with Package 'libasound2' has no installation candidate. Consequently, when ALSA is absent, the new dependency step exits under set -e before Termleaf is downloaded; detect/install libasound2t64 on systems where that is the concrete package, or otherwise resolve the available provider.

Useful? React with 👍 / 👎.

if ! dpkg-query -W -f='${Status}' "$package_name" 2>/dev/null |
grep -q '^install ok installed$'; then
missing_packages="$missing_packages $package_name"
fi
done

if [ -n "$missing_packages" ]; then
say "Installing Linux audio dependencies:$missing_packages"
run_as_root apt-get update
# Package names above are fixed constants, so intentional word
# splitting passes each missing package as a separate argument.
# shellcheck disable=SC2086
run_as_root apt-get install --yes $missing_packages
fi
}

usage() {
cat <<'EOF'
Usage: termleaf-installer.sh [OPTIONS]
Expand Down Expand Up @@ -95,6 +132,8 @@ case "$os_name" in
if ldd --version 2>&1 | grep -q 'musl'; then
die "musl Linux is not supported by the prebuilt installer"
fi

install_linux_audio_dependencies
;;
*)
die "unsupported operating system: $os_name"
Expand Down
Loading