#!/bin/bash

source "${PALUDIS_EBUILD_DIR}/echo_functions.bash"

if [[ "${CATEGORY}/${PN}" == "xfce-base/xfce4-session" ]] ; then
	elog "Replacing /usr/$(exhost --target)/bin/xflock4!"

	cat << EOF > "${IMAGE}"/usr/$(exhost --target)/bin/xflock4
#!/bin/sh

PATH=/bin:/usr/bin
export PATH

# else run another access locking utility, if installed
for lock_cmd in \
  "i3lock -c 000000"
  do
    set -- \$lock_cmd
    if command -v -- \$1 >/dev/null 2>&1; then
        \$lock_cmd >/dev/null 2>&1 &
	# turn off display backlight:
	xset dpms force off
        exit
    fi
done

# else access locking failed
exit 1
EOF

fi