# Maintainer: Bruno Pagani <archange@archlinux.org>
# Contributor: Eli Schwartz <eschwartz@archlinux.org>
# Contributor: Alexandre Filgueira <alexfilgueira@cinnarch.com>
# Contributor: M0Rf30
# Contributor: unifiedlinux
# Contributor: CReimer

pkgname=cinnamon
pkgver=6.6.3
pkgrel=1
pkgdesc="Linux desktop which provides advanced innovative features and a traditional user experience"
arch=(x86_64)
url="https://github.com/linuxmint/cinnamon"
license=(GPL2)
depends=(accountsservice cinnamon-control-center cinnamon-desktop cinnamon-menus cinnamon-screensaver
         cinnamon-session cinnamon-settings-daemon cjs gcr gdk-pixbuf2 glib2 gnome-backgrounds gsound
         gstreamer gtk3 libibus libgnomekbd libkeybinder3 librsvg muffin
         network-manager-applet nemo pango polkit-gnome python python-cairo python-dbus
         python-gobject python-pam python-pexpect python-pillow python-pyinotify
         python-pytz python-tinycss2 python-xapp python-requests timezonemap xapp xdg-desktop-portal-xapp)
optdepends=('blueman: Bluetooth support'
            'cinnamon-translations: i18n'
            'gnome-panel: fallback mode'
            'metacity: fallback mode'
            'system-config-printer: printer settings'
            'wget: cover download support in audio applet'
            'gnome-terminal: X terminal emulator'
            'touchegg: touch gestures'
            'switcheroo-control: GPU offloading')
makedepends=(git meson gobject-introspection intltool glib2-devel python-libsass)
conflicts=("caribou<=0.4.21+75+g8ad9883-8")
options=('!emptydirs')
source=(git+${url}#tag=$pkgver
        set_wheel.diff
        default-theme.patch)
sha512sums=('39a45317ff89262cc675dab14e2341baaa7af504ffab6f0e1d3f861220cfa13e0757c79c5e0165181a9b4238b59278c0dbd5232acae02f7fc3579f2e680004aa'
            'fd7e117054996ed1c3dfd0f968c2bf98ca4fcee9a100221f8839a232147745ec0140e1f68eeffba58a3c44f66f26e05d433648a7a28858ec669524f7266ba04c'
            'ee7dedd59ea370cf81d75def49060f9a29b22e7b025ca7d5db87a0102d50f138c79aa562b0d36a748c4b1c59a37f600ba1f60ff6caf303cf5b6fc4d110d051b4')
b2sums=('bf9c79f6347f7e4a7a6bccf09be777c3edc057500539bba8a6deb0af91a4f8e292d47a549d5dfe995bb666f1e361f15c55fbd072906e4374d37007c76423defa'
        '3becf1f40068fc629109e6e7d464c3c484296afacc9ab6328b2ccbb3c9735bcbfa9550f9f73b430ede178ae668e37c660ce322b5b4d1873526de3d3d41185160'
        '86c3a29acd132ca321f08fd81dd5a45707accdc035b2aeec95bf358b29072ff1eedb77b2566cf48d7253d1d791599f0f44938c4600761d711cb18b59019f1c62')

prepare() {
  cd ${pkgname}

  # Use wheel group instread of sudo (taken from Fedora)
  patch -p1 < ../set_wheel.diff

  # Set default theme to 'cinnamon'
  patch -p1 < ../default-theme.patch

  # Replace MintInstall with GNOME Software
  sed -i 's/mintinstall.desktop/org.gnome.Software.desktop/' data/org.cinnamon.gschema.xml

  # Add polkit agent to required components
  sed -i 's/RequiredComponents=\(.*\)$/RequiredComponents=\1polkit-gnome-authentication-agent-1;/' \
      cinnamon*.session.in

  # https://github.com/linuxmint/cinnamon/issues/3575#issuecomment-374887122
  # Cinnamon has no upstream backgrounds, use GNOME backgrounds instead
  sed -i 's|/usr/share/cinnamon-background-properties|/usr/share/gnome-background-properties|' \
      files/usr/share/cinnamon/cinnamon-settings/modules/cs_backgrounds.py
}

build() {
  arch-meson --libexecdir=lib/cinnamon ${pkgname} build
  meson compile -C build
}

package() {
  meson install -C build --destdir="$pkgdir"
}
