# Maintainer: Brett Cornwall <ainola@archlinux.org>
# Maintainer: Robin Candau <antiz@archlinux.org>
# Contributor: Maxim Baz <archlinux at maximbaz dot com>
# Contributor: Alexander F. Rødseth <xyproto@archlinux.org>

pkgname=sway
pkgver=1.12
epoch=1
pkgrel=4
pkgdesc='Tiling Wayland compositor and replacement for the i3 window manager'
arch=(x86_64)
url='https://swaywm.org/'
license=(MIT)
depends=(
  'cairo'
  'gdk-pixbuf2'
  'libevdev.so'
  'libinput'
  'libjson-c.so'
  'libpixman-1.so'
  'libudev.so'
  'libwayland-server.so'
  'libxcb'
  'libxkbcommon.so'
  'pango'
  'pcre2'
  'ttf-font'
  'wlroots0.20'
  'xcb-util-wm'
)
makedepends=(git meson ninja scdoc wayland-protocols)
provides=('wayland-compositor')
backup=(
  etc/sway/config
  etc/sway/config.d/50-systemd-user.conf
)
optdepends=(
  'brightnessctl: Brightness adjustment tool used in the default configuration'
  'foot: Terminal emulator used in the default configuration'
  'grim: Screenshot utility used in the default configuration'
  'i3status: Status line generation'
  'libpulse: Volume adjustment tool (pactl) used in the default configuration'
  'mako: Lightweight notification daemon'
  'playerctl: Media player controller used in the default configuration'
  'polkit: System privilege control. Required if not using seatd service'
  'swaybg: Wallpaper tool for sway'
  'sway-contrib: Collection of user-contributed scripts for sway'
  'swayidle: Idle management daemon'
  'swaylock: Screen locker'
  'waybar: Highly customizable bar'
  'wmenu: Application launcher used in default config'
  'xorg-xwayland: X11 support'
  'xdg-desktop-portal-gtk: Default xdg-desktop-portal for file picking'
  'xdg-desktop-portal-wlr: xdg-desktop-portal backend'
)
source=("git+https://github.com/swaywm/sway.git#tag=$pkgver?signed"
  "50-systemd-user.conf"
  "sway-portals.conf"
  "remove_git_version_format.patch")
install=sway.install
sha512sums=('03a71801d2345d98e8b7618356a8fb1259b7f5a3d98b22d4d97d7b5a8724e696a0596b311e4792772618296baa8e95cd6db5d4650b61fc3fb6d07e59e5ebbb57'
  'd5f9aadbb4bbef067c31d4c8c14dad220eb6f3e559e9157e20e1e3d47faf2f77b9a15e52519c3ffc53dc8a5202cb28757b81a4b3b0cc5dd50a4ddc49e03fe06e'
  '4f9576b7218aef8152eb60e646985e96b13540b7a4fd34ba68fdc490199cf7a7b46bbee85587e41bffe81fc730222cf408d5712e6251edc85a0a0b0408c1a2df'
  'c3a450d3411b5ec6d4bcb485744213a49ee95698d3237804a7bf93258e091753de4666a2245ffe74129151749ec296be4d7741814380133b673f3fd2ec71932b')
validpgpkeys=('34FF9526CFEF0E97A340E2E40FDE7BE0E88F5E48' # Simon Ser
  '9DDA3B9FA5D58DD5392C78E652CB6609B22DA89A')            # Drew DeVault

prepare() {
  cd "$pkgname"
  # Patch meson.build to not use git version format (despite `git` presence in the build env)
  patch -Np1 -i "$srcdir/remove_git_version_format.patch"
}

build() {
  mkdir -p build
  arch-meson build "$pkgname" -D sd-bus-provider=libsystemd -D werror=false -D b_ndebug=true
  ninja -C build
}

package() {
  DESTDIR="$pkgdir" ninja -C build install
  install -Dm644 "$pkgname/LICENSE" "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
  install -Dm644 50-systemd-user.conf -t "$pkgdir/etc/sway/config.d/"
  install -Dm644 sway-portals.conf "$pkgdir/usr/share/xdg-desktop-portal/sway-portals.conf"
}

# vim: ts=2 sw=2 et
