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

HOWTOs

Search Howtos :Match :

D.4. Modified hotplug input.agent /etc/hotplug/input.agent

This /etc/hotplug/input.agent is modified to use the global configuration file.

#!/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-Sep-2003     modified to use single configuration file
#                       /etc/sysconfig/ruby.conf by me :-)
#                       (Svetoslav Slavtchev)
#                       added handling for multimedia keys
#                       but doesn't work as expected :(
#       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
 
RUBY_CONF="/etc/sysconfig/ruby.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_mm_keys ()
{
    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"
}

setup_input ()
{
    if [ -n "$DEV_KBD" ]; then
        sed -n "/keyboard devices/,/config/p" $RUBY_CONF	| setup_kbd 
        sed -n "/multimedia keys/,/config/p" $RUBY_CONF		| setup_mm_keys
    fi
    if [ -n "$DEV_EVENT" ]; then
        sed -n "/event devices/,/config/p" $RUBY_CONF		| setup_event 
    fi
    if [ -n "$DEV_MOUSE" ]; then
        sed -n "/mouse devices/,/config/p" $RUBY_CONF		| setup_mouse  
    fi
}

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/^.*=//'`

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)
    setup_input
    ;;
remove)
    #setup_input
    ;;
*)
    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