Initial bulk commit for "Git on MSys"
[msysgit/historical-msysgit.git] / mingw / lib / tk8.4 / demos / ixset
blob3ae26891cfbfb477da79f2b1f212c3e180ae6387
1 #!/bin/sh
2 # the next line restarts using wish \
3 exec wish "$0" ${1+"$@"}
5 # ixset --
6 # A nice interface to "xset" to change X server settings
8 # History :
9 # 91/11/23 : pda@masi.ibp.fr, jt@ratp.fr : design
10 # 92/08/01 : pda@masi.ibp.fr : cleaning
12 # RCS: @(#) $Id: ixset,v 1.4 2001/11/05 10:13:53 dkf Exp $
15 # Button actions
18 proc quit {} {
19 destroy .
22 proc ok {} {
23 writesettings
24 quit
27 proc cancel {} {
28 readsettings
29 dispsettings
30 .buttons.apply configure -state disabled
31 .buttons.cancel configure -state disabled
34 proc apply {} {
35 writesettings
36 .buttons.apply configure -state disabled
37 .buttons.cancel configure -state disabled
41 # Read current settings
44 proc readsettings {} {
45 global kbdrep ; set kbdrep "on"
46 global kbdcli ; set kbdcli 0
47 global bellvol ; set bellvol 100
48 global bellpit ; set bellpit 440
49 global belldur ; set belldur 100
50 global mouseacc ; set mouseacc "3/1"
51 global mousethr ; set mousethr 4
52 global screenbla ; set screenbla "blank"
53 global screentim ; set screentim 600
54 global screencyc ; set screencyc 600
56 set xfd [open "|xset q" r]
57 while {[gets $xfd line] > -1} {
58 set kw [lindex $line 0]
60 case $kw in {
61 {auto}
63 set rpt [lindex $line 1]
64 if {[expr "{$rpt} == {repeat:}"]} then {
65 set kbdrep [lindex $line 2]
66 set kbdcli [lindex $line 6]
69 {bell}
71 set bellvol [lindex $line 2]
72 set bellpit [lindex $line 5]
73 set belldur [lindex $line 8]
75 {acceleration:}
77 set mouseacc [lindex $line 1]
78 set mousethr [lindex $line 3]
80 {prefer}
82 set bla [lindex $line 2]
83 set screenbla [expr "{$bla} == {yes} ? {blank} : {noblank}"]
85 {timeout:}
87 set screentim [lindex $line 1]
88 set screencyc [lindex $line 3]
92 close $xfd
94 # puts stdout [format "Key REPEAT = %s\n" $kbdrep]
95 # puts stdout [format "Key CLICK = %s\n" $kbdcli]
96 # puts stdout [format "Bell VOLUME = %s\n" $bellvol]
97 # puts stdout [format "Bell PITCH = %s\n" $bellpit]
98 # puts stdout [format "Bell DURATION = %s\n" $belldur]
99 # puts stdout [format "Mouse ACCELERATION = %s\n" $mouseacc]
100 # puts stdout [format "Mouse THRESHOLD = %s\n" $mousethr]
101 # puts stdout [format "Screen BLANCK = %s\n" $screenbla]
102 # puts stdout [format "Screen TIMEOUT = %s\n" $screentim]
103 # puts stdout [format "Screen CYCLE = %s\n" $screencyc]
108 # Write settings into the X server
111 proc writesettings {} {
112 global kbdrep kbdcli bellvol bellpit belldur
113 global mouseacc mousethr screenbla screentim screencyc
115 set bellvol [.bell.vol get]
116 set bellpit [.bell.val.pit.entry get]
117 set belldur [.bell.val.dur.entry get]
119 if {[expr "{$kbdrep} == {on}"]} then {
120 set kbdcli [.kbd.val.cli get]
121 } else {
122 set kbdcli "off"
125 set mouseacc [.mouse.hor.acc.entry get]
126 set mousethr [.mouse.hor.thr.entry get]
128 set screentim [.screen.tim.entry get]
129 set screencyc [.screen.cyc.entry get]
131 exec xset \
132 b $bellvol $bellpit $belldur \
133 c $kbdcli \
134 r $kbdrep \
135 m $mouseacc $mousethr \
136 s $screentim $screencyc \
137 s $screenbla
142 # Sends all settings to the window
145 proc dispsettings {} {
146 global kbdrep kbdcli bellvol bellpit belldur
147 global mouseacc mousethr screenbla screentim screencyc
149 .bell.vol set $bellvol
150 .bell.val.pit.entry delete 0 end
151 .bell.val.pit.entry insert 0 $bellpit
152 .bell.val.dur.entry delete 0 end
153 .bell.val.dur.entry insert 0 $belldur
155 .kbd.val.onoff [expr "{$kbdrep} == {on} ? {select} : {deselect}"]
156 .kbd.val.cli set $kbdcli
158 .mouse.hor.acc.entry delete 0 end
159 .mouse.hor.acc.entry insert 0 $mouseacc
160 .mouse.hor.thr.entry delete 0 end
161 .mouse.hor.thr.entry insert 0 $mousethr
163 .screen.blank [expr "{$screenbla}=={blank} ? {select} : {deselect}"]
164 .screen.pat [expr "{$screenbla}!={blank} ? {select} : {deselect}"]
165 .screen.tim.entry delete 0 end
166 .screen.tim.entry insert 0 $screentim
167 .screen.cyc.entry delete 0 end
168 .screen.cyc.entry insert 0 $screencyc
173 # Create all windows, and pack them
176 proc labelentry {path text length {range {}}} {
177 frame $path
178 label $path.label -text $text
179 if {[llength $range]} {
180 spinbox $path.entry -width $length -relief sunken \
181 -from [lindex $range 0] -to [lindex $range 1]
182 } else {
183 entry $path.entry -width $length -relief sunken
185 pack $path.label -side left
186 pack $path.entry -side right -expand y -fill x
189 proc createwindows {} {
191 # Buttons
194 frame .buttons
195 button .buttons.ok -default active -command ok -text "Ok"
196 button .buttons.apply -default normal -command apply -text "Apply" \
197 -state disabled
198 button .buttons.cancel -default normal -command cancel -text "Cancel" \
199 -state disabled
200 button .buttons.quit -default normal -command quit -text "Quit"
202 pack .buttons.ok .buttons.apply .buttons.cancel .buttons.quit \
203 -side left -expand yes -pady 5
205 bind . <Return> {.buttons.ok flash; .buttons.ok invoke}
206 bind . <Escape> {.buttons.quit flash; .buttons.quit invoke}
207 bind . <1> {
208 if {![string match .buttons* %W]} {
209 .buttons.apply configure -state normal
210 .buttons.cancel configure -state normal
213 bind . <Key> {
214 if {![string match .buttons* %W]} {
215 switch -glob %K {
216 Return - Escape - Tab - *Shift* {}
217 default {
218 .buttons.apply configure -state normal
219 .buttons.cancel configure -state normal
226 # Bell settings
229 labelframe .bell -text "Bell Settings" -padx 1.5m -pady 1.5m
230 scale .bell.vol \
231 -from 0 -to 100 -length 200 -tickinterval 20 \
232 -label "Volume (%)" -orient horizontal
234 frame .bell.val
235 labelentry .bell.val.pit "Pitch (Hz)" 6 {25 20000}
236 labelentry .bell.val.dur "Duration (ms)" 6 {1 10000}
237 pack .bell.val.pit -side left -padx 5
238 pack .bell.val.dur -side right -padx 5
239 pack .bell.vol .bell.val -side top -expand yes
242 # Keyboard settings
245 labelframe .kbd -text "Keyboard Repeat Settings" -padx 1.5m -pady 1.5m
247 frame .kbd.val
248 checkbutton .kbd.val.onoff \
249 -text "On" \
250 -onvalue "on" -offvalue "off" -variable kbdrep \
251 -relief flat
252 scale .kbd.val.cli \
253 -from 0 -to 100 -length 200 -tickinterval 20 \
254 -label "Click Volume (%)" -orient horizontal
255 pack .kbd.val.onoff -side left -fill x -expand yes -padx {0 1m}
256 pack .kbd.val.cli -side left -expand yes -fill x -padx {1m 0}
258 pack .kbd.val -side top -expand yes -pady 2 -fill x
261 # Mouse settings
264 labelframe .mouse -text "Mouse Settings" -padx 1.5m -pady 1.5m
266 frame .mouse.hor
267 labelentry .mouse.hor.acc "Acceleration" 5
268 labelentry .mouse.hor.thr "Threshold (pixels)" 3 {1 2000}
270 pack .mouse.hor.acc -side left -padx {0 1m}
271 pack .mouse.hor.thr -side right -padx {1m 0}
273 pack .mouse.hor -side top -expand yes
276 # Screen Saver settings
279 labelframe .screen -text "Screen-saver Settings" -padx 1.5m -pady 1.5m
281 radiobutton .screen.blank \
282 -variable screenblank -text "Blank" -relief flat \
283 -value "blank" -variable screenbla -anchor w
284 radiobutton .screen.pat \
285 -variable screenblank -text "Pattern" -relief flat \
286 -value "noblank" -variable screenbla -anchor w
287 labelentry .screen.tim "Timeout (s)" 5 {1 100000}
288 labelentry .screen.cyc "Cycle (s)" 5 {1 100000}
290 grid .screen.blank .screen.tim -sticky e
291 grid .screen.pat .screen.cyc -sticky e
292 grid configure .screen.blank .screen.pat -sticky ew
295 # Main window
298 pack .buttons -side top -fill both
299 pack .bell .kbd .mouse .screen -side top -fill both -expand yes \
300 -padx 1m -pady 1m
303 # Let the user resize our window
305 wm minsize . 10 10
308 ##############################################################################
309 # Main program
312 # Listen what "xset" tells us...
315 readsettings
318 # Create all windows
321 createwindows
324 # Write xset parameters
327 dispsettings
330 # Now, wait for user actions...
333 # Local Variables:
334 # mode: tcl
335 # End: