#!/bin/sh
# modify jwm_font_repair.sh
# from jwm-493-i18n by shinobar
MODIFIED=""
for ONEFILE in /etc/xdg/templates/_root_.jwmrc /root/.jwmrc /root/.jwm/jwmrc-theme $(ls /root/.jwm/themes/*-jwmrc 2>/dev/null)
do
	grep -q '<Font>DejaVu Sans-' $ONEFILE || continue
	sed -e 's/<Font>DejaVu Sans-/<Font>NanumGothic /'  $ONEFILE > $ONEFILE.new
	[ -s $ONEFILE.new ] && mv -f $ONEFILE.new $ONEFILE && MODIFIED="yes"
done
MSG="No files modified."
BG=""
if [ "$MODIFIED" ] ; then
 MSG="Font settings on jwm is replaced(DejaVu Sans -> NanumGothic)."
 BG="-bg green"
 fi
[ "$DISPLAY" ] && which xmessage &>/dev/null && xmessage -center -timeout 6 -buttons '' $BG "$MSG"
[ "$MODIFIED" ] && pidof jwm >/dev/null && jwm -restart