#!/bin/sh
#BK Aug 2009, gpl
#jamesbond 2012, 2013 - change/root to $HOME, rework stuff, adjust for default 96 dpi
# 131119 L18L internationalisation

# std localisation stanza
export TEXTDOMAIN=fatdog
. gettext.sh
# performance tweak - use "C" if there is no localisation
! [ -e $TEXTDOMAINDIR/${LANG%.*}/LC_MESSAGES/$TEXTDOMAIN.mo ] &&
! [ -e $TEXTDOMAINDIR/${LANG%_*}/LC_MESSAGES/$TEXTDOMAIN.mo ] && LANG=C

#read current dpi setting...
CURRDPI=$(awk '/^Xft.dpi:/ {print $2}' $HOME/.Xresources)
[ -z $CURRDPI ] && CURRDPI=96
CURRINDEX=$(( $CURRDPI / 12 - 5 ))

CNT=0; RADIOBUTTONS=''
for ONEDPI in 60 72 84 96 108 120 132 144 156 168 180
do
 STATUS='off'
 case $CNT in $CURRINDEX) STATUS='on' ;; esac
 RADIOBUTTONS="$RADIOBUTTONS $ONEDPI $ONEDPI $STATUS"
 CNT=$(( $CNT + 1 ))
done

if NEWDPI=$(Xdialog --left --stdout --title "$(gettext 'Set global font size')" --no-tags --radiolist "
$(gettext 'Please choose dpi (dots per inch) for the screen.')

$(gettext 'The larger the value, the bigger that antialiased fonts will render on the screen. 
Adjust up or down if fonts are rendering too small or too big on screen.')
$(gettext 'Note1: Some apps do not use antialiased rendering and will not be affected by this setting.')
$(gettext 'Note2: Change will only take affect after restarting X')
" 0 0 0 ${RADIOBUTTONS}); then
	sed -i -e '/^Xft.dpi:/ d' $HOME/.Xresources
	echo "Xft.dpi: $NEWDPI" >> $HOME/.Xresources
fi

###END###
