Last active
February 13, 2026 23:44
-
-
Save luavixen/eff50578c5d21b160dc4a6c7f69de9f3 to your computer and use it in GitHub Desktop.
Bash script for setting up https://github.com/varjolintu/keepassxc-proxy-rust on Bazzite with both Firefox and KeePassXC as Flatpaks.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| set -euo pipefail | |
| # Cleanup function | |
| cleanup() { | |
| if [ -n "${TMPDIR:-}" ] && [ -d "${TMPDIR}" ]; then | |
| echo "cleaning up temporary directory..." >&2 | |
| rm -rf "${TMPDIR}" | |
| fi | |
| } | |
| trap cleanup EXIT | |
| # 1. Check flatpaks | |
| echo "checking flatpaks..." | |
| if ! flatpak list --app | grep -q "org.mozilla.firefox"; then | |
| echo "error: missing flatpak org.mozilla.firefox" >&2 | |
| exit 1 | |
| fi | |
| if ! flatpak list --app | grep -q "org.keepassxc.KeePassXC"; then | |
| echo "error: missing flatpak org.keepassxc.KeePassXC" >&2 | |
| exit 1 | |
| fi | |
| # 2. Create temporary directory | |
| TMPDIR="${XDG_RUNTIME_DIR}/keepassxc-proxy-install.$$" | |
| echo "creating temporary directory..." | |
| mkdir -p "${TMPDIR}" | |
| # 3. Clone repository at specific commit | |
| echo "cloning keepassxc-proxy-rust at commit ece4006f..." | |
| git clone https://github.com/varjolintu/keepassxc-proxy-rust "${TMPDIR}/keepassxc-proxy-rust" | |
| git -C "${TMPDIR}/keepassxc-proxy-rust" checkout ece4006f801c1b8bfd9694b1df499e2685fe8231 | |
| # 4. Build in alpine container | |
| echo "building with rustc 1.93.0 in alpine:3.23 container..." | |
| podman run --rm \ | |
| -v "${TMPDIR}/keepassxc-proxy-rust:/app:Z" \ | |
| -w /app \ | |
| alpine:3.23 \ | |
| sh -c 'apk add --no-cache rustup build-base && \ | |
| rustup-init -y --default-toolchain 1.93.0 --target x86_64-unknown-linux-musl && \ | |
| source "$HOME/.cargo/env" && \ | |
| RUSTFLAGS="-C link-arg=-s -Clink-self-contained=y -Clinker=rust-lld" cargo build --release --target x86_64-unknown-linux-musl' | |
| # 5. Stop Firefox | |
| echo "stopping org.mozilla.firefox flatpak..." | |
| flatpak kill org.mozilla.firefox 2>/dev/null || true | |
| # 6. Copy binary | |
| DEST_DIR="${HOME}/.var/app/org.mozilla.firefox/.mozilla/native-messaging-hosts" | |
| echo "copying binary to ${DEST_DIR}..." | |
| mkdir -p "${DEST_DIR}" | |
| cp "${TMPDIR}/keepassxc-proxy-rust/target/x86_64-unknown-linux-musl/release/keepassxc-proxy" "${DEST_DIR}/keepassxc-proxy" | |
| chmod +x "${DEST_DIR}/keepassxc-proxy" | |
| # 7. Write manifest | |
| MANIFEST_PATH="${DEST_DIR}/org.keepassxc.keepassxc_browser.json" | |
| echo "writing native messaging manifest..." | |
| cat > "${MANIFEST_PATH}" << EOF | |
| { | |
| "allowed_extensions": [ | |
| "keepassxc-browser@keepassxc.org" | |
| ], | |
| "description": "KeePassXC integration with native messaging support, workaround for flatpaked Firefox, see https://is.gd/flatpakFirefoxKPXC", | |
| "name": "org.keepassxc.keepassxc_browser", | |
| "path": "${HOME}/.mozilla/native-messaging-hosts/keepassxc-proxy", | |
| "type": "stdio" | |
| } | |
| EOF | |
| # 8. Punch the hole | |
| echo "granting org.mozilla.firefox access to keepassxc's socket..." | |
| flatpak override --user --filesystem=xdg-run/app/org.keepassxc.KeePassXC/:create org.mozilla.firefox | |
| # 9. Yaaayyy :3c Yippee :D | |
| echo "installation complete" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment