#!/bin/sh
# this script will change settings in your ~/.xmms/config
# so that they play well with Cyrillic tags and rusxmms

# by Michael Shigorin <mike@altlinux.org> 
# for xmms-1.2.8-alt3+

XMMS_CYR_SOURCE="true"
XMMS_CYR_INIT="/usr/share/xmms/xmms-wrapper.sh"
unset BROKENFONTS 

[ -r "$XMMS_CYR_INIT" ] && source "$XMMS_CYR_INIT"

[ -z "$XMMS_CYR_CREATED" -o -n "$BROKENFONTS" ] && {
	[ -w "$CONFIG" ] || exit 1
	subst "s,^\(playlist_font=\).*$,\1$BIGFONT," "$CONFIG" 
	subst "s,^\(mainwin_font=\).*$,\1$SMALLFONT," "$CONFIG"
	subst "s,^\(shade_font=\).*$,\1$SMALLFONT," "$CONFIG"
	subst "s,^\(autocharset=\).*$,\1$AUTOCHARSET," "$CONFIG"
	subst "s,^\(autocharset_fs=\).*$,\1$AUTOCHARSET," "$CONFIG"
	subst "s,^\(mainwin_use_xfont=\).*$,\1$MAINWIN_USE_XFONT," "$CONFIG"
}

[ -n "$DISPLAY" ] || exit 0

for i in kmessage gmessage wmessage xmessage true; do
	if which $i >/dev/null 2>&1; then
		XMESSAGE=$i
		break
	fi
done

"$XMESSAGE" -buttons "OK" -default "OK" \
	-title "XMMS Cyrillic Setup" \
	"Fonts and recoding done ($CONFIG)" && \
unset XMMS_CYR_SOURCE && \
runxmms "$@"
