# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Maintainer: Antonio Rojas <arojas@archlinux.org>
# Contributor: Andrea Scarpino <andrea@archlinux.org>
# Contributor: Alexey D. <lq07829icatm at rambler.ru>

# Holo: Build with the GLIBC_LOCALE_PREGENERATED=ON option

pkgname=plasma-workspace
pkgver=6.2.5
_dirver=$(echo $pkgver | cut -d. -f1-3)
pkgrel=1.1
pkgdesc='KDE Plasma Workspace'
arch=(x86_64)
url='https://kde.org/plasma-desktop/'
license=(LGPL-2.0-or-later)
depends=(accountsservice
         appstream-qt
         dbus
         fontconfig
         freetype2
         gcc-libs
         glibc
         icu
         kactivitymanagerd
         karchive
         kauth
         kbookmarks
         kcmutils
         kcolorscheme
         kcompletion
         kconfig
         kconfigwidgets
         kcoreaddons
         kcrash
         kde-cli-tools
         kdeclarative
         kded
         kdbusaddons
         kglobalaccel
         kguiaddons
         kholidays
         ki18n
         kiconthemes
         kidletime
         kio
         kio-extras
         kio-fuse
         kirigami
         kirigami-addons
         kitemmodels
         kjobwidgets
         knewstuff
         knotifications
         knotifyconfig
         kpackage
         kparts
         kpipewire
         krunner
         kquickcharts
         kscreenlocker
         kservice
         kstatusnotifieritem
         ksvg
         ksystemstats
         ktexteditor
         ktextwidgets
         kunitconversion
         kuserfeedback
         kwallet
         kwayland
         kwidgetsaddons
         kwin
         kwindowsystem
         kxmlgui
         layer-shell-qt
         libcanberra
         libice
         libkexiv2
         libksysguard
         libplasma
         libqalculate
         libsm
         libx11
         libxau
         libxcb
         libxcrypt
         libxcursor
         libxfixes
         libxft
         libxtst
         milou
         ocean-sound-theme
         phonon-qt6
         plasma-activities
         plasma-activities-stats
         plasma5support
         prison
         qt6-5compat
         qt6-base
         qt6-declarative
         qt6-positioning
         qt6-svg
         qt6-tools # for qdbus
         qt6-virtualkeyboard
         qt6-wayland
         sh
         solid
         systemd-libs
         wayland
         xcb-util
         xcb-util-image
         xorg-xmessage
         xorg-xrdb
         xorg-xsetroot
         xorg-xwayland
         zlib)
makedepends=(baloo
             extra-cmake-modules
             gpsd
             kdoctools
             kunitconversion
             networkmanager-qt
             plasma-wayland-protocols
             qcoro)
optdepends=('appmenu-gtk-module: global menu support for GTK2 and some GTK3 applications'
            'baloo: Baloo search runner'
            'discover: manage applications installation from the launcher'
            'gpsd: GPS based geolocation'
            'kdepim-addons: displaying PIM events in the calendar'
            'kwayland-integration: Wayland integration for Qt5 applications'
            'networkmanager-qt: IP based geolocation'
            'plasma-workspace-wallpapers: additional wallpapers'
            'plasma5-integration: use Plasma settings in Qt5 applications'
            'xdg-desktop-portal-gtk: sync font settings to Flatpak apps')
conflicts=(plasma-wayland-session)
replaces=(plasma-wayland-session)
groups=(plasma)
source=(https://download.kde.org/stable/plasma/$_dirver/$pkgname-$pkgver.tar.xz{,.sig}
        0001-Avoid-assert-on-shortcut-handling-when-used-with-kio.patch # Fix for crashing lockscreen, drop after = 6.3
)
sha256sums=('b82511e46f62e1b8f60b969c828c8d8d32fc7928401a70cc28c29f85f46c412f'
            'SKIP'
            'ad4f7e762f9babe601e537acdafd22f0a38b63f4c43ca78e754cc63494830bd3')
validpgpkeys=('E0A3EB202F8E57528E13E72FD7574483BB57B18D'  # Jonathan Esk-Riddell <jr@jriddell.org>
              '0AAC775BB6437A8D9AF7A3ACFE0784117FBCE11D'  # Bhushan Shah <bshah@kde.org>
              'D07BD8662C56CB291B316EB2F5675605C74E02CF'  # David Edmundson <davidedmundson@kde.org>
              '1FA881591C26B276D7A5518EEAAF29B42A678C20') # Marco Martin <notmart@gmail.com>

prepare() {
  patch -p1 -d "$srcdir/$pkgname-$pkgver" -i "$srcdir/0001-Avoid-assert-on-shortcut-handling-when-used-with-kio.patch"
}


build() {

  # Holo: GLIBC_LOCALE_* settings are overriden due to Steam differences
  # with the read only disk.
  # See documentation with CMakeLists.txt of plasma-workspace for details

  cmake -B build -S $pkgname-$pkgver \
    -DCMAKE_INSTALL_LIBEXECDIR=lib \
    -DGLIBC_LOCALE_PREGENERATED=ON \
    -DGLIBC_LOCALE_GEN=OFF \
    -DBUILD_TESTING=OFF
  cmake --build build
}

package() {
  depends+=(plasma-integration) # Declare runtime dependency here to avoid dependency cycles at build time

  DESTDIR="$pkgdir" cmake --install build
}
