Files
strans/run.sh

50 lines
1.2 KiB
Bash
Executable File

#!/bin/sh
cd "$(dirname "$0")" || exit 1
if test "$#" -eq 0; then
set --
for font in \
/usr/share/fonts/TTF/DejaVuSans.ttf \
/usr/share/fonts/TTF/Jigmo.ttf \
/usr/share/fonts/TTF/Jigmo2.ttf \
/usr/share/fonts/noto/NotoSansCJK-Regular.ttc
do
test -f "$font" && set -- "$@" "$font"
done
if test "$#" -eq 0; then
echo "run.sh: no default font found; pass a font file" >&2
exit 1
fi
fi
if ! test -x ./strans; then
echo "run.sh: ./strans is not executable; run make first" >&2
exit 1
fi
if test -n "${DISPLAY-}" && ! test -x xim/strans-xim; then
echo "run.sh: xim/strans-xim is not executable; run make first" >&2
exit 1
fi
if ! command -v pkill >/dev/null 2>&1; then
echo "run.sh: pkill is required" >&2
exit 1
fi
uid=$(id -u) || exit 1
pkill -TERM -u "$uid" -x strans-xim 2>/dev/null || :
pkill -TERM -u "$uid" -x strans 2>/dev/null || :
sleep 0.1
pkill -KILL -u "$uid" -x strans-xim 2>/dev/null || :
pkill -KILL -u "$uid" -x strans 2>/dev/null || :
./strans map "$@" </dev/null &
strans_pid=$!
if test -n "${DISPLAY-}"; then
xim/strans-xim </dev/null &
xim_pid=$!
echo "run.sh: started daemon $strans_pid and XIM $xim_pid"
else
echo "run.sh: started daemon $strans_pid; DISPLAY is unset"
fi