Initial commit: linux-provision repo
Distribution-agnostic provisioning script that sets up a new Linux machine (Detected via lib/distro.sh - supports Debian/Ubuntu/Pop and Fedora families). 13 stages covering: - System packages, external repos, toolchains (nvm, uv, Python) - Shell config (zsh, oh-my-zsh, p10k), git, SSH - Custom uv tools from ~40 git repos - Desktop config (keybindings, hotkeys, ghostty, fonts) - Docker, system tweaks, browser/app installs - Custom systemd user services (porridge, swayidle, mempi-sync, etc.) - API keys loaded from Bitwarden at shell startup
This commit is contained in:
86
stages/07-scripts.sh
Normal file
86
stages/07-scripts.sh
Normal file
@@ -0,0 +1,86 @@
|
||||
#!/usr/bin/env bash
|
||||
# ===========================================================================
|
||||
# Stage 07: Custom Scripts (~/.local/bin/)
|
||||
# Deploys Julian's custom scripts: Bitwarden SSH loader, Zoom wrapper,
|
||||
# idle battery suspend, env PATH helper, and more.
|
||||
# ===========================================================================
|
||||
# These are the "glue" scripts that make the desktop work the way Julian
|
||||
# expects. They were found in ~/.local/bin/ on the Pop machine.
|
||||
#
|
||||
# Config templates are in config/scripts/
|
||||
# ===========================================================================
|
||||
|
||||
CONFIG_DIR="${SCRIPT_DIR:-$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)}/config"
|
||||
SCRIPTS_DIR="${CONFIG_DIR}/scripts"
|
||||
TARGET_DIR="$HOME/.local/bin"
|
||||
|
||||
mkdir -p "$TARGET_DIR"
|
||||
|
||||
info "Deploying custom scripts to $TARGET_DIR..."
|
||||
|
||||
# ---- 1. env.sh — PATH helper (sourced by .profile / .bashrc) ----
|
||||
# Ensures ~/.local/bin is in PATH without duplicate entries.
|
||||
if [ -f "$SCRIPTS_DIR/env.sh" ]; then
|
||||
cp "$SCRIPTS_DIR/env.sh" "$TARGET_DIR/env"
|
||||
chmod +x "$TARGET_DIR/env"
|
||||
ok "env deployed."
|
||||
fi
|
||||
|
||||
# ---- 2. bw-load-ssh.sh — Load SSH keys from Bitwarden ----
|
||||
# Script that fetches SSH keys from Bitwarden vault and loads into ssh-agent.
|
||||
# Depends on: bw (Bitwarden CLI), jq, ssh-agent running.
|
||||
if [ -f "$SCRIPTS_DIR/bw-load-ssh.sh" ]; then
|
||||
cp "$SCRIPTS_DIR/bw-load-ssh.sh" "$TARGET_DIR/bw-load-ssh.sh"
|
||||
chmod +x "$TARGET_DIR/bw-load-ssh.sh"
|
||||
ok "bw-load-ssh.sh deployed."
|
||||
fi
|
||||
|
||||
# ---- 3. zoom.sh — Zoom wrapper for Wayland + AMD GPU ----
|
||||
# Forces Wayland native mode and VAAPI hardware video decoding on AMD Radeon.
|
||||
# Without this, Zoom would use XWayland and software decoding (bad perf).
|
||||
if [ -f "$SCRIPTS_DIR/zoom.sh" ]; then
|
||||
cp "$SCRIPTS_DIR/zoom.sh" "$TARGET_DIR/zoom"
|
||||
chmod +x "$TARGET_DIR/zoom"
|
||||
ok "zoom wrapper deployed."
|
||||
else
|
||||
# Create default Zoom wrapper
|
||||
cat > "$TARGET_DIR/zoom" << 'SCRIPT'
|
||||
#!/bin/bash
|
||||
# Zoom wrapper — forces Wayland + HW acceleration on AMD GPU
|
||||
export QT_QPA_PLATFORM=wayland
|
||||
export LIBVA_DRIVER_NAME=radeonsi
|
||||
export LIBVA_DRI3_DISABLE=0
|
||||
exec /usr/bin/zoom "$@"
|
||||
SCRIPT
|
||||
chmod +x "$TARGET_DIR/zoom"
|
||||
ok "zoom wrapper created (default)."
|
||||
fi
|
||||
|
||||
# ---- 4. idle-battery-suspend.sh — Suspend on battery after idle ----
|
||||
# Checks if AC is disconnected before suspending. Prevents suspend on desktop.
|
||||
# Used by swayidle.service (stage 08).
|
||||
if [ -f "$SCRIPTS_DIR/idle-battery-suspend.sh" ]; then
|
||||
cp "$SCRIPTS_DIR/idle-battery-suspend.sh" "$TARGET_DIR/idle-battery-suspend.sh"
|
||||
chmod +x "$TARGET_DIR/idle-battery-suspend.sh"
|
||||
ok "idle-battery-suspend.sh deployed."
|
||||
fi
|
||||
|
||||
# ---- 5. Bitwarden CLI (bw) ----
|
||||
# On Pop: ~/.local/bin/bw (138 MB standalone binary)
|
||||
if ! command -v bw &>/dev/null; then
|
||||
info "Installing Bitwarden CLI..."
|
||||
# bw is a standalone binary — download it
|
||||
BW_LATEST=$(curl -fsSL "https://api.github.com/repos/bitwarden/clients/releases?per_page=1" | grep -oP '"tag_name":\s*"cli-v\K[^"]+' | head -1) || BW_LATEST="2025.1.0"
|
||||
curl -fsSL "https://github.com/bitwarden/clients/releases/download/cli-v${BW_LATEST}/bw-linux-${BW_LATEST}.zip" -o /tmp/bw.zip 2>/dev/null && {
|
||||
unzip -o /tmp/bw.zip -d /tmp/bw-extract 2>/dev/null
|
||||
cp /tmp/bw-extract/bw "$TARGET_DIR/bw"
|
||||
chmod +x "$TARGET_DIR/bw"
|
||||
rm -rf /tmp/bw.zip /tmp/bw-extract
|
||||
ok "Bitwarden CLI installed."
|
||||
} || warn "Bitwarden CLI download failed. Install manually: https://bitwarden.com/help/cli/"
|
||||
fi
|
||||
|
||||
# Ensure permissions
|
||||
chmod -R 755 "$TARGET_DIR" 2>/dev/null || true
|
||||
|
||||
ok "Stage 07 complete: custom scripts deployed to ~/.local/bin."
|
||||
Reference in New Issue
Block a user