#!/bin/bash
#Name: ds-mouse-config-check
#Version: 1.0
#Depends: 
#Author: Dave (david@daveserver.info)
#Purpose: Check integrity of mouse.conf
#License: gplv2

TEXTDOMAINDIR=/usr/share/locale 
TEXTDOMAIN=ds-mouse

user_dts_dir=$HOME/.desktop-session
user_config=$user_dts_dir/mouse.conf

if [ ! -f $user_config ]; then
    mkdir -p $user_dts_dir;
    touch $user_config
    cat <<EOT >> $user_config
#Mouse configuration file
#This is used by ds-mouse / ds-mouse.py
#This is structured in a bash script format, so all options must be option="desired-option"
EOT
fi

if ! grep --quiet "^ACCELERATION=" $user_config; then 
    cat <<EOT >> $user_config

#Mouse acceleration
#Anything outside of the range value will result in the default settings
#Value: Multiplication Value of default speed. (default X ACCELERATION = speed) 
#Range: 0 - 20
ACCELERATION=5
EOT
fi

if ! grep --quiet "^THRESHOLD=" $user_config; then 
    cat <<EOT >> $user_config

#Mouse threshold
#Anything outside of the range value will result in the default settings
#Value: Pixels. The number of pixels the cursor must move to begin accelerating
#Range: 0 - 100
THRESHOLD=1
EOT
fi

if ! grep --quiet "^BUTTONORDER=" $user_config; then 
    cat <<EOT >> $user_config

#Button Order
#0 = right hand
#1 = left hand
BUTTONORDER=0
EOT
fi

if ! grep --quiet "^SIZE=" $user_config; then 
    cat <<EOT >> $user_config

#Cursor Size
#Value: in pixels
#Range: 10-50
SIZE=10
EOT
fi

if ! grep --quiet "^CLICK_TIME=" $user_config; then 
    cat <<EOT >> $user_config

#Multi Click Time
#Time frame given to recognize multiple clicks.
#Value: milliseconds
#Range: 0-5000
CLICK_TIME=400
EOT
fi

if ! grep --quiet "^TOUCHPAD=" $user_config; then 
    cat <<EOT >> $user_config

#Enable / Disable Touchpad
#Options: True (Enabled) / False (Disabled)
TOUCHPAD=true
EOT
fi

if ! grep --quiet "^TOUCHPAD_LOCKOUT=" $user_config; then 
    cat <<EOT >> $user_config

#Enable / Disable Touchpad Lockout
#Disables touchpad while keyboard is in use.
#Will re-enable after time value specified in TOUCHPAD_LOCKOUT_TIME
#Options: True (Enabled) / False (Disabled)
TOUCHPAD_LOCKOUT=false
EOT
fi

if ! grep --quiet "^TOUCHPAD_LOCKOUT_TIME=" $user_config; then 
    cat <<EOT >> $user_config

#Touchpad lockout time
#Set the time value for touchpad lockout to end after last key press
#Value: milliseconds
#Range: 0-500
TOUCHPAD_LOCKOUT_TIME=200
EOT
fi

if ! grep --quiet "^REVERSE_SCROLLING=" $user_config; then 
    cat <<EOT >> $user_config

#Enable / Disable reverse (Natural) scrolling
#Options: True (Enabled) / False (Disabled)
REVERSE_SCROLLING=False
EOT
fi
