description="All-in-one voice and text chat for gamers that's free and secure."
url="https://discordapp.com/"

packager="Tnut <tnut@nutyx.org>"
contributors="Rems,Sundev79,Spiky,Skythrew"

name=discord
version=0.0.25

run=(gtk3 libnotify xorg-libxscrnsaver
     glibc alsa-lib nspr nss pulseaudio
     noto-fonts-emoji hicolor-icon-theme
     desktop-file-utils gtk-update-icon-cache shared-mime-info)

PKGMK_KEEP_SOURCES="no"

source=(https://dl.discordapp.net/apps/linux/$version/$name-$version.tar.gz
        https://discordapp.com/terms https://discordapp.com/licenses)

prepare() {
  sed -i "s|Exec=.*|Exec=/usr/bin/$name|" Discord/$name.desktop
}
build() {

  install -d $PKG/opt/$name
  cp -a Discord/. $PKG/opt/$name
  chmod 755 $PKG/opt/$name/Discord

  install -d $PKG/usr/share/applications
  ln -s /opt/$name/$name.desktop $PKG/usr/share/applications

  install -d $PKG/usr/bin
  ln -s /opt/$name/Discord $PKG/usr/bin/$name

  install -d $PKG/usr/share/pixmaps
  ln -s /opt/$name/$name.png $PKG/usr/share/pixmaps/$name.png

  chmod u+s $PKG/opt/$name/chrome-sandbox

  install -Dm644 terms $PKG/usr/share/licenses/$name/LICENSE.html
  install -Dm644 licenses $PKG/usr/share/licenses/$name/OSS-LICENSES.html
}
