%global debug_package %{nil}
%define _userunitdir /usr/lib/systemd/user
Name:           dotool
Version:        1.5
Release:        5.1
Summary:        Command to simulate input anywhere

License:        GPL3
URL:            https://git.sr.ht/~geb/dotool
Source0:        %{name}-%{version}.tar.gz
Source1:        vendor.tar.gz
Source2:        dotoold.service

%global         debug_package %{nil}

BuildRequires:  golang >= 1.19, libxkbcommon-devel, scdoc
Requires:       libxkbcommon

%description
dotool is a tool to simulate input anywhere.

%prep
%setup -q
tar -xzf %{SOURCE1}

%build
go build -mod=vendor -ldflags "-X main.Version=%{version}"

%install
mkdir -p %{buildroot}%{_bindir}
mkdir -p %{buildroot}%{_sysconfdir}/udev/rules.d/
mkdir -p %{buildroot}%{_userunitdir}
install -Dm755 dotool dotoolc dotoold %{buildroot}%{_bindir}/
install -Dm644 "80-dotool.rules" %{buildroot}%{_sysconfdir}/udev/rules.d/80-dotool.rules
install -Dm644 %{SOURCE2} %{buildroot}%{_userunitdir}/dotoold.service

mkdir -p %{buildroot}%{_mandir}/man1
scdoc < doc/dotool.1.scd > %{buildroot}%{_mandir}/man1/dotool.1

%files
%{_bindir}/dotool
%{_bindir}/dotoolc
%{_bindir}/dotoold
%dir %{_sysconfdir}/udev
%dir %{_sysconfdir}/udev/rules.d
%{_sysconfdir}/udev/rules.d/80-dotool.rules
%{_userunitdir}/dotoold.service
%{_mandir}/man1/dotool.1*

%post
if [ ! 0%{?suse_version} ]; then
    /usr/bin/udevadm control --reload
    /usr/bin/udevadm trigger
fi

%changelog
* Tue Jun 11 2024 John Gebbie <me@johngebbie.com> - 1.5
- The selecting of the fewest modifiers for simulating keys.
* Tue Apr 30 2024 smallcms <smallcms@gmail.com> - 1.4
- Initial package version for Fedora.