#!/usr/bin/bash
# JOBoRun		: Jwm OpenBox Obarun RUNit
# Maintainer	: Joe Bo Run <joborun@disroot.org>
# PkgSource		: url="https://gittea.disroot.org/joborun-pkg/jobextra/$pkgname"
# Contributor	: Dylan Araps <dylan.araps@gmail.com>
#-----------------------------------------| DESCRIPTION |---------------------------------------

pkgname=openbox-patched
_pkgname=openbox
pkgver=3.6.1
pkgrel=07
pkgdesc='Openbox with Rounded Corners patch and anything else deemed useful'
url='http://openbox.org'
arch=('x86_64')
install="${pkgname}.install"
backup=('etc/xdg/openbox/menu.xml'
        'etc/xdg/openbox/rc.xml'
        'etc/xdg/openbox/autostart'
        'etc/xdg/openbox/environment')
depends=('libxml2' 'libxinerama' 'libxrandr'
         'libxcursor' 'pango' 'imlib2' 'librsvg' 'libsm' 'python-pyxdg')
groups=('lxde' 'lxde-gtk3')
provides=('libobrender.so' $_pkgname)
conflicts=($_pkgname)
replaces=($_pkgname)

source=("http://openbox.org/dist/openbox/${_pkgname}-${pkgver}.tar.gz"
        "http://openbox.org/dist/openbox/openbox-3.5.0-title-matching.patch"
        "http://openbox.org/dist/openbox/openbox-3.5.0-which-2.20.patch"
        "http://openbox.org/dist/openbox/openbox-3.6.2-rounded-corners.patch"
        "http://openbox.org/dist/openbox/openbox-3.6.2-fix-out-of-bounds.patch"
        "https://github.com/archlinux/svntogit-community/blob/packages/openbox/trunk/py3.patch")

prepare() {
    cd "${_pkgname}-${pkgver}"

    patch -Np1 -i "${srcdir}/openbox-3.5.0-title-matching.patch"  # OB#5277
    patch -Np1 -i "${srcdir}/openbox-3.5.0-which-2.20.patch"  # FS#11455

    # https://forums.bunsenlabs.org/viewtopic.php?pid=46711#p46711
    patch -Np1 -i "${srcdir}/openbox-3.6.2-rounded-corners.patch"

    # https://github.com/danakj/openbox/pull/26
    patch -Np1 -i "${srcdir}/openbox-3.6.2-fix-out-of-bounds.patch"

    patch -Np1 -i "${srcdir}/py3.patch"

    # py3.patch modifies configure.ac
    autoreconf -ifv
}

build() {
    cd "${_pkgname}-${pkgver}"

    ./configure \
        --prefix=/usr \
        --with-x \
        --disable-startup-notification \
        --sysconfdir=/etc \
        --libexecdir=/usr/lib/openbox
    make
}

package() {
    cd "${_pkgname}-${pkgver}"
    make DESTDIR="$pkgdir" install
    # GNOME Panel is no longer available in the arch repositories
    rm -r "${pkgdir}/usr/bin/"{gdm-control,gnome-panel-control,openbox-gnome-session} \
          "${pkgdir}/usr/share/gnome"{,-session} \
          "${pkgdir}/usr/share/man/man1/openbox-gnome-session.1" \
          "${pkgdir}/usr/share/xsessions/openbox-gnome.desktop"

#
#    sed -i 's:startkde:/usr/bin/\0:' \
#        "${pkgdir}/usr/share/xsessions/openbox-kde.desktop"
#  The hell with kde and plasma telemetry backdoors
#
}

#---- license gpg-key sha256sums ----

license=('GPL')

sha256sums=(8b4ac0760018c77c0044fab06a4f0c510ba87eae934d9983b10878483bde7ef7  # openbox-3.6.1.tar.gz
	adc0820671e6ec42ff1bb4cbb04c65e19cdf74c62bcef3a3b727adb208eb82c7  # openbox-3.5.0-title-matching.patch
	ce33bb6c3d543da091db2037e1f3084e5a0e752c9479584256d2f000f0da920d  # openbox-3.5.0-which-2.20.patch
	ac5617253dfc39e2fc204830ca19aa3fa48a0e00e46dd90a0057a2f1dd77cfbb  # openbox-3.6.2-rounded-corners.patch
	ec1f99bd7149e888c96b719b4192c413464815848bb05cfa8e88c7cb4214b9ac  # openbox-3.6.2-fix-out-of-bounds.patch
	4cd2708320ab3cdf4868bd66f20481dbad504d0e9aa43f13bca5c149b94a49cf) # py3.patch

