%global debug_package %{nil}

Name:           bucklespring
Version:        1.5.100
Release:        3%{?dist}
Summary:        Nostalgia bucklespring keyboard sound

License:        GPLv2
URL:            https://github.com/daniviga/bucklespring/
Source0:        %{name}-%{version}.tar.gz

BuildRequires:  sed
BuildRequires:  gcc
BuildRequires:  openal-soft-devel
BuildRequires:  alure-devel
BuildRequires:  libXtst-devel
BuildRequires:  libinput-devel
BuildRequires:  systemd-devel
BuildRequires:  desktop-file-utils

%description
Fork of https://github.com/zevv/bucklespring

Copyright 2016 Ico Doornekamp

Bucklespring runs as a background process and plays back the sound of each key pressed and released on your keyboard, just as if you were using an IBM Model-M.
The sound of each key has carefully been sampled, and is played back while simulating the proper distance and direction for a realistic 3D sound palette of pure nostalgic bliss.

To temporarily silence bucklespring, for example to enter secrets, press ScrollLock twice (but be aware that those ScrollLock events are delivered to the application); same to unmute.
The keycode for muting can be changed with the -m option. Use keycode 0 to disable the mute function.

%package wayland
Summary:    Wayland support for Bucklespring
Requires:       %{name}%{?_isa} = %{version}-%{release}

%description wayland
Wayland support for Bucklespring

%prep
%autosetup
sed -i 's|./wav/001|/usr/share/bucklespring/001|g' Makefile

%build
make libinput=1
mv buckle buckle-wayland
make clean
make

%install
install -m 755 -d %{buildroot}%{_bindir}
install -m 755 buckle %{buildroot}%{_bindir}/buckle
install -m 755 buckle-wayland %{buildroot}%{_bindir}/buckle-wayland
install -m 755 -d wav %{buildroot}%{_datadir}/bucklespring
cp -R wav/* %{buildroot}%{_datadir}/bucklespring
desktop-file-install                                    \
--dir=%{buildroot}%{_datadir}/applications              \
buckle.desktop
desktop-file-install                                    \
--dir=%{buildroot}%{_datadir}/applications              \
buckle-wayland.desktop

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

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

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

%post wayland
update-desktop-database &> /dev/null || :
touch --no-create %{_datadir}/icons/hicolor &>/dev/null || :

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

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

%files
%license LICENSE
%{_bindir}/buckle
%{_datadir}/bucklespring
%{_datadir}/applications/buckle.desktop

%files wayland
%{_bindir}/buckle-wayland
%{_datadir}/applications/buckle-wayland.desktop

%changelog
* Sat Oct 9 2021 Daniele Viganò <daniele@vigano.me> - 1.5.100
- Add buckle-wayland subpackage

* Fri May 14 2021 Daniele Viganò <daniele@vigano.me> - 1.5.99
- Release 1.5.0

* Mon Nov 5 2018 Daniele Viganò <daniele@vigano.me> - 1.4.99
- First release