Skip to content

Instantly share code, notes, and snippets.

@naytseyd
Last active February 26, 2024 18:25
Show Gist options
  • Save naytseyd/5a2157f7a8ee24d3f770f782bd51d8fc to your computer and use it in GitHub Desktop.
Save naytseyd/5a2157f7a8ee24d3f770f782bd51d8fc to your computer and use it in GitHub Desktop.
#!/bin/bash
# Get current version
DISCORD_VERSION=$(curl -s https://discord.com/api/updates/stable?platform=linux | jq -r '.name')
# Download current version
if ! curl -Lo "discord-$DISCORD_VERSION.tar.gz" "https://discord.com/api/download?platform=linux&format=tar.gz&branch=stable"; then
echo "Download failed. Please try again."
exit 1
fi
# Remove old version
sudo rm -rf /opt/Discord
# Install new version
sudo tar -xvzf "discord-$DISCORD_VERSION.tar.gz" -C /opt/ >/dev/null 2>&1
# Copy the Discord icon to an appropriate location
sudo cp /opt/Discord/discord.png /usr/share/icons
# Update desktop shortcut
sudo sed -i 's|/usr/share/discord|/opt/Discord|' /opt/Discord/discord.desktop
sudo cp /opt/Discord/discord.desktop /usr/share/applications/
# Clean up
rm "discord-$DISCORD_VERSION.tar.gz"
# Exclude Discord from dnf updates
if grep -q "Fedora" /etc/os-release; then
if ! grep -q "exclude=discord" /etc/dnf/dnf.conf; then
echo "exclude=discord" | sudo tee -a /etc/dnf/dnf.conf >/dev/null 2>&1
fi
fi
# Show update message
echo -e "Discord updated.\nCurrent version: $DISCORD_VERSION"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment