Skip to content

Instantly share code, notes, and snippets.

@RobChiocchio
Last active July 18, 2025 21:14
Show Gist options
  • Save RobChiocchio/3e4a9eac1d4f8c472b999554ffa1c42e to your computer and use it in GitHub Desktop.
Save RobChiocchio/3e4a9eac1d4f8c472b999554ffa1c42e to your computer and use it in GitHub Desktop.
Install BetterDiscord for the Flatpak version of Discord on Linux
#!/bin/bash
# This script installs BetterDiscord for the Flatpak version of Discord on Linux.
# Written by Rob Chiocchio on 04/30/2024
### Variables ###
# Color variables
NO_COLOR="\033[0m"
COLOR="\033[0;36m" # Cyan
# Flatpak Discord AppID and download URL for latest BetterDiscord Linux AppImage release
APPID=com.discordapp.Discord
DOWNLOAD_URL=https://github.com/BetterDiscord/Installer/releases/latest/download/BetterDiscord-Linux.AppImage
# Set temporary directory
DISCORD_TMPDIR="$XDG_RUNTIME_DIR/app/$APPID/"
TEMP=$(TMPDIR=$DISCORD_TMPDIR mktemp -d)
cd $TEMP
# Cleanup temp directory on exit
trap "rm -rf $TEMP" EXIT
### Functions ###
# Log a message with colors and a timestamp
log () {
echo -e "${COLOR}[$(date +'%Y-%m-%d %H:%M:%S')]${NO_COLOR} $1"
}
# Return true (0) if Discord is running, false (1) otherwise. Sets PIDS variable to the list of PIDs.
is_running () {
PIDS=$(flatpak ps | grep $APPID | grep -oP "(^\\S+)")
return $(test -n "$PIDS")
}
### Main Script ###
log "BetterDiscord installer script for Flatpak Discord by Rob Chiocchio"
# Check if Discord is running
if is_running; then
log "Discord is currently running. Please close Discord before installing BetterDiscord. Press any key to continue..."
read -n 1 -r -s -p ""
fi
# If Discord is still running, kill processes
if is_running; then
echo "$PIDS" | while read -r pid; do
log "Killing Discord process $pid..."
flatpak kill $pid
done
fi
log "Downloading BetterDiscord..."
wget --quiet --show-progress --progress=bar:force:noscroll -O BetterDiscord.AppImage $DOWNLOAD_URL
chmod +x $TEMP/BetterDiscord.AppImage
log "Extracting BetterDiscord installer files..."
$TEMP/BetterDiscord.AppImage --appimage-extract 2>&1 > /dev/null
log "Running BetterDiscord installer..."
flatpak run --command=$TEMP/squashfs-root/betterdiscord-installer $APPID --no-sandbox
log "Cleaning up temporary files..."
rm -rf $TEMP
log "BetterDiscord installation complete!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment