Skip to content

Instantly share code, notes, and snippets.

@karoltheguy
Forked from niklasdewally/update-discord
Last active January 10, 2024 04:13
Show Gist options
  • Save karoltheguy/140ea9eda92a29437509f7df13e2ab5d to your computer and use it in GitHub Desktop.
Save karoltheguy/140ea9eda92a29437509f7df13e2ab5d to your computer and use it in GitHub Desktop.
Discord Installer
#!/bin/bash
shopt -s nullglob
pp (){
if [ -x "$(command -v cowsay)" ]
then
cowsay "$1"
else
echo "=========="
echo "$1"
echo "=========="
fi
}
# CHECK FOR ROOT
if [[ $(id -u) -ne 0 ]] ; then pp "Please run as root" ; exit 1 ; fi
tmpdir=$(mktemp -d)
pp "Downloading Discord"
wget --output-document="$tmpdir/discord.tar.gz" 'https://discord.com/api/download?platform=linux&format=tar.gz'
tar xf "$tmpdir/discord.tar.gz" --directory="$tmpdir"
pp "Installing to /opt/Discord"
mkdir -p /opt/Discord
rm -rf /opt/Discord/*
cp -r $tmpdir/Discord /opt/
pp "Run postinstallation script"
sudo -u $(logname) sh -c "/opt/Discord/postinst.sh"
pp "Create desktop file"
# https://superuser.com/a/484280/1691435
desktopFile="/home/$(logname)/.local/share/applications/discord.desktop"
echo "Saving desktop entry to $desktopFile"
cat << EOF > $desktopFile
## AUTOGENERATED BY update-discord!
[Desktop Entry]
Name=Discord
StartupWMClass=discord
Comment=All-in-one voice and text chat for gamers that's free, secure, and works on both your desktop and phone.
GenericName=Internet Messenger
Path=/opt/Discord
Exec=/opt/Discord/Discord --ignore-gpu-blocklist --disable-features=UseOzonePlatform --enable-features=VaapiVideoDecoder --enable-gpu-rasterization --enable-zero-copy --enable-features=VaapiVideoDecoder,VaapiVideoEncoder --ozone-platform=wayland
Icon=/opt/Discord/discord.png
Type=Application
Categories=Network;InstantMessaging;
EOF
chown $(logname):$(logname) "$desktopFile"
chmod 777 "$desktopFile"
@karoltheguy
Copy link
Author

Added shortcuts work with KDE Plasma

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment