# 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 xorg-libevdev
# Optional: gdk-pixbuf scdoc seatd

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

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

  prt-get isinst bash-completion || PKGMK_SWAY+=' -D bash-completions=false'
  prt-get isinst zsh || PKGMK_SWAY+=' -D zsh-completions=false'
  prt-get isinst xorg-xwayland && PKGMK_SWAY+=' -D xwayland=enabled' || PKGMK_SWAY+=' -D xwayland=disabled'

  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
}
