abinfo "Building dms ..."
cd "$SRCDIR"/core/cmd/dms
go build \
    -v \
    -trimpath \
    -ldflags "-X main.Version=$PKGVER -s -w" \
    -o dms

abinfo "Installing dms binary ..."
install -Dvm755 "$SRCDIR"/core/cmd/dms/dms "$PKGDIR"/usr/bin/dms

abinfo "Installing quickshell files ..."
install -dvm755 "$PKGDIR"/usr/share/quickshell/dms
cp -av "$SRCDIR"/quickshell/. "$PKGDIR"/usr/share/quickshell/dms/

abinfo "Installing systemd unit" \
       "and desktop assets ..."
install -Dvm644 "$SRCDIR"/assets/systemd/dms.service -t "$PKGDIR"/usr/lib/systemd/user/
install -Dvm644 "$SRCDIR"/assets/dms-open.desktop -t "$PKGDIR"/usr/share/applications/
install -Dvm644 "$SRCDIR"/assets/danklogo.svg -t "$PKGDIR"/usr/share/icons/hicolor/scalable/apps/

abinfo "Installing shell completions ..."
# FIXME: dms cannot be run as root, so we have to copy it to a temporary location and run it as nobody to generate the completions
## Note: https://github.com/AvengeMedia/DankMaterialShell/issues/2233
cp -av "$SRCDIR"/core/cmd/dms/dms /tmp/dms-abbs-dms
runuser -u nobody -- /tmp/dms-abbs-dms completion bash > "$SRCDIR"/bash-completions
runuser -u nobody -- /tmp/dms-abbs-dms completion fish > "$SRCDIR"/fish-completions
runuser -u nobody -- /tmp/dms-abbs-dms completion zsh > "$SRCDIR"/zsh-completions
install -Dvm644 "$SRCDIR"/bash-completions "$PKGDIR"/usr/share/bash-completion/completions/dms
install -Dvm644 "$SRCDIR"/fish-completions "$PKGDIR"/usr/share/fish/vendor_completions.d/dms.fish
install -Dvm644 "$SRCDIR"/zsh-completions "$PKGDIR"/usr/share/zsh/site-functions/_dms
