%global debug_package %{nil} %global buildsubdir %{name}-%{version}-build %global pyproject_bytecompilation %{nil} %global __brp_python_bytecompile %{nil} Name: keymasq Version: 0.21.0 Release: 1%{?dist} Summary: Input remapper for keyboards, mice, and game controllers, with layered profiles and macros License: MIT URL: https://keymasq.tools Source0: %{name}-%{version}.tar.gz BuildArch: noarch BuildRequires: desktop-file-utils BuildRequires: pyproject-rpm-macros BuildRequires: python3-devel BuildRequires: systemd-rpm-macros Requires: acl Requires: gtk4 Requires: libxkbcommon Requires: libadwaita Requires: polkit Requires: systemd Recommends: slurp Recommends: python3dist(uvloop) %generate_buildrequires %pyproject_buildrequires %description Input remapper for keyboards, mice, and game controllers, with layered profiles and macros. %prep %autosetup -n %{buildsubdir} %build %pyproject_wheel %install %pyproject_install find %{buildroot}%{python3_sitelib} -type d -name __pycache__ -prune -exec rm -rf {} + find %{buildroot}%{python3_sitelib} -type f -name '*.py[co]' -delete %pyproject_save_files keymasq sed -i '/__pycache__/d; /\.py[co]/d' %{pyproject_files} install -Dpm0644 systemd/keymasqd.service %{buildroot}%{_unitdir}/keymasqd.service install -Dpm0644 systemd/keymasq-hardware@.service %{buildroot}%{_unitdir}/keymasq-hardware@.service install -Dpm0644 systemd/keymasq-session.service %{buildroot}%{_userunitdir}/keymasq-session.service install -Dpm0644 sysusers.d/keymasq.conf %{buildroot}%{_sysusersdir}/keymasq.conf install -Dpm0644 tmpfiles.d/keymasq.conf %{buildroot}%{_tmpfilesdir}/keymasq.conf install -Dpm0644 udev/91-keymasq-acl.rules %{buildroot}%{_udevrulesdir}/91-keymasq-acl.rules install -Dpm0644 udev/99-keymasq-hide-grabbed.rules %{buildroot}%{_udevrulesdir}/99-keymasq-hide-grabbed.rules install -Dpm0644 polkit/49-keymasq-hardware.rules %{buildroot}%{_datadir}/polkit-1/rules.d/49-keymasq-hardware.rules install -Dpm0644 assets/tools.keymasq.keymasq.desktop %{buildroot}%{_datadir}/applications/tools.keymasq.keymasq.desktop install -Dpm0644 assets/tools.keymasq.keymasq.metainfo.xml %{buildroot}%{_datadir}/metainfo/tools.keymasq.keymasq.metainfo.xml install -Dpm0644 assets/tools.keymasq.keymasq.svg %{buildroot}%{_datadir}/icons/hicolor/scalable/apps/tools.keymasq.keymasq.svg install -Dpm0644 LICENSE %{buildroot}%{_datadir}/licenses/%{name}/LICENSE install -Dpm0644 README.md %{buildroot}%{_docdir}/%{name}/README.md install -Dpm0644 examples/security.toml %{buildroot}%{_sysconfdir}/keymasq/security.toml mkdir -p %{buildroot}%{_datadir}/gnome-shell/extensions/gnome-bridge@keymasq.tools cp -a gnome-extension/gnome-bridge@keymasq.tools/. %{buildroot}%{_datadir}/gnome-shell/extensions/gnome-bridge@keymasq.tools/ for size in 16 22 24 32 48 64 128 256 512; do install -Dpm0644 assets/icons/tools.keymasq.keymasq-${size}.png %{buildroot}%{_datadir}/icons/hicolor/${size}x${size}/apps/tools.keymasq.keymasq.png done desktop-file-install --dir %{buildroot}%{_datadir}/applications assets/tools.keymasq.keymasq.desktop %post #!/bin/sh set -e # The package ships no bytecode and rpmbuild can pin source mtimes, so bytecode # that root processes wrote for the previous version would still look current. for keymasq_dir in /usr/lib/python3*/site-packages/keymasq; do [ -d "$keymasq_dir" ] || continue find "$keymasq_dir" -name __pycache__ -type d -prune -exec rm -rf {} + 2>/dev/null || true done # Apply packaged sysusers/tmpfiles data when the host allows it. systemd-sysusers /usr/lib/sysusers.d/keymasq.conf >/dev/null 2>&1 || true systemd-tmpfiles --create /usr/lib/tmpfiles.d/keymasq.conf >/dev/null 2>&1 || true # Reload udev rules udevadm control --reload-rules 2>/dev/null || true udevadm trigger --subsystem-match=input --sysname-match='event*' --action=change 2>/dev/null || true udevadm trigger --subsystem-match=input --sysname-match='js*' --action=change 2>/dev/null || true udevadm trigger --subsystem-match=misc --sysname-match=uinput --action=change 2>/dev/null || true udevadm trigger --subsystem-match=hidraw --action=change 2>/dev/null || true udevadm settle --timeout=30 2>/dev/null || true # Reload systemd systemctl daemon-reload 2>/dev/null || true # On RPM upgrades, $1 is greater than 1. Restart only an already-running daemon; # do not start keymasqd on first install. if [ "${1:-1}" -gt 1 ]; then systemctl try-restart keymasqd.service 2>/dev/null || true fi # Bump mtimes so desktop environments that watch icon/theme changes # can notice the new launcher assets without a full session restart. find /usr/share/icons/hicolor -path '*/apps/tools.keymasq.keymasq.*' -exec touch {} + >/dev/null 2>&1 || true touch /usr/share/icons/hicolor 2>/dev/null || true touch /usr/share/applications/tools.keymasq.keymasq.desktop 2>/dev/null || true echo "" if [ "${1:-1}" -gt 1 ]; then echo "Keymasq has been upgraded!" else echo "Keymasq has been installed!" fi echo "" echo "To use Keymasq:" echo " 1. Enable the daemon:" echo " sudo systemctl enable --now keymasqd" echo "" echo " 2. Enable the session manager:" echo " systemctl --user enable --now keymasq-session" echo "" echo " 3. Launch Keymasq:" echo " keymasq" echo "" echo "Security policy: /etc/keymasq/security.toml" # The AppImage's /etc units override this package's units. if [ -e /opt/keymasq/version ]; then echo "" >&2 echo "Keymasq AppImage integration in /opt/keymasq overrides this package." >&2 echo "To switch to this package, run as your desktop user:" >&2 echo " /opt/keymasq/bin/keymasq --uninstall" >&2 echo " sudo systemctl enable --now keymasqd" >&2 echo " systemctl --user enable --now keymasq-session" >&2 fi %preun #!/bin/sh set -e # On RPM upgrades, $1 is non-zero because another version of the package will # remain installed after this scriptlet completes. Avoid stopping/disabling the # service in that case. if [ "${1:-0}" -eq 0 ]; then # Stop keymasqd and finish hardware recovery while the helper is installed. # If recovery is incomplete, the helper fails and RPM keeps the package. /usr/bin/keymasq-helper prepare-removal systemctl disable keymasqd.service 2>/dev/null || true systemctl daemon-reload 2>/dev/null || true fi %postun #!/bin/sh set -e # Reload udev after rule removal udevadm control --reload-rules 2>/dev/null || true # Reload systemd after unit removal systemctl daemon-reload 2>/dev/null || true # On RPM upgrades, $1 is non-zero because another version remains installed # after this scriptlet runs. Skip the removal message in that case. if [ "${1:-0}" -ne 0 ]; then exit 0 fi # Bytecode written at runtime is not owned by the package and keeps its # directories from being removed. for keymasq_dir in /usr/lib/python3*/site-packages/keymasq; do [ -d "$keymasq_dir" ] || continue find "$keymasq_dir" -name __pycache__ -type d -prune -exec rm -rf {} + 2>/dev/null || true find "$keymasq_dir" -depth -type d -empty -delete 2>/dev/null || true done # Let the remaining udev policy recompute owner, group, and mode. udevadm trigger --action=change --subsystem-match=input 2>/dev/null || true udevadm trigger --action=change --sysname-match=uinput 2>/dev/null || true echo "" echo "Keymasq has been removed." echo "" echo "The 'keymasq' user and group have been preserved." echo "To remove them:" echo " sudo userdel keymasq" echo " sudo groupdel keymasq" echo "" echo "Configuration files remain in: /etc/keymasq/" %files -f %{pyproject_files} %{_bindir}/keymasq %{_bindir}/keymasqd %{_bindir}/keymasq-helper %{_bindir}/keymasq-session %{_unitdir}/keymasqd.service %{_unitdir}/keymasq-hardware@.service %{_userunitdir}/keymasq-session.service %{_sysusersdir}/keymasq.conf %{_tmpfilesdir}/keymasq.conf %{_udevrulesdir}/91-keymasq-acl.rules %{_udevrulesdir}/99-keymasq-hide-grabbed.rules %{_datadir}/polkit-1/rules.d/49-keymasq-hardware.rules %{_datadir}/applications/tools.keymasq.keymasq.desktop %{_datadir}/metainfo/tools.keymasq.keymasq.metainfo.xml %{_datadir}/icons/hicolor/scalable/apps/tools.keymasq.keymasq.svg %{_datadir}/icons/hicolor/16x16/apps/tools.keymasq.keymasq.png %{_datadir}/icons/hicolor/22x22/apps/tools.keymasq.keymasq.png %{_datadir}/icons/hicolor/24x24/apps/tools.keymasq.keymasq.png %{_datadir}/icons/hicolor/32x32/apps/tools.keymasq.keymasq.png %{_datadir}/icons/hicolor/48x48/apps/tools.keymasq.keymasq.png %{_datadir}/icons/hicolor/64x64/apps/tools.keymasq.keymasq.png %{_datadir}/icons/hicolor/128x128/apps/tools.keymasq.keymasq.png %{_datadir}/icons/hicolor/256x256/apps/tools.keymasq.keymasq.png %{_datadir}/icons/hicolor/512x512/apps/tools.keymasq.keymasq.png %{_datadir}/gnome-shell/extensions/gnome-bridge@keymasq.tools/ %{_datadir}/licenses/%{name}/LICENSE %{_docdir}/%{name}/README.md %config(noreplace) %{_sysconfdir}/keymasq/security.toml %changelog * Wed Apr 22 2026 nyrda - $VERSION-$RELEASE - Local Fedora build