#!/bin/sh
# Emit the IBus engine list as the union of the per-engine snippets that are
# actually installed under engines.d/. Each front-end package (ibus-libpinyin,
# ibus-libbopomofo) drops exactly one <engine> snippet there, so an engine is
# only advertised to IBus when its package is installed.
#
# This script is referenced from the <engines exec="..."/> attribute of
# /usr/share/ibus/component/libpinyin.xml.
set -e

dir=/usr/share/ibus-libpinyin/engines.d

printf '<?xml version="1.0" encoding="utf-8"?>\n'
printf '<engines>\n'
for f in "$dir"/*.xml; do
	[ -e "$f" ] || continue
	cat "$f"
	printf '\n'
done
printf '</engines>\n'
