Alexander Mueller, Homepage: http://virtuelle.gefil.de/~dondy ---- some improvements to the BClock :) * new mail notification * starting a programm on button press set radius 10 set maildir [expr {([catch {file exists $env(MAIL)}] == "0")? \ "$env(MAIL)" : "/var/spool/mail/$env(USER)"}] wm title . "BClock, initializing..." wm aspect . 6 4 6000 4000 wm geometry . [expr $radius * 6 + 1]x[expr $radius * 4 + 1] proc create_resize_ovals {value radius} { foreach col {0 1 2 3 4 5} { foreach row {0 1 2 3} { set x1 [expr $col * $radius] set y1 [expr $radius * 3 - $row * $radius] set x2 [expr $x1 + $radius] set y2 [expr $y1 + $radius] if { $value == 0 } { .b create oval $x1 $y1 $x2 $y2 -tag $col,$row } elseif { $value == 1 } { .b coords $col,$row $x1 $y1 $x2 $y2 } else { exit 1 } } } } proc resize_canvas_ovals {width height} { global radius set radius [expr ($width / 6 + $height / 4) / 2] .b configure -width [expr $radius * 6] -height [expr $radius * 4] create_resize_ovals 1 $radius } proc every {ms body} { eval $body after $ms [info level 0] } . configure -bd 0 -highlightthickness 0 pack [canvas .b -background Black -highlightthickness 0 -bd 0] create_resize_ovals 0 $radius bind . { resize_canvas_ovals %w %h } # just for some extra functionality :D bind . { exec -- xterm -fg white -bg black -e mutt & } bind . { exec -- xterm -fg white -bg black & } bind . { exec -- xterm -fg white -bg black -e vim & } every 1000 { global maildir set mtime [file mtime $maildir] set atime [file atime $maildir] # if we have mail... if { $mtime > $atime } { # first approach to show the user we have mail .b configure -background LimeGreen . configure -bg LimeGreen set led0 "DarkBlue" set led1 "LightBlue" # have audible notofication too :) bell } else { .b configure -background Black . configure -bg Black set led0 "DarkRed" set led1 "IndianRed1" } set time [ clock format [ clock sec ] -format "%T" ] regexp {([0-2])([0-9]):([0-5])([0-9]):([0-5])([0-9])} \ $time -> h1 h2 m1 m2 s1 s2 wm title . "BClock, $time" set values [list $h1 $h2 $m1 $m2 $s1 $s2] foreach col {0 1 2 3 4 5} value $values { foreach bit {0 1 2 3} { set color [expr {$value & (1 << $bit)? "$led1" : "$led0" }] .b itemconfigure $col,$bit -fill $color } } } ---- * telnet.tcl, my version of the telnet client found at [Telnet] proc quit {fd_sock} { close $fd_sock set ::closed($fd_sock) 1 } proc input {fd_sock} { set data x while {[string length $data]} { set data [read $fd_sock 4096] if {[eof $fd_sock]} { quit $fd_sock } else { puts -nonewline stdout $data } } } proc output {fd_sock} { if {[gets stdin data] >= 0} { puts $fd_sock $data } else { quit $fd_sock } } set fd_sock [socket 130.149.19.20 7680] fconfigure $fd_sock -buffering none -blocking 0 fconfigure stdout -buffering none fileevent $fd_sock readable [list input $fd_sock] fileevent stdin readable [list output $fd_sock] vwait closed($fd_sock) exit ---- GCCs output on compilation of terminal.c see: [Unix Terminal Extension] [almu@mozart:4]% gcc -I/usr/include/tcl8.3 -I/usr/include/linux -shared terminal.c -o terminal.so In file included from /usr/include/sys/types.h:215, from /usr/include/stdlib.h:390, from terminal.c:2: /usr/include/sys/select.h:58: warning: `__NFDBITS' redefined /usr/include/linux/posix_types.h:22: warning: this is the location of the previous definition /usr/include/sys/select.h:60: warning: `__FDMASK' redefined /usr/include/linux/posix_types.h:34: warning: this is the location of the previous definition /usr/include/sys/select.h:89: warning: `FD_SET' redefined /usr/include/linux/time.h:106: warning: this is the location of the previous definition /usr/include/sys/select.h:90: warning: `FD_CLR' redefined /usr/include/linux/time.h:107: warning: this is the location of the previous definition /usr/include/sys/select.h:91: warning: `FD_ISSET' redefined /usr/include/linux/time.h:108: warning: this is the location of the previous definition /usr/include/sys/select.h:92: warning: `FD_ZERO' redefined /usr/include/linux/time.h:109: warning: this is the location of the previous definition In file included from /usr/include/bits/types.h:143, from /usr/include/stdio.h:36, from terminal.c:1: /usr/include/bits/pthreadtypes.h:50: parse error before `size_t' /usr/include/bits/pthreadtypes.h:50: warning: no semicolon at end of struct or union /usr/include/bits/pthreadtypes.h:53: parse error before `__stacksize' /usr/include/bits/pthreadtypes.h:53: warning: data definition has no type or storage class /usr/include/bits/pthreadtypes.h:54: warning: data definition has no type or storage class In file included from /usr/include/_G_config.h:44, from /usr/include/libio.h:32, from /usr/include/stdio.h:65, from terminal.c:1: /usr/include/gconv.h:72: parse error before `size_t' /usr/include/gconv.h:85: parse error before `size_t' /usr/include/gconv.h:94: parse error before `size_t' /usr/include/gconv.h:170: parse error before `size_t' /usr/include/gconv.h:170: warning: no semicolon at end of struct or union /usr/include/gconv.h:173: parse error before `}' /usr/include/gconv.h:173: warning: data definition has no type or storage class In file included from /usr/include/libio.h:32, from /usr/include/stdio.h:65, from terminal.c:1: /usr/include/_G_config.h:47: field `__cd' has incomplete type /usr/include/_G_config.h:50: field `__cd' has incomplete type In file included from /usr/include/stdio.h:65, from terminal.c:1: /usr/include/libio.h:344: parse error before `size_t' /usr/include/libio.h:353: parse error before `size_t' /usr/include/libio.h:461: parse error before `_IO_sgetn' /usr/include/libio.h:461: parse error before `size_t' /usr/include/libio.h:461: warning: data definition has no type or storage class In file included from terminal.c:1: /usr/include/stdio.h:259: parse error before `size_t' /usr/include/stdio.h:265: parse error before `size_t' /usr/include/stdio.h:293: parse error before `size_t' /usr/include/stdio.h:297: parse error before `size_t' /usr/include/stdio.h:459: parse error before `fread' /usr/include/stdio.h:459: parse error before `size_t' /usr/include/stdio.h:460: warning: data definition has no type or storage class /usr/include/stdio.h:462: parse error before `fwrite' /usr/include/stdio.h:462: parse error before `size_t' /usr/include/stdio.h:463: warning: data definition has no type or storage class /usr/include/stdio.h:467: parse error before `fread_unlocked' /usr/include/stdio.h:467: parse error before `size_t' /usr/include/stdio.h:468: warning: data definition has no type or storage class /usr/include/stdio.h:469: parse error before `fwrite_unlocked' /usr/include/stdio.h:469: parse error before `size_t' /usr/include/stdio.h:470: warning: data definition has no type or storage class In file included from terminal.c:2: /usr/include/stdlib.h:133: parse error before `__ctype_get_mb_cur_max' /usr/include/stdlib.h:133: warning: data definition has no type or storage class In file included from /usr/include/sys/types.h:132, from /usr/include/stdlib.h:390, from terminal.c:2: /usr/include/linux/time.h:10: parse error before `time_t' /usr/include/linux/time.h:10: warning: no semicolon at end of struct or union /usr/include/linux/time.h:12: parse error before `}' /usr/include/linux/time.h:89: parse error before `time_t' /usr/include/linux/time.h:89: warning: no semicolon at end of struct or union /usr/include/linux/time.h:90: warning: data definition has no type or storage class /usr/include/linux/time.h:120: field `it_interval' has incomplete type /usr/include/linux/time.h:121: field `it_value' has incomplete type /usr/include/linux/time.h:125: field `it_interval' has incomplete type /usr/include/linux/time.h:126: field `it_value' has incomplete type In file included from terminal.c:2: /usr/include/stdlib.h:407: parse error before `size_t' /usr/include/stdlib.h:436: parse error before `size_t' /usr/include/stdlib.h:527: parse error before `__size' /usr/include/stdlib.h:529: parse error before `__nmemb' /usr/include/stdlib.h:536: parse error before `size_t' In file included from /usr/include/stdlib.h:546, from terminal.c:2: /usr/include/alloca.h:33: parse error before `__size' In file included from terminal.c:2: /usr/include/stdlib.h:551: parse error before `__size' /usr/include/stdlib.h:690: parse error before `size_t' /usr/include/stdlib.h:694: parse error before `size_t' /usr/include/stdlib.h:756: parse error before `size_t' /usr/include/stdlib.h:759: parse error before `size_t' /usr/include/stdlib.h:763: parse error before `size_t' /usr/include/stdlib.h:766: parse error before `size_t' /usr/include/stdlib.h:773: parse error before `size_t' /usr/include/stdlib.h:776: parse error before `*' /usr/include/stdlib.h:780: parse error before `wchar_t' /usr/include/stdlib.h:784: parse error before `mbstowcs' /usr/include/stdlib.h:784: parse error before `*' /usr/include/stdlib.h:785: warning: data definition has no type or storage class /usr/include/stdlib.h:787: parse error before `wcstombs' /usr/include/stdlib.h:788: parse error before `*' /usr/include/stdlib.h:789: warning: data definition has no type or storage class ---- [[ [Category Person] | [Category Home Page] ]]