2 # the next line restarts using wish \
3 exec wish
"$0" ${1+"$@"}
6 # A nice interface to "xset" to change X server settings
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 $
30 .buttons.apply configure
-state disabled
31 .buttons.cancel configure
-state disabled
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]
63 set rpt
[lindex
$line 1]
64 if {[expr "{$rpt} == {repeat:}"]} then {
65 set kbdrep
[lindex
$line 2]
66 set kbdcli
[lindex
$line 6]
71 set bellvol
[lindex
$line 2]
72 set bellpit
[lindex
$line 5]
73 set belldur
[lindex
$line 8]
77 set mouseacc
[lindex
$line 1]
78 set mousethr
[lindex
$line 3]
82 set bla
[lindex
$line 2]
83 set screenbla
[expr "{$bla} == {yes} ? {blank} : {noblank}"]
87 set screentim
[lindex
$line 1]
88 set screencyc
[lindex
$line 3]
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
]
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
]
132 b
$bellvol $bellpit $belldur \
135 m
$mouseacc $mousethr \
136 s
$screentim $screencyc \
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
{}}} {
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]
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
{} {
195 button .buttons.ok
-default active
-command ok
-text "Ok"
196 button .buttons.apply
-default normal
-command apply
-text "Apply" \
198 button .buttons.cancel
-default normal
-command cancel
-text "Cancel" \
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
}
208 if {![string match .buttons
* %W
]} {
209 .buttons.apply configure
-state normal
210 .buttons.cancel configure
-state normal
214 if {![string match .buttons
* %W
]} {
216 Return
- Escape
- Tab
- *Shift
* {}
218 .buttons.apply configure
-state normal
219 .buttons.cancel configure
-state normal
229 labelframe .bell
-text "Bell Settings" -padx 1.5m
-pady 1.5m
231 -from 0 -to 100 -length 200 -tickinterval 20 \
232 -label "Volume (%)" -orient horizontal
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
245 labelframe .kbd
-text "Keyboard Repeat Settings" -padx 1.5m
-pady 1.5m
248 checkbutton .kbd.val.onoff \
250 -onvalue "on" -offvalue "off" -variable kbdrep \
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
264 labelframe .mouse
-text "Mouse Settings" -padx 1.5m
-pady 1.5m
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
298 pack .buttons
-side top
-fill both
299 pack .bell .kbd .mouse .screen
-side top
-fill both
-expand yes \
303 # Let the user resize our window
308 ##############################################################################
312 # Listen what "xset" tells us...
324 # Write xset parameters
330 # Now, wait for user actions...