#!/usr/bin/wish # Matt Willis - simple tk interface to fmtools # mute button added by James Smith # The radio is turned off after leaving. # -*- tcl -*- # These are stations in the Rio de Janeiro area. Customize for your own locale. set stations \ " MPB 90.3 CBN 92.5 BandNews 94.9 PARADISO 95.7 Nativa 96.5 98FM 98.0 MEC 98.9 JBFM 99.7 O_Dia 100.5 Transamerica 101.3 JovenPan 102.1 Oi 102.9 Antena1 103.7 " # initial volume [0,100] set volume 100 set n [expr [llength $stations]/2] # default radio station set radbut 3 set rvol 100 set state 0 # make tuner buttons frame .labels for {set i 0} {$i<$n} {incr i 1} { radiobutton .r$i -value $i -variable radbut \ -text [lindex $stations [expr $i *2]] -command setstation pack .r$i -anchor w -in .labels } # turns the radio on eval exec fm on frame .rhs scale .vol -orient horizontal -from 0 -to 100 -showvalue 0 \ -variable volume -label Volume: entry .stn -bg black -fg green -font "-*-helvetica-*-r-*-*-20-*-*-*-*-*-*-*" \ -width 6 -justify right -state disabled button .exit -command out -text exit button .mute -command mute -text mute pack .vol .stn .exit .mute -in .rhs pack .labels .rhs -side left .vol configure -command setvolume proc setstation {} { global stations radbut volume # roma 20091221 # eval exec fm [lindex $stations [expr $radbut*2+1]] $volume eval exec fm [lindex $stations [expr $radbut*2+1]] eval exec amixer -q -c 0 set PCM $volume% .stn configure -state normal .stn delete 0 end .stn insert 0 [lindex $stations [expr $radbut*2+1]] .stn configure -state disabled } proc setvolume {sliderval} { setstation } proc out {} { global stations radbut volume # roma 20070217 # eval exec fm [lindex $stations [expr $radbut*2+1]] 0 eval exec fm off exit } proc mute {} { global stations radbut volume rvol state if {$state==0} { set rvol $volume # roma 20070217 # eval exec fm [lindex $stations [expr $radbut*2+1]] 0 eval exec fm off set state 1 .mute config -text unmute } else { # eval exec fm [lindex $stations [expr $radbut*2+1]] $volume eval exec fm on set state 0 .mute config -text mute } }