File kando.spec of Package kando

#
# spec file for package kando
#
# Copyright (c) 2025 SUSE LLC
#
# 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.

Name:           kando
Version:        2.0.0
Release:        0
Summary:        Cross-platform pie menu for your desktop
License:        MIT
Group:          System/GUI/Other
URL:            https://kando.menu/
Source0:        https://github.com/kando-menu/kando/archive/refs/tags/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
Source1:        node_modules.obscpio
Source2:        dbus-final-0.0.0+git3e43f60.obscpio
Patch0:         fix-git-deps.patch
%include %{_sourcedir}/node_modules.spec.inc
BuildRequires:  nodejs >= 18
BuildRequires:  npm
BuildRequires:  local-npm-registry
BuildRequires:  fdupes
BuildRequires:  git-core
BuildRequires:  cmake
BuildRequires:  gcc-c++
BuildRequires:  python3
# Runtime dependencies for Electron apps
Requires:       libnotify4
Requires:       libXScrnSaver1
Requires:       libXtst6

%description
Kando is a cross-platform pie menu for your desktop that offers an
unconventional, fast, highly efficient, and fun way of interacting with
your computer. You can use Kando to launch applications, simulate keyboard
shortcuts, open files, and much more.

Key features:
- Works on Windows, macOS, and Linux
- Supports mouse, stylus, touch, or controller input
- Completely free and open source

%prep
%setup -q
%patch -P 0 -p1

# Install all node_modules from vendored tarballs using local-npm-registry
# The patch replaced @electron/node-gyp and drag-drop-touch git URLs with npm registry versions
# dbus-final was removed from package.json and will be installed manually
local-npm-registry %{_sourcedir} install --include=dev --ignore-scripts

# Manually install dbus-final from obs_scm generated CPIO since it's not published to npm
mkdir -p node_modules/dbus-final
cd node_modules/dbus-final
cpio -idv < %{SOURCE2}
cd ../..

%build
# Build the application
npm run make

%install
# Install Electron app (adjust based on actual build output structure)
install -d %{buildroot}%{_datadir}/%{name}
cp -a out/make/zip/linux/x64/%{name}-linux-x64-%{version}/* %{buildroot}%{_datadir}/%{name}/

# Create wrapper script
install -d %{buildroot}%{_bindir}
cat > %{buildroot}%{_bindir}/%{name} << 'EOF'
#!/bin/bash
exec %{_datadir}/%{name}/%{name} "$@"
EOF
chmod +x %{buildroot}%{_bindir}/%{name}

# Install desktop file (if available in source)
if [ -f assets/%{name}.desktop ]; then
    install -d %{buildroot}%{_datadir}/applications
    install -m 644 assets/%{name}.desktop %{buildroot}%{_datadir}/applications/
fi

# Install icon (if available in source)
if [ -f assets/icon.png ]; then
    install -d %{buildroot}%{_datadir}/icons/hicolor/256x256/apps
    install -m 644 assets/icon.png %{buildroot}%{_datadir}/icons/hicolor/256x256/apps/%{name}.png
fi

%fdupes %{buildroot}%{_datadir}/%{name}

%files
%license LICENSE.md
%doc README.md
%{_bindir}/%{name}
%{_datadir}/%{name}
%if 0%{?suse_version}
%dir %{_datadir}/icons/hicolor
%dir %{_datadir}/icons/hicolor/256x256
%dir %{_datadir}/icons/hicolor/256x256/apps
%endif
%{_datadir}/applications/%{name}.desktop
%{_datadir}/icons/hicolor/256x256/apps/%{name}.png

%changelog
openSUSE Build Service is sponsored by