gdtltr@brahms.udel.edu (root@research.bdi.com (Systems Research Supervisor)) (01/09/91)
Just get a SPARC? Miss the blinking LED's on your old Sun-3? Try blink.c ! Those keyboard lights never do anything anyway (except flash briefly when you start X,) so why not put them to some use? This trivial hack is known to work on a SPARC SLC w/SunOS 4.1 . Gary Duzan Time Lord Third Regeneration #include <fcntl.h> #include <sys/stat.h> #include <sys/ioctl.h> #include <sys/types.h> #include <sundev/kbd.h> #include <sundev/kbio.h> char ledtab[] = { LED_CAPS_LOCK, LED_COMPOSE, LED_SCROLL_LOCK, LED_NUM_LOCK, LED_SCROLL_LOCK, LED_COMPOSE }; main() { int kbdfd,i; if((kbdfd=open("/dev/kbd", O_WRONLY)) < 0) { perror("open"); abort(); } while(1) { for(i=0;i<6;i++) { if(ioctl(kbdfd, KIOCSLED, &ledtab[i]) < 0) { perror("ioctl"); abort(); } usleep(100000); } } } -- gdtltr@brahms.udel.edu _o_ ---------------------- _o_ [|o o|] Two CPU's are better than one; N CPU's would be real nice. [|o o|] |_o_| Disclaimer: I AM Brain Dead Innovations, Inc. |_o_|
dd@mips.com (Slack is full of contradictions.) (01/10/91)
In article <17394@brahms.udel.edu> gdtltr@brahms.udel.edu (root@research.bdi.com (Systems Research Supervisor)) writes: > > Just get a SPARC? Miss the blinking LED's on your old Sun-3? > > Try blink.c ! I think it's more interesting to do this with a shell script... #! /bin/sh # $Header: sunbell,v 1.6 90/02/14 18:43:55 david Exp $ # ring the bell or rotate the LEDs on a Sun keyboard # D. DiGiacomo if sun ; then : else echo "`basename $0`: not a Sun" exit 1 fi if [ -f /lib/ld.so ] ; then # SunOS 4.x belldev=/dev/kbd else # SunOS 3.x belldev=/dev/bell if [ ! -c $belldev ] ; then echo "$belldev does not exist" echo "try \"mknod $belldev c 12 2; chmod 666 /dev/bell\"" exit 1 fi fi if [ ! -w $belldev ] ; then echo "`basename $0`: $belldev is not writable" echo "(try \"chmod 666 $belldev\")" exit 2 fi if (echo "x" > $belldev) 2> /dev/null ; then : else echo "`basename $0`: cannot write to $belldev" echo "(no keyboard connected?)" exit 3 fi case $# in 0) set - $0 ;; esac case "$1" in *bell*) echo -n "beeeeeeeeeep!" | tr 'bp!' '\002\003\013' > $belldev ;; *[lL][eE][dD]*|*) # rotate LEDs -- type 4 only case "`type usleep`" in *not*found) sleep="sleep 1" ledpat="8 2 4 1 4 2" ;; *) sleep="usleep 250m" ledpat="8 2 4 1 0" ;; esac setled=`echo -n a | tr a '\016'` noclick=`echo -n a | tr a '\013'` trap 'echo -n "${setled}0${noclick}" > $belldev; exit' 1 2 15 while true do for led in $ledpat do echo -n "${setled}${led}${noclick}" $sleep done > $belldev done ;; esac -- David DiGiacomo, MIPS Computer Systems, Sunnyvale, CA dd@mips.com