# $Id: PKGBUILD 315639 2018-04-10 21:32:27Z grazzolini $
# Maintainer: Giancarlo Razzolini <grazzolini@archlinux.org>
# Contributor: Guillaume ALAUX <guillaume@archlinux.org>
# Contributor: Allan McRae <allan@archlinux.org>
# Contributor: fancris3 <fancris3 at gmail.com>
# Contributor: Daniel J Griffiths <ghost1227@archlinux.us>

pkgname=terminator
pkgver=1.91
pkgrel=6
pkgdesc='Terminal emulator that supports tabs and grids'
arch=('any')
url='https://gnometerminator.blogspot.com/p/introduction.html'
license=('GPL2')
depends=('gsettings-desktop-schemas' 'libkeybinder3' 'libnotify' 'python2-cairo' 'python2-dbus' 'python2-psutil' 'python2-gobject' 'vte3' 'xdg-utils')
makedepends=('intltool')
source=("https://launchpad.net/terminator/gtk3/${pkgver}/+download/${pkgname}-${pkgver}.tar.gz"
        "https://launchpad.net/terminator/gtk3/${pkgver}/+download/${pkgname}-${pkgver}.tar.gz.asc"
        "001-custom_commands.patch")
md5sums=('2eed999d7a41f2e18eaa511bbbf80f58'
         'SKIP'
         'd6c51930c0c741c327641de3adfe0aa1')
sha512sums=('6feee96cda08f913601d3b01e51632bed87712ddb5ce577df1daa8a5fe4e8dc39075d5e21f87b865d1f007c7e1070ee2c0c814540c9c7786f0f24fbee762a03d'
            'SKIP'
            'db1e3bbc911afaedd07dae0d34301b15ae28ecec54f7ce10a9c0fd6e2ebd6eaac643e8b6c2a01942f76ba51a41c39eb164fa83e3c78f13ef8441c253a5408d4d')
validpgpkeys=('FE67C001C72200A71DE9EFA5DB69E1780B95EF32')

prepare() {
    cd "${srcdir}/${pkgname}-${pkgver}"

    # python2 fix
    for file in terminatorlib/{,plugins/}*.py; do
        sed -i 's_#!/usr/bin/python_#!/usr/bin/python2_' $file
        sed -i 's_#!/usr/bin/env python_#!/usr/bin/env python2_' $file
    done

    # fix run without gconf
    sed -i 's/except ImportError:/except ValueError:/' terminatorlib/config.py

    # patch the custom commands plugin
    patch -Np1 -i "${srcdir}/001-custom_commands.patch"
}

build() {
    cd "${srcdir}/${pkgname}-${pkgver}"

    python2 setup.py build
}

package() {
    cd "${srcdir}/${pkgname}-${pkgver}"

    python2 setup.py install --skip-build --root="${pkgdir}" --optimize=1

    rm -f "${pkgdir}/usr/share/icons/hicolor/icon-theme.cache"
}
