File hhd.spec of Package hhd
#
# spec file for package hhd
#
# Copyright (c) 2025 SUSE LLC and contributors
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
Name: hhd
Version: 4.0.1
Release: 0
Summary: A tool for configuring handheld devices
License: LGPL-2.1-or-later
URL: https://github.com/hhd-dev/hhd
Source: https://github.com/hhd-dev/hhd/archive/refs/tags/v%{version}.tar.gz
BuildArch: noarch
BuildRequires: systemd-rpm-macros
BuildRequires: udev
Requires: udev
Requires: python3-hhd = %{version}
%description
Handheld Daemon contains utilities for managing handheld devices.
Features include TDP controls, controller remappings, and gamescope
session management. This is done through a plugin system and a
HTTP/D-Bus daemon, which exposes the settings of the plugins in a
UI-agnostic way.
%package -n python-hhd
Summary: Python hhd module
BuildRequires: %{python_module pip}
BuildRequires: %{python_module setuptools}
BuildRequires: %{python_module wheel}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
BuildRequires: %{python_module Babel}
Requires: python-gobject
Requires: python-PyYAML
Requires: python-xlib
Requires: python-dbus-python
Requires: python-evdev
Requires: python-pyroute2
Requires: python-pyserial
Requires: python-rich
Requires: python-setuptools
Requires: hhd
Requires: python3
Requires(post): update-alternatives
Requires(postun): update-alternatives
%python_subpackages
%description -n python-hhd
This package contains a Python hhd module.
%prep
%autosetup -p1
%build
python3 -m babel.messages.frontend compile -D hhd -d ./i18n
python3 -m babel.messages.frontend compile -D adjustor -d ./i18n || true
cp -rf ./i18n/* ./src/hhd/i18n
%pyproject_wheel
%install
%pyproject_install
find %{buildroot} -name '*.pyc' -delete
%python_expand %fdupes %{buildroot}%{$python_sitelib}
%python_clone -a %{buildroot}%{_bindir}/hhd
%python_clone -a %{buildroot}%{_bindir}/hhd.contrib
%python_clone -a %{buildroot}%{_bindir}/hhd.steamos
%python_clone -a %{buildroot}%{_bindir}/hhdctl
# udev rules / hwdb
install -Dm0644 usr/lib/udev/rules.d/83-%{name}.rules \
%{buildroot}%{_udevrulesdir}/83-%{name}.rules
# Prefer the macro if available, fallback would be /usr/lib/udev/hwdb.d
%{!?_udevhwdbdir:%global _udevhwdbdir /usr/lib/udev/hwdb.d}
install -Dm0644 usr/lib/udev/hwdb.d/83-%{name}.hwdb \
%{buildroot}%{_udevhwdbdir}/83-%{name}.hwdb
# systemd units
install -Dm0644 usr/lib/systemd/system/%{name}@.service \
%{buildroot}%{_unitdir}/%{name}@.service
install -Dm0644 usr/lib/systemd/system/%{name}.service \
%{buildroot}%{_unitdir}/%{name}.service
%pre -n hhd
%service_add_pre %{name}.service
%post -n hhd
%service_add_post %{name}.service
%preun -n hhd
%service_del_preun %{name}.service
%postun -n hhd
%service_del_postun %{name}.service
%post -n python-hhd
%python_install_alternative hhd hhd.contrib hhd.steamos hhdctl
%postun -n python-hhd
%python_uninstall_alternative hhd hhd.contrib hhd.steamos hhdctl
%files -n hhd
%license LICENSE
%doc readme.md
%{_udevrulesdir}/83-%{name}.rules
%{_udevhwdbdir}/83-%{name}.hwdb
%{_unitdir}/%{name}@.service
%{_unitdir}/%{name}.service
%files %{python_files}
%{python_sitelib}/hhd*
%python_alternative hhd
%python_alternative hhd.contrib
%python_alternative hhd.steamos
%python_alternative hhdctl
%{python_sitelib}/adjustor*
%changelog