#!/bin/sh
#BK Aug 2009, gpl
#130312 internationalisation L18L
#180430 move range from 54-108 to 78-132

export TEXTDOMAIN=set-xftdpi
export OUTPUT_CHARSET=UTF-8
#export LANG=C #xdialog happy with this. #130312

#read current dpi setting...
CURRDPI=`grep "^Xft\\.dpi:" /root/.Xresources | tr '\t' ' ' | tr -s ' ' | cut -f 2 -d ' '`

#[ ! $CURRDPI ] && CURRDPI=78
#CURRINDEX=$(( $CURRDPI / 6 - 9 ))
[ ! $CURRDPI ] && CURRDPI=96
CURRINDEX=$(( $CURRDPI / 6 - 13 ))

CNT=0; RADIOBUTTONS=''
for ONEDPI in 78 84 90 96 102 108 114 120 126 132 #54 60 66 72 78 84 90 96 102 108
do
 STATUS='off'
 [ $CNT -eq $CURRINDEX ] && STATUS='on'
 RADIOBUTTONS="$RADIOBUTTONS $ONEDPI $ONEDPI $STATUS"
 CNT=$(( $CNT + 1 ))
done

XDIALOG="Xdialog --left --wrap --stdout --title \"$(gettext 'Set global font size')\" --no-tags --radiolist \"$(gettext 'Please choose dpi (dots per inch) for the screen. 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.')\n\n$(gettext 'Note1: Some apps do not use antialiased rendering and will not be affected by this setting.')\n\n$(gettext 'Note2: Change will only take effect after restarting X')\" 0 60 0 ${RADIOBUTTONS}"
NEWDPI="`eval "$XDIALOG"`"
[ $? -ne 0 ] && exit

TMP1="`cat /root/.Xresources | grep -v "Xft\\.dpi:"`"
echo "$TMP1" > /root/.Xresources
echo "Xft.dpi: $NEWDPI" >> /root/.Xresources
sync

###END###
