IceWalkers.com - Linux Software downloads and news
Name : Password :
Linux SoftwareLinux RPMLinux HowtosLink UsAboutAdvertise

HOWTOs

Search Howtos :Match :

C.1. hotplug: input.agent

/etc/hotplug/input.agent


#!/bin/sh
# Please place this file /etc/hotplug
#
# input-specific hotplug policy agent.
#
# Kernel Input params are:
#	
#	ACTION=add
#	PHYS=pysical location of device
#	NAME=Name of the device
#
# HISTORY:
#       15-JUN-2003     removed paste
#       07-MAY-2003     remake by Aivils Stoss
#                       /proc manipulation added
#                       parse kbd.conf event.conf mouse.conf.
#			create necessary symbolic links
#	28-SEP-2002	Initial version from Andreas Schuldei
#			 andreas (at) schuldei.org 
#
cd /etc/hotplug
. hotplug.functions
DEBUG=yes export DEBUG

KBD_CONFIG="./kbd.conf"
EVENT_CONFIG="./event.conf"
MOUSE_CONFIG="./mouse.conf"

setup_kbd ()
{
    while read VT_NUM PHYS_PATTERN NAME_PATTERN
    do
	if [ `echo "$VT_NUM" | grep "^#"` ]; then
	    continue;
	fi
	if [ `echo "$PHYS" | grep $PHYS_PATTERN 2>/dev/null` ]; then
	    VT=`echo "$VT_NUM" | sed 's/VT//' | awk '{printf "%02d", $0}'`
            if [ -d /proc/bus/console/$VT ]; then
                echo "$PHYS" > "/proc/bus/console/$VT/keyboard"
                debug_mesg "Input device $NAME on $PHYS mapping as secondary to VT$VT"
                return;
	    else
		debug_mesg "Trying to configure keyboard for VT$VT , but not enough VT's available"
	    fi
	fi
    done
    debug_mesg "Found no fitting VT"
}

setup_event ()
{
    while read SYM_LINK PHYS_PATTERN NAME_PATTERN
    do
	if [ `echo "$SYM_LINK" | grep "^#"` ]; then
	    continue;
	fi
	if [ `echo "$PHYS" | grep $PHYS_PATTERN 2>/dev/null` ]; then
	    case $ACTION in
	    add)
		cd /dev/input
                rm -f $SYM_LINK
		ln -s $DEV_EVENT $SYM_LINK
    		debug_mesg "Input event device $NAME on $PHYS linked to $SYM_LINK"
	    ;;
	    remove)
		rm -f /dev/input/$SYM_LINK
    		debug_mesg "Input event device link $SYM_LINK removed"
	    ;;
	    esac
	    return;
	fi
    done
    debug_mesg "Found no fitting event device"
}

setup_mouse ()
{
    while read SYM_LINK PHYS_PATTERN NAME_PATTERN
    do
	if [ `echo "$SYM_LINK" | grep "^#"` ]; then
	    continue;
	fi
	if [ `echo "$PHYS" | grep $PHYS_PATTERN 2>/dev/null` ]; then
	    case $ACTION in
	    add)
                cd /dev/input
		rm -f $SYM_LINK
		ln -s $DEV_MOUSE $SYM_LINK
    		debug_mesg "Input mouse device $NAME on $PHYS linked to $SYM_LINK"
	    ;;
	    remove)
		rm -f /dev/input/$SYM_LINK
    		debug_mesg "Input mouse device link $SYM_LINK removed"
	    ;;
	    esac
	    return;
	fi
    done
    debug_mesg "Found no fitting mouse device"
}

if [ "$ACTION" = "" ]; then
    mesg Bad input agent invocation
    exit 1
fi

DEV_HANDLERS=`grep -E 'Phys|Handlers' /proc/bus/input/devices | \
    awk '{ if(count == 0) { printf("%s\t",$0); count++; } else { print $0; count=0; } }' | \
    grep $PHYS | awk -F\t '{print $2}' | sed 's/^.*=//'`

# older grep do not support -o :-(
#DEV_EVENT=`echo $MATCHED | grep -oE event[0-9]+`
#DEV_MOUSE=`echo $MATCHED | grep -oE mouse[0-9]+`
#DEV_KBD=`echo $MATCHED | grep -o kbd`

DEV_EVENT=`echo $DEV_HANDLERS | \
	    awk -F" " '{for(n=1;$n;n=n+1) if($n ~ /event/) print $n}'`
DEV_MOUSE=`echo $DEV_HANDLERS | \
	    awk -F" " '{for(n=1;$n;n=n+1) if($n ~ /mouse/) print $n}'`
DEV_KBD=`echo $DEV_HANDLERS | \
	    awk -F" " '{for(n=1;$n;n=n+1) if($n ~ /kbd/) print $n}'`

#
# What to do with this input device event?
#
case "$ACTION" in

add)
    if [ -n "$DEV_KBD" ]; then
	setup_kbd < $KBD_CONFIG
    fi
    if [ -n "$DEV_EVENT" ]; then
	setup_event < $EVENT_CONFIG
    fi
    if [ -n "$DEV_MOUSE" ]; then
	setup_mouse < $MOUSE_CONFIG
    fi
    ;;
remove)
    #setup_event < $EVENT_CONFIG
    #setup_mouse < $MOUSE_CONFIG
    ;;
*)
    debug_mesg "Input '$ACTION' event not supported"
    return 1
    ;;

esac
      
Search Howtos :Match :
DbVisualizer 6.5.2
The Universal Database Tool
PhpMyAdmin 3.1.2 rc1
Php front-end to MySQL administration
Xine 1.1.6
Free video player
Glade 3.5.5
User interface builder for GTK+ and Gnome
Evolution 2.25.4
GNOME mailer, calendar, contact manager and communications tool
GEdit 2.25.4
Small but powerful text editor
LimeWire 5.0.4
Gnutella Client
WebGUI 7.6.8
A fully featured content management system.
GTK2 2.14.7
GUI Toolkit
Brasero 0.9.0
Application to burn CD/DVD
Free IT Magazines, White Papers, eBooks, and more !
Dr. Dobb's Journal

Dr. Dobb's Journal enables programmers to write the most efficient and sophisticated programs and help in daily programming quandaries.

The 7 Things that IT Security Professionals MUST KNOW!

Gain key insight into security problem and find the safest means to protect your technological assets.

Database Trends and Applications

Provides timely coverage of the technology, intelligence and insight needed to plan, implement and manage information-rich projects.

Linux Software Map
Find Linux RPM
Best Rated Linux Software
Most Rated Linux Software
Linux Distributions
Linux Howtos
Quick Survey

Please take our survey and help us improve our website to serve you better.

Thank you.
Linux Software
Linux / IT Resources
Site Resources
Google
Privacy Policy
Contact Us
Submit Software
Advertising info