103 lines
3.1 KiB
Plaintext
103 lines
3.1 KiB
Plaintext
|
#!/bin/bash
|
||
|
#
|
||
|
# gpm -- GPM adds mouse support to text-based Linux applications
|
||
|
#
|
||
|
# chkconfig: 345 98 1
|
||
|
# description: GPM adds mouse support to text-based Linux applications such \
|
||
|
# the Midnight Commander. Is also allows mouse-based console \
|
||
|
# cut-and-paste operations, and includes support for pop-up \
|
||
|
# menus on the console.
|
||
|
# processname: gpm
|
||
|
# pidfile: /var/run/gpm.pid
|
||
|
# config: /etc/sysconfig/mouse
|
||
|
|
||
|
# Copyright (c) 2003-2005 by Silvan Calarco <silvan.calarco@qilinux.it>
|
||
|
# Copyright (c) 2003-2007 by Davide Madrisan <davide.madrisan@qilinux.it>
|
||
|
|
||
|
. /etc/sysconfig/rc
|
||
|
. $rc_functions
|
||
|
|
||
|
NAME=gpm
|
||
|
DAEMON=/usr/sbin/$NAME
|
||
|
DAEMONPID=/var/run/$NAME.pid
|
||
|
DAEMONCONF=/etc/gpm-root.conf
|
||
|
OPTIONS=-R
|
||
|
#MOUSECFG=/etc/sysconfig/mouse
|
||
|
#MOUSEDEVICE=/dev/mouse
|
||
|
|
||
|
[ -x $DAEMON ] || exit 0
|
||
|
|
||
|
[ -r /etc/sysconfig/$NAME ] && . /etc/sysconfig/$NAME
|
||
|
|
||
|
KERNELMIN=`uname -r | sed -e 's,[^\.]*\.,,' -e 's,\..*,,'`
|
||
|
RETVAL=0
|
||
|
|
||
|
case "$1" in
|
||
|
start)
|
||
|
echo -n $"Starting console mouse services: "
|
||
|
unset GPM_PARMS
|
||
|
SYNAPTIC_DEV=`cat /proc/bus/input/devices 2>/dev/null | \
|
||
|
sed '/./{H;$!d;};x;/Synaptics/!d' | \
|
||
|
sed -n '/Handlers=/{s,.*\(event[^ ]*\).*,\1,p}'`
|
||
|
[ "$SYNAPTIC_DEV" ] &&
|
||
|
GPM_PARMS="-m /dev/input/$SYNAPTIC_DEV -t evdev"
|
||
|
|
||
|
USB_DEV=`cat /proc/bus/input/devices 2>/dev/null | \
|
||
|
sed '/./{H;$!d;};x;/Phys=usb/!d' | \
|
||
|
sed -n '/Handlers=/{s,.*\(mouse[^ ]*\).*,\1,p}'`
|
||
|
[ "$USB_DEV" ] &&
|
||
|
for usbdev in $USB_DEV; do
|
||
|
GPM_PARMS="${GPM_PARMS:+"$GPM_PARMS -M"} -m /dev/input/$usbdev -t imps2"
|
||
|
done
|
||
|
|
||
|
PS2_DEV=`cat /proc/bus/input/devices 2>/dev/null | \
|
||
|
sed '/./{H;$!d;};x;/Name="PS\/2/!d' | \
|
||
|
sed -n '/Handlers=/{s,.*\(mouse[^ ]*\).*,\1,p}'`
|
||
|
[ "$PS2_DEV" ] &&
|
||
|
GPM_PARMS="${GPM_PARMS:+"$GPM_PARMS -M"} -m /dev/input/$PS2_DEV -t ps2"
|
||
|
|
||
|
IMPS2_DEV=`cat /proc/bus/input/devices 2>/dev/null | \
|
||
|
sed '/./{H;$!d;};x;/Name="Im[^ ]*PS\/2/!d' | \
|
||
|
sed -n '/Handlers=/{s,.*\(mouse[^ ]*\).*,\1,p}'`
|
||
|
[ "$IMPS2_DEV" ] &&
|
||
|
GPM_PARMS="${GPM_PARMS:+"$GPM_PARMS -M"} -m /dev/input/$IMPS2_DEV -t imps2"
|
||
|
|
||
|
if [ "$KERNELMIN" -le 4 ]; then
|
||
|
[ -z "$PS2_DEV" -a -e /dev/psaux ] &&
|
||
|
GPM_PARMS="${GPM_PARMS:+"$GPM_PARMS -M"} -m /dev/psaux -t ps2"
|
||
|
|
||
|
[ "$USB_DEV" ] ||
|
||
|
for usbdev in `find /dev/input/mouse[0-9] 2>/dev/null`; do
|
||
|
GPM_PARMS="${GPM_PARMS:+"$GPM_PARMS -M"} -m $usbdev -t imps2"
|
||
|
done
|
||
|
fi
|
||
|
|
||
|
daemon --pidfile=$DAEMONPID $DAEMON $OPTIONS $GPM_PARMS
|
||
|
RETVAL=$?
|
||
|
evaluate_retval; echo
|
||
|
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$NAME
|
||
|
;;
|
||
|
stop)
|
||
|
echo -n $"Shutting down console mouse services: "
|
||
|
killproc -p $DAEMONPID $DAEMON
|
||
|
RETVAL=$?
|
||
|
evaluate_retval; echo
|
||
|
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$NAME
|
||
|
;;
|
||
|
restart|reload)
|
||
|
$0 stop
|
||
|
$0 start
|
||
|
;;
|
||
|
condrestart)
|
||
|
[ -e /var/lock/subsys/$NAME ] && $0 restart || :
|
||
|
;;
|
||
|
status)
|
||
|
statusproc $DAEMON
|
||
|
;;
|
||
|
*) echo $"Usage:"" $0 {start|stop|status|restart}"
|
||
|
exit 1
|
||
|
;;
|
||
|
esac
|
||
|
|
||
|
exit $RETVAL
|