#!/bin/bash # Copyright (C) 2009-2010 Matias Fonzo, Santiago del Estero, AR # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # Localización: TEXTDOMAINDIR=/usr/local/share/locale TEXTDOMAIN=gpmconfig # Directorio temporal: TMP=${TMP:-/tmp} [[ ! -d $TMP ]] && mkdir -p "$TMP" TEMPFILE=${TMP}/gpmconfig-reply$$ rm -f $TEMPFILE while [[ ! -s $TEMPFILE ]]; do dialog \ --backtitle $"Mouse configuration tool" \ --title $"MOUSE" \ --menu \ $"Welcome to gpmconfig. A configuration tool for the mouse selection.\n\n\ The PS/2 model is the most common model for laptops. Otherwise, \ you can select the USB model or see the rest of the models.\n\n\ Select your mouse type:" 20 70 12 \ "" $"--> Mouse type (PS/2)" \ "ps2" $"Common mouse for PS2 series" \ "imps2" $"Microsoft Intellimouse autodetect 2/3 buttons" \ "exps2" $"IntelliMouse Explorer - 3 buttons" \ "netmouse" $"Genius NetMouse - 4 buttons" \ "ncr" $"Ncr3125pen found on some laptops" \ "" $"--> Mouse type (USB)" \ "imps2usb" $"Also a common protocol for USB devices" \ "" $"--> Mouse type (Serial)" \ "acecad" $"Acecad tablet absolute mode" \ "bare" $"Microsoft compatible - 2 buttons" \ "genitizer" $"Genitizer tablet, in relative mode" \ "logi" $"Logitech devices" \ "logim" $"Logitech into Mouse-Systems compatible" \ "twid" $"Twidddler keyboard" \ "wacom" $"Wacom Protocol IV tablets" \ "mman" $"The MouseMan and similar devices" \ "ms" $"Microsoft-compatible - 3 buttons" \ "ms3" $"Microsoft Intellimouse - 3 buttons" \ "msc" $"Mouse-Systems compatible. Most 3-button mice" \ "pnp" $"Plug and Play mice. Doesn't work with 'ms'" \ "wp" $"Genius WizardPad tablet" \ "" $"--> Miscellaneous devices" \ "js" $"Mouse emulation with a Joystick" \ 2> $TEMPFILE RETCODE=$? if (( $RETCODE != 0 )); then rm -f $TEMPFILE exit $RETCODE; fi done if [[ -f $TEMPFILE ]]; then ANSWER=$(cut -f 1 -d ' ' $TEMPFILE) fi case "$ANSWER" in ps2|imps2|exps2|ncr) DEVICE=/dev/psaux ;; imps2usb) ANSWER=imps2 DEVICE=/dev/input/mice ;; acecad|bare|genitizer|logi*|twid|wacom|mman|ms*|pnp|wp) dialog \ --title $"SERIAL PORT" \ --backtitle $"Mouse configuration tool" \ --menu $"Your mouse requires a port communication:" 0 0 0 \ "ttyS0" $"Serial port 0, COM1 under DOS" \ "ttyS1" $"Serial port 1, COM2 under DOS" \ "ttyS2" $"Serial port 2, COM3 under DOS" \ "ttyS3" $"Serial port 3, COM4 under DOS" \ 2> ${TMP}/gpmconfig-reply-serdev$$ RETCODE=$?; (( $RETCODE != 0 )) && "$0" && RETCODE=0; DEVICE=$(cut -f 1 -d ' ' ${TMP}/gpmconfig-reply-serdev$$) rm -f ${TMP}/gpmconfig-reply-serdev$$ ;; js) DEVICE=/dev/js0 ;; *) RETCODE=1; esac # Escribe el archivo de configuración si es adecuado: if [[ $DEVICE ]]; then # Hace un enlace fresco: ( cd /dev && rm -f mouse && ln -s $DEVICE mouse ) # Escribimos los valores de configuración: mkdir -p /etc/sysconfig printf "%s\n" \ "# /etc/sysconfig/gpm: File configuration for gpm." \ "" \ "# Mouse acceleration (the default is 2):" \ "ACCEL=2" \ "" \ "# Mouse protocol:" \ "PROTO=$ANSWER" \ "" \ "# Mouse device:" \ "DEV=$DEVICE" \ "" > /etc/sysconfig/gpm # Ahora, el archivo de inicio para runit: mkdir -p /etc/runit/runsvdir/default /etc/sv/gpm printf "%s\n" \ "#!/bin/sh" \ "#" \ "# gpm: The main mouse server for GNU Linux." \ "#" \ "" \ ". /etc/sysconfig/gpm || exit 1;" \ "" \ "if [ -x /usr/sbin/gpm ]; then" \ " exec /usr/sbin/gpm -D -m \$DEV -t \$PROTO -a \$ACCEL > /dev/null 2>&1" \ "fi" "" > /etc/sv/gpm/run # Reiniciamos el servicio para que surta efecto: chmod 755 /etc/sv/gpm/run ( cd /etc/runit/runsvdir/default && ln -sf /etc/sv/gpm . ) fi exit $RETCODE