Service Bell

I wrote this for my partner who is recovering from surgery. She can't do much unassisted, so this enables her to summon me from the other end of the house without the indignity of having to yell. The first part is a wish script which is running on her laptop:

wm resizable . 0 0
wm title . "Service Bell"
wm attributes . -toolwindow true
pack [canvas .canvas -width 100 -height 100] -side top -fill both
set button [.canvas create oval 10 10 90 90 -fill "#cc8844"]
bind .canvas <ButtonPress-1> on_press
proc on_press {} {
        variable button
        .canvas itemconfigure $button -fill "#ff8844"
        after 250 [list .canvas itemconfigure $button -fill "#cc8844"]
        set sock [socket -async 192.168.1.102 1001]
        fileevent $sock readable [list close $sock]
}

The second is a tclsh script that listens for a connection. No data is actually transferred, a connection is sufficient to "ring the bell." Whenever a connection is received the script sends ASCII code 7 (BEL) to stdout.

puts "Service Bell"
proc on_connect {sock args} {
        puts -nonewline [binary format c1 7]
        flush stdout
        close $sock
}
socket -server on_connect 1001
vwait forever

This took about 3 minutes to make :)


AMG: [binary format c1 7] works, but a simpler way to get the bell character is to type \a.


gold 25nov2017, added pix and some categories.

Ref links, vwait ,Backdoor Socket Server, Medical

service bell on TCL WIKI png