# Maintainer: Gabriel Aramburu <aramburu.gabriel@gmail.com>

pkgname=omakeyboard
pkgver=0.1.0
pkgrel=1
pkgdesc='Keyboard remapping and shortcuts for Omarchy, built with Qt Quick'
arch=('x86_64' 'aarch64')
url='https://github.com/gabamnml/omakeyboard'
license=('MIT')
install='omakeyboard.install'
# The build already strips nothing useful, and the Omarchy repository's own
# Qt applications ship without a separate debug package.
options=('!debug')

# Every name this app has shipped under, so pacman swaps the old one out in a
# single step instead of leaving two packages that own the same files.
replaces=('omakbrds' 'omakeyboards')
conflicts=('omakbrds' 'omakeyboards')

# Everything here is part of an Omarchy system already: Qt for the interface,
# libxkbcommon for the keymaps, lua to read the Hyprland configuration, and
# Hyprland itself to apply changes. No input daemon is involved.
depends=(
  'hicolor-icon-theme'
  'hyprland'
  'libxkbcommon'
  'lua'
  'qt6-base'
  'qt6-declarative'
  'qt6-wayland'
)
makedepends=(
  'gcc'
  'make'
  'qt6-base'
  'qt6-declarative'
)
# The interface check renders the app offscreen, so the tests need Qt Quick
# as well as Qt itself.
checkdepends=(
  'qt6-base'
  'qt6-declarative'
)
optdepends=('xdg-desktop-portal: follow the desktop dark mode and text scale, and use the desktop file chooser when exporting or importing')

# The Omarchy repository builds a published tag, never a working tree. Fill
# the checksum in with `makepkg -g` once the tag exists.
source=("$pkgname-$pkgver.tar.gz::https://github.com/gabamnml/omakeyboard/archive/refs/tags/v$pkgver.tar.gz")
sha256sums=('SKIP')

build() {
  cd "$srcdir/$pkgname-$pkgver"
  ./bin/build
}

check() {
  cd "$srcdir/$pkgname-$pkgver"
  ./bin/test
}

package() {
  cd "$srcdir/$pkgname-$pkgver"

  install -Dm755 build/omakeyboard "$pkgdir/usr/bin/omakeyboard"
  install -Dm644 packaging/omakeyboard.desktop \
    "$pkgdir/usr/share/applications/omakeyboard.desktop"
  # One raster per size the hicolor theme declares, generated from
  # resources/omakeyboard-logo.png by resources/make-icons.sh.
  for size in 16 22 24 32 48 64 96 128 256 512; do
    install -Dm644 "resources/icons/${size}.png" \
      "$pkgdir/usr/share/icons/hicolor/${size}x${size}/apps/omakeyboard.png"
  done
  install -Dm644 resources/wordmark.svg \
    "$pkgdir/usr/share/omakeyboard/wordmark.svg"
  install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
  install -Dm644 README.md "$pkgdir/usr/share/doc/$pkgname/README.md"
}
