diff options
author | Chmouel Boudjnah <chmouel@mandriva.org> | 2000-04-05 16:34:26 +0000 |
---|---|---|
committer | Chmouel Boudjnah <chmouel@mandriva.org> | 2000-04-05 16:34:26 +0000 |
commit | d42a67c192d2c69561efec5cc1a33c4ce1db1ccd (patch) | |
tree | ee59bc4255c17ee5dac11be247ceff22ce6b7abc | |
parent | daa6a8ea90487345093fb76b904d069e2ba9cf55 (diff) | |
download | numlock-topic/MandrakeSoft.tar numlock-topic/MandrakeSoft.tar.gz numlock-topic/MandrakeSoft.tar.bz2 numlock-topic/MandrakeSoft.tar.xz numlock-topic/MandrakeSoft.zip |
Initial revisionCookertopic/MandrakeSoft
-rw-r--r-- | Makefile | 20 | ||||
-rw-r--r-- | enable_X11_numlock.c | 13 | ||||
-rwxr-xr-x | numlock | 62 | ||||
-rwxr-xr-x | numlock.sh | 10 |
4 files changed, 105 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..4e67373 --- /dev/null +++ b/Makefile @@ -0,0 +1,20 @@ +TOP= +CFLAGS=-g -O2 -Wall +CC=gcc +FLAGS=-lX11 -lXtst -I/usr/X11R6/include -L/usr/X11R6/lib + +enable_X11_numlock: enable_X11_numlock.c + $(CC) $(CFLAGS) $(FLAGS) -o $@ $< + +all: enable_X11_numlock + +clean: + rm -f enable_X11_numlock core *.o + +install: all + install -d $(TOP)/usr/X11R6/bin/ + install -d $(TOP)/etc/{profile.d,rc.d/init.d}/ + + install -m755 enable_X11_numlock $(TOP)/usr/X11R6/bin + install -m755 numlock $(TOP)/etc/rc.d/init.d/ + install -m755 numlock.sh $(TOP)/etc/profile.d/
\ No newline at end of file diff --git a/enable_X11_numlock.c b/enable_X11_numlock.c new file mode 100644 index 0000000..836a4de --- /dev/null +++ b/enable_X11_numlock.c @@ -0,0 +1,13 @@ +#include <X11/extensions/XTest.h> +#include <X11/keysym.h> + +int main(int argc, char **argv) +{ + Display* disp = XOpenDisplay( NULL ); + if( disp == NULL ) + return 1; + XTestFakeKeyEvent( disp, XKeysymToKeycode( disp, XK_Num_Lock ), True, CurrentTime ); + XTestFakeKeyEvent( disp, XKeysymToKeycode( disp, XK_Num_Lock ), False, CurrentTime ); + XCloseDisplay( disp ); + return 0; +} @@ -0,0 +1,62 @@ +#!/bin/sh +# +# Startup script for NumLock +# +# description: Locks NumLock key at init runlevel change +# chkconfig: 345 85 15 + +# Source function library. +. /etc/rc.d/init.d/functions + +# The following file make bash to relock the numlock key when logging +# since login unlock it. +#SYSCONF_FILE=/var/lock/subsys/NumLock +SYSCONF_FILE=/etc/sysconfig/NumLock + +# See how we were called. +case "$1" in + start) + echo -n "Starting NumLock: " + echo_success + echo + touch $SYSCONF_FILE + + for tty in /dev/tty[1-8]; do + setleds -D +num < $tty + done + + ;; + stop) + echo -n "Disabling NumLocks on ttys: " + for tty in /dev/tty[1-8]; do + setleds -D -num < $tty + done + echo_success + echo + rm -f $SYSCONF_FILE + ;; + status) +# status NumLock +# echo "dead status as reported is normal since NumLock doesn't need to daemonize" + if [ -f $SYSCONF_FILE ] + then + echo "NumLock is enabled" + else + echo "NumLock is disabled" + fi + ;; + restart) + $0 stop + $0 start + ;; + reload) + echo -n "Reloading NumLock: " + $0 start + echo + ;; + *) + echo "Usage: $0 {start|stop|restart|reload|status}" + exit 1 +esac + +exit 0 diff --git a/numlock.sh b/numlock.sh new file mode 100755 index 0000000..39781d1 --- /dev/null +++ b/numlock.sh @@ -0,0 +1,10 @@ +# Linux-Mandrake configuration. +# ReLock the NumLock key if /etc/rc.d/init.d/NumLock has been runned +# This is needed as login reset the tty + +MY_TTY=`tty` +case $MY_TTY in + /dev/tty[0-9]*) [ -f /etc/sysconfig/NumLock ] && setleds -D +num < $MY_TTY;; + /dev/pts/[0-9]*) [ "XX$DISPLAY" != "XX" ] && [ -x /usr/X11R6/bin/enable_X11_numlock ] && /usr/X11R6/bin/enable_X11_numlock +esac +unset MY_TTY
\ No newline at end of file |