# Description: An i3-compatible wayland compositor.
# URL: https://swaywm.org/
# Maintainer: Tim Biermann, tbier at posteo dot de
# Depends on: basu json-c pango wlroots
# Optional: gdk-pixbuf scdoc seatd

name=sway
version=1.12
release=1
source=(https://github.com/swaywm/sway/archive/$version/$name-$version.tar.gz
  8920.patch
  8405.patch)

build() {
  patch -Np1 -d $name-$version -i $SRC/8920.patch

  prt-get isinst bash-completion || PKGMK_SWAY+=' -D bash-completions=false'
  prt-get isinst zsh || PKGMK_SWAY+=' -D zsh-completions=false'

  meson setup $name-$version build $PKGMK_SWAY \
    --prefix=/usr \
    --buildtype=plain \
    --wrap-mode nodownload \
    -D b_lto=true \
    -D b_pie=true \
    -D tray=enabled \
    -D sd-bus-provider=basu \
    -D fish-completions=false \
    -D werror=false
  meson compile -C build
  DESTDIR=$PKG meson install -C build

  # needs CONFIG_*_FS_SECURITY to work
  # https://github.com/swaywm/sway/pull/6994
  setcap 'cap_sys_nice=eip' $PKG/usr/bin/sway || true
}
