# Maintainer: David Heinemeier Hansson <david@hey.com>

# TMOG publishes no source and no AUR package, so this repackages the vendor's
# Linux tarball. That tarball is 8 MB against the system Qt, where the AppImage
# is 55 MB of bundled Qt -- the same binary, minus a second copy of what
# Omarchy already installs.
#
# .omarchy/upstream.sh rewrites the pkgver and sha256 below when
# the Linux x86_64 release manifest moves, taking the checksum from the .sha256
# sidecar tmog.org publishes beside each versioned tarball.

pkgname=tmog-bin
pkgver=1.0.0
pkgrel=1
pkgdesc="Native system monitor and task manager"
arch=('x86_64')
url="https://tmog.org/"
license=('LicenseRef-proprietary')

depends=(
  'gcc-libs'
  'glibc'
  'hicolor-icon-theme'
  'qt6-base'
  'qt6-multimedia'
  'qt6-svg'
  # Omarchy is a Wayland desktop, so the Wayland platform plugin is what this
  # actually runs on; without it Qt falls back to xcb under XWayland.
  'qt6-wayland'
  'systemd-libs'
)

provides=('tmog')
conflicts=('tmog')

# Upstream ships a stripped release build and no debug symbols to split out.
options=('!debug' '!strip')

_srcdir="TaskManagerOG-${pkgver}-linux-x86_64"

source=("${pkgname}-${pkgver}.tar.gz::${url}rtm/downloads/${_srcdir}.tar.gz")
sha256sums=('a147c613d4a6f5c0ec16eaf52965593de523f9f0231e09c241460cc63352f325')

package() {
  cd "${_srcdir}"

  install -Dm755 bin/tmog-task-manager "${pkgdir}/usr/bin/tmog-task-manager"

  install -Dm644 share/applications/com.tmog.taskmanager.desktop \
    "${pkgdir}/usr/share/applications/com.tmog.taskmanager.desktop"
  install -Dm644 share/metainfo/com.tmog.taskmanager.metainfo.xml \
    "${pkgdir}/usr/share/metainfo/com.tmog.taskmanager.metainfo.xml"
  install -Dm644 share/pixmaps/tmog-task-manager.png \
    "${pkgdir}/usr/share/pixmaps/tmog-task-manager.png"

  local icon
  for icon in share/icons/hicolor/*/apps/tmog-task-manager.png; do
    install -Dm644 "$icon" "${pkgdir}/usr/${icon}"
  done

  # Upstream files its licence texts under share/doc, which is Debian's layout.
  # On Arch they belong with the package's licences.
  local doc
  for doc in share/doc/tmog/* share/doc/taskmanagerog/copyright; do
    install -Dm644 "$doc" "${pkgdir}/usr/share/licenses/${pkgname}/${doc##*/}"
  done
}
