Skip to content

Instantly share code, notes, and snippets.

@morgan9e
Created February 29, 2024 00:02
Show Gist options
  • Save morgan9e/3b6e6fb7f05c89f5f7b933e4a115face to your computer and use it in GitHub Desktop.
Save morgan9e/3b6e6fb7f05c89f5f7b933e4a115face to your computer and use it in GitHub Desktop.
Multiple instance of user-installed Flatpak.
#!/bin/bash
set -euo pipefail
if [ ! -v FLATPAK_ID ]; then echo "Not in Flatpak."; exit; fi;
DEFAULT_COMMAND=$(cat /app/manifest.json | python3 -c "import sys, json; print(json.load(sys.stdin)['command'])");
NEW_HOME="${HOME}/.altvar"
NEW_APP_DIR="${NEW_HOME}/app/${FLATPAK_ID}"
if [ ! -d "$NEW_HOME" ]; then echo "Not initialized."; exit; fi;
export XDG_CACHE_HOME="${NEW_APP_DIR}/cache"
export XDG_DATA_HOME="${NEW_APP_DIR}/data"
export XDG_CONFIG_HOME="${NEW_APP_DIR}/config"
mkdir -p "$XDG_CACHE_HOME"
mkdir -p "$XDG_DATA_HOME"
mkdir -p "$XDG_CONFIG_HOME"
echo -e "\e[1;32m[${FLATPAK_ID}] APP_DIR: ${NEW_APP_DIR}\e[0m"
eval ${DEFAULT_COMMAND}
#!/bin/bash
shift
echo $@ >> ~/.altvar/log
flatpak run --filesystem="$HOME/.altvar" --cwd="$HOME" --command=".altvar/entrypoint" $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment