# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=ukui-settings-daemon
pkgver=3.1.1.1
pkgrel=7
pkgdesc="Daemon handling the UKUI session settings"
arch=('x86_64')
license=('GPL')
url="https://github.com/ukui/ukui-settings-daemon"
groups=('ukui')
depends=('geoclue' 'gnome-desktop' 'gtk3' 'kglobalaccel5' 'kwindowsystem5'
         'libcanberra' 'libkscreen5' 'libmatekbd' 'libnotify' 'libxklavier'
         'mate-desktop' 'qt5-sensors' 'qt5-svg' 'qt5-x11extras' 'ukui-interface')
makedepends=('qt5-tools' 'xorg-server-devel')
source=("$pkgname-$pkgver.tar.gz::https://github.com/ukui/ukui-settings-daemon/archive/v$pkgver.tar.gz"
         libkscreen-5.27.patch
         fix-build.patch)
sha512sums=('451cca8c153764c497d502eb6159db44bbdf0fce63c5ee38d3f347ee8c1d84d726f7026b1b02b463c6c7a8b9a15a84ad5df8f27b5afe0e06d2b6a81481839fe4'
            'e99ae6572322d727b67cafe83559c98dc0f93e29a2c982ab9b34a74c6bf9afa241aa8fdf90ed5b04b464c46d08ef90ecabbe99fcb93e2e8ce711db59597183cc'
            '96a7003b0c589e84c300d9bdb29dc2a9bd2ee31f916cc0ab2538fb1e00d882515a487f3ad2c749c23b9fc005c7ea4070b080570d1fa0be65c3870a771d5e6b2c')

prepare() {
  cd $pkgname-$pkgver
  sed -i 's|#include <ukuisdk/kylin-com4cxx.h>|#include <kylin-com4cxx.h>|' common/usd_base_class.h
  sed -i 's|udev.path = /lib/udev/rules.d/|udev.path = /usr/lib/udev/rules.d/|' plugins/mouse/mouse.pro

  # Fix build with libkscreen 5.27
  sed -e 's|c++11||' -i plugins/xrandr/xrandr.pro -i common/common.pri
  patch -p1 -i ../libkscreen-5.27.patch
  patch -p1 -i ../fix-build.patch
}

build() {
  cd $pkgname-$pkgver
  qmake-qt5 PREFIX=/usr QMAKE_LFLAGS="${LDFLAGS}"
  make
}

package() {
  cd $pkgname-$pkgver
  make INSTALL_ROOT="$pkgdir" install
}
