File btnx.spec of Package btnx
# vim: set ts=4 sw=4 et:
%if 0%{?suse_version} >= 1210
%define has_systemd 1
%else
%define has_systemd 0
%endif
Name: btnx
Version: 0.4.12.1
Release: 0
Summary: Button Extension
Source: %{name}-%{version}.tar.bz2
Source1: %{name}.service
URL: https://github.com/cdobrich/btnx
Group: Hardware/Other
License: GPL-2.0
BuildRoot: %{_tmppath}/build-%{name}-%{version}
BuildRequires: libdaemon-devel
BuildRequires: gcc make glibc-devel pkgconfig
BuildRequires: autoconf automake libtool
%if %{has_systemd}
BuildRequires: systemd-rpm-macros
%endif
Requires: btnx-config
%{?systemd_requires}
%description
btnx is a daemon that enables rerouting of mouse button events through uinput
as keyboard and other mouse button combinations.
For example, you can configure an extra mouse button to send a Ctrl+Alt+Right
command to switch workspaces. This is especially useful for mice with more
buttons than Gnome or KDE can properly handle, or mice that need evdev and a
100 step howto to register button events at all.
btnx integrates revoco, a program that allows changing MX Revolution's wheel
behavior.
%prep
%setup -q
%build
echo "libdaemon lib flags: $(pkg-config --libs libdaemon)"
export init_scripts_path=/etc/init.d
export config_path="%{_sysconfdir}/btnx"
export init_tool=no
export LDFLAGS="$LDFLAGS -Wl,--no-as-needed"
export SUSE_ASNEEDED=0
%configure
%__make %{?_smp_flags}
%install
export init_scripts_path=/etc/init.d
export config_path="%{_sysconfdir}/btnx"
export init_tool=no
%makeinstall
touch "%{buildroot}%{_sysconfdir}/btnx/btnx_config"
# install systemd.service file
%if %{has_systemd}
%__rm %{buildroot}/etc/init.d/btnx
install -D -m 644 %{S:1} %{buildroot}%{_unitdir}/%{name}.service
%__ln_s /usr/sbin/btnx %{buildroot}%{_sbindir}/rcbtnx
%else
%__install -d "%{buildroot}/usr/sbin"
%__ln_s ../../etc/init.d/btnx "%{buildroot}/usr/sbin/rcbtnx"
%endif
%pre
%if %{has_systemd}
%service_add_pre %{name}.service
%endif
%post
%if %{has_systemd}
%service_add_post %{name}.service
%else
%{fillup_and_insserv -f btnx}
%endif
%preun
%if %{has_systemd}
%service_del_preun %{name}.service
%else
%stop_on_removal btnx
%endif
%postun
%if %{has_systemd}
%service_del_postun %{name}.service
%else
%restart_on_update btnx
%insserv_cleanup
%endif
%files
%defattr(-,root,root)
%doc AUTHORS ChangeLog COPYING NEWS README.md
%dir %{_sysconfdir}/btnx
%attr(0644,root,root) %config(noreplace) %{_sysconfdir}/btnx/btnx_config
%config(noreplace) %{_sysconfdir}/btnx/events
%{_sbindir}/btnx
%{_sbindir}/rcbtnx
%if %{has_systemd}
%{_unitdir}/%{name}.service
%else
/etc/init.d/btnx
%endif
%changelog