%global shortversion 7.4
%global tag v%{shortversion}
Name    : compton
Version : 7.4.0
Release : 1%{?dist}
Summary : A compositor for X11, active fork
License : MPL-2.0 and MIT
URL     : https://github.com/yshui/compton
Source0 : https://github.com/yshui/compton/archive/%{tag}.tar.gz
Source1 : compton.conf
BuildRequires:		gcc,make,cmake
BuildRequires:		pkgconfig(x11),pkgconfig(xext),pkgconfig(xproto),pkgconfig(xcb),pkgconfig(xcb-damage),pkgconfig(xcb-xfixes),pkgconfig(xcb-shape),pkgconfig(xcb-renderutil)
BuildRequires:		pkgconfig(xcb-render),pkgconfig(xcb-randr),pkgconfig(xcb-composite),pkgconfig(xcb-image),pkgconfig(xcb-present),pkgconfig(xcb-xinerama)
BuildRequires: 		pkgconfig(pixman-1),pkgconfig(dbus-1),pkgconfig(libconfig),pkgconfig(libxdg-basedir),pkgconfig(gl),pkgconfig(libpcre)
BuildRequires:		libev-devel,uthash-devel
BuildRequires:		asciidoc,desktop-file-utils,meson,git,asciidoc
Requires:		pkgconfig(pixman-1)
Requires:		hicolor-icon-theme

%if 0%{?mageia}
Requires: lib64ev4
%else
Requires: libev,xorg-x11-utils
%endif

%description
Compton is a compositor for X, and a fork of xcompmgr-dana.
This one is the active fork (yshui/compton) of the original chjj/compton

%prep
%setup -q -n %{name}-%{shortversion}

%build
mkdir -p build
meson -D build_docs=true -D b_ndebug=true . build
ninja -v -C build

%install
meson configure -Dprefix=%{_prefix} build
DESTDIR="%{buildroot}" ninja -C build install
install -Dm644 %{SOURCE1} "%{buildroot}/etc/xdg/compton.conf"

%check
ninja -C build test
desktop-file-validate %{buildroot}/%{_datadir}/applications/compton.desktop

%post
/bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null || :

%postun
if [ $1 -eq 0 ] ; then
    /bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null
    /usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
fi

%posttrans
/usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :

%files
/etc/xdg/%{name}.conf
%{_bindir}/%{name}
%{_bindir}/%{name}-convgen.py
%{_bindir}/%{name}-trans
%{_mandir}/man1/compton.1*
%{_mandir}/man1/compton-trans.1*
%{_datadir}/icons/hicolor/scalable/apps/compton.svg
%{_datadir}/icons/hicolor/48x48/apps/compton.png
%{_datadir}/applications/compton.desktop
%license COPYING
%doc README.md compton.sample.conf

%changelog
* Mon Sep 23 2019 Víctor González - 7.4.0-1
- Bump version to 7.4
* Mon Sep 16 2019 Víctor González - 7.3.0-2
- Add mageia chroot
- Fix error when updating to 7.3 tarball
* Sat Aug 24 2019 Víctor González - 7.3.0-1
- Bump version to 7.3
* Tue Jul 30 2019 Víctor González - 7.0.0-1
- Change source to yshui/compton
* Fri Dec 15 2017 Dominik Schubert - 0.1-0.1.20170430git316eac0
- Initial packaging