]>
Commit | Line | Data |
---|---|---|
1 | #!/usr/local/bin/wish -f | |
2 | ||
3 | # | |
4 | # A nice interface to "xset" to change X server settings | |
5 | # | |
6 | # History : | |
7 | # 91/11/23 : pda@masi.ibp.fr, jt@ratp.fr : design | |
8 | # 92/08/01 : pda@masi.ibp.fr : cleaning | |
9 | # | |
10 | ||
11 | # | |
12 | # Button actions | |
13 | # | |
14 | ||
15 | proc quit {} { | |
16 | destroy . | |
17 | } | |
18 | ||
19 | proc ok {} { | |
20 | writesettings | |
21 | quit | |
22 | } | |
23 | ||
24 | proc cancel {} { | |
25 | readsettings | |
26 | dispsettings | |
27 | } | |
28 | ||
29 | # apply is just "writesettings" | |
30 | ||
31 | ||
32 | # | |
33 | # Read current settings | |
34 | # | |
35 | ||
36 | proc readsettings {} { | |
37 | global kbdrep ; set kbdrep "on" | |
38 | global kbdcli ; set kbdcli 0 | |
39 | global bellvol ; set bellvol 100 | |
40 | global bellpit ; set bellpit 440 | |
41 | global belldur ; set belldur 100 | |
42 | global mouseacc ; set mouseacc "3/1" | |
43 | global mousethr ; set mousethr 4 | |
44 | global screenbla ; set screenbla "blank" | |
45 | global screentim ; set screentim 600 | |
46 | global screencyc ; set screencyc 600 | |
47 | ||
48 | set xfd [open "|xset q" r] | |
49 | while {[gets $xfd line] > -1} { | |
50 | set kw [lindex $line 0] | |
51 | ||
52 | case $kw in { | |
53 | {auto} | |
54 | { | |
55 | set rpt [lindex $line 1] | |
56 | if {[expr "{$rpt} == {repeat:}"]} then { | |
57 | set kbdrep [lindex $line 2] | |
58 | set kbdcli [lindex $line 6] | |
59 | } | |
60 | } | |
61 | {bell} | |
62 | { | |
63 | set bellvol [lindex $line 2] | |
64 | set bellpit [lindex $line 5] | |
65 | set belldur [lindex $line 8] | |
66 | } | |
67 | {acceleration:} | |
68 | { | |
69 | set mouseacc [lindex $line 1] | |
70 | set mousethr [lindex $line 3] | |
71 | } | |
72 | {prefer} | |
73 | { | |
74 | set bla [lindex $line 2] | |
75 | set screenbla [expr "{$bla} == {yes} ? {blank} : {noblank}"] | |
76 | } | |
77 | {timeout:} | |
78 | { | |
79 | set screentim [lindex $line 1] | |
80 | set screencyc [lindex $line 3] | |
81 | } | |
82 | } | |
83 | } | |
84 | close $xfd | |
85 | ||
86 | # puts stdout [format "Key REPEAT = %s\n" $kbdrep] | |
87 | # puts stdout [format "Key CLICK = %s\n" $kbdcli] | |
88 | # puts stdout [format "Bell VOLUME = %s\n" $bellvol] | |
89 | # puts stdout [format "Bell PITCH = %s\n" $bellpit] | |
90 | # puts stdout [format "Bell DURATION = %s\n" $belldur] | |
91 | # puts stdout [format "Mouse ACCELERATION = %s\n" $mouseacc] | |
92 | # puts stdout [format "Mouse THRESHOLD = %s\n" $mousethr] | |
93 | # puts stdout [format "Screen BLANCK = %s\n" $screenbla] | |
94 | # puts stdout [format "Screen TIMEOUT = %s\n" $screentim] | |
95 | # puts stdout [format "Screen CYCLE = %s\n" $screencyc] | |
96 | } | |
97 | ||
98 | ||
99 | # | |
100 | # Write settings into the X server | |
101 | # | |
102 | ||
103 | proc writesettings {} { | |
104 | global kbdrep kbdcli bellvol bellpit belldur | |
105 | global mouseacc mousethr screenbla screentim screencyc | |
106 | ||
107 | set bellvol [.bell.vol get] | |
108 | set bellpit [.bell.val.pit.entry get] | |
109 | set belldur [.bell.val.dur.entry get] | |
110 | ||
111 | if {[expr "{$kbdrep} == {on}"]} then { | |
112 | set kbdcli [.kbd.val.cli get] | |
113 | } else { | |
114 | set kbdcli "off" | |
115 | } | |
116 | ||
117 | set mouseacc [.mouse.hor.acc.entry get] | |
118 | set mousethr [.mouse.hor.thr.entry get] | |
119 | ||
120 | set screentim [.screen.val.le.tim.entry get] | |
121 | set screencyc [.screen.val.le.cyc.entry get] | |
122 | ||
123 | exec xset \ | |
124 | b $bellvol $bellpit $belldur \ | |
125 | c $kbdcli \ | |
126 | r $kbdrep \ | |
127 | m $mouseacc $mousethr \ | |
128 | s $screentim $screencyc \ | |
129 | s $screenbla | |
130 | } | |
131 | ||
132 | ||
133 | # | |
134 | # Sends all settings to the window | |
135 | # | |
136 | ||
137 | proc dispsettings {} { | |
138 | global kbdrep kbdcli bellvol bellpit belldur | |
139 | global mouseacc mousethr screenbla screentim screencyc | |
140 | ||
141 | .bell.vol set $bellvol | |
142 | .bell.val.pit.entry delete 0 end | |
143 | .bell.val.pit.entry insert 0 $bellpit | |
144 | .bell.val.dur.entry delete 0 end | |
145 | .bell.val.dur.entry insert 0 $belldur | |
146 | ||
147 | .kbd.val.onoff [expr "{$kbdrep} == {on} ? {select} : {deselect}"] | |
148 | .kbd.val.cli set $kbdcli | |
149 | ||
150 | .mouse.hor.acc.entry delete 0 end | |
151 | .mouse.hor.acc.entry insert 0 $mouseacc | |
152 | .mouse.hor.thr.entry delete 0 end | |
153 | .mouse.hor.thr.entry insert 0 $mousethr | |
154 | ||
155 | .screen.val.rb.blank [expr "{$screenbla}=={blank} ? {select} : {deselect}"] | |
156 | .screen.val.rb.pat [expr "{$screenbla}!={blank} ? {select} : {deselect}"] | |
157 | .screen.val.le.tim.entry delete 0 end | |
158 | .screen.val.le.tim.entry insert 0 $screentim | |
159 | .screen.val.le.cyc.entry delete 0 end | |
160 | .screen.val.le.cyc.entry insert 0 $screencyc | |
161 | } | |
162 | ||
163 | ||
164 | # | |
165 | # Create all windows, and pack them | |
166 | # | |
167 | ||
168 | proc labelentry {path text length} { | |
169 | frame $path | |
170 | label $path.label -text $text | |
171 | entry $path.entry -width $length -relief sunken | |
172 | pack append $path $path.label {left expand} $path.entry {right expand} | |
173 | } | |
174 | ||
175 | proc createwindows {} { | |
176 | # | |
177 | # Buttons | |
178 | # | |
179 | ||
180 | frame .buttons | |
181 | button .buttons.ok -command "ok" -text "Ok" | |
182 | button .buttons.apply -command "writesettings" -text "Apply" | |
183 | button .buttons.cancel -command "cancel" -text "Cancel" | |
184 | button .buttons.quit -command "quit" -text "Quit" | |
185 | ||
186 | pack append .buttons \ | |
187 | .buttons.ok {left expand pady 10} \ | |
188 | .buttons.apply {left expand pady 10} \ | |
189 | .buttons.cancel {left expand pady 10} \ | |
190 | .buttons.quit {left expand pady 10} | |
191 | ||
192 | # | |
193 | # Bell settings | |
194 | # | |
195 | ||
196 | frame .bell -relief raised -borderwidth 2 | |
197 | label .bell.label -text "Bell Settings" | |
198 | scale .bell.vol \ | |
199 | -from 0 -to 100 -length 200 -tickinterval 20 \ | |
200 | -label "Volume (%)" -orient horizontal \ | |
201 | -bg Bisque1 -activeforeground Gray | |
202 | ||
203 | frame .bell.val | |
204 | labelentry .bell.val.pit "Pitch (Hz)" 6 | |
205 | labelentry .bell.val.dur "Duration (ms)" 6 | |
206 | pack append .bell.val \ | |
207 | .bell.val.pit {left padx 10} \ | |
208 | .bell.val.dur {right padx 10} | |
209 | ||
210 | pack append .bell \ | |
211 | .bell.label {top expand} \ | |
212 | .bell.vol {top expand} \ | |
213 | .bell.val {top expand} | |
214 | ||
215 | # | |
216 | # Keyboard settings | |
217 | # | |
218 | ||
219 | frame .kbd -relief raised -borderwidth 2 | |
220 | ||
221 | label .kbd.label -text "Keyboard Repeat Settings" | |
222 | ||
223 | frame .kbd.val | |
224 | checkbutton .kbd.val.onoff \ | |
225 | -text "On" \ | |
226 | -onvalue "on" -offvalue "off" -variable kbdrep \ | |
227 | -relief flat \ | |
228 | -activebackground Bisque1 | |
229 | scale .kbd.val.cli \ | |
230 | -from 0 -to 100 -length 200 -tickinterval 20 \ | |
231 | -label "Click Volume (%)" -orient horizontal \ | |
232 | -bg Bisque1 -activeforeground Gray | |
233 | pack append .kbd.val \ | |
234 | .kbd.val.onoff {left expand fill} \ | |
235 | .kbd.val.cli {left expand} | |
236 | ||
237 | pack append .kbd \ | |
238 | .kbd.label {top expand} \ | |
239 | .kbd.val {top expand pady 4 fillx} | |
240 | ||
241 | # | |
242 | # Mouse settings | |
243 | # | |
244 | ||
245 | frame .mouse -relief raised -borderwidth 2 | |
246 | ||
247 | label .mouse.label -text "Mouse Settings" | |
248 | frame .mouse.hor | |
249 | labelentry .mouse.hor.acc "Acceleration" 3 | |
250 | labelentry .mouse.hor.thr "Threshold (pixels)" 3 | |
251 | ||
252 | pack append .mouse.hor \ | |
253 | .mouse.hor.acc {left} \ | |
254 | .mouse.hor.thr {right} | |
255 | ||
256 | pack append .mouse \ | |
257 | .mouse.label {top} \ | |
258 | .mouse.hor {top expand} | |
259 | ||
260 | # | |
261 | # Screen Saver settings | |
262 | # | |
263 | ||
264 | frame .screen -relief raised -borderwidth 2 | |
265 | ||
266 | label .screen.label -text "Screen-saver Settings" | |
267 | frame .screen.val | |
268 | ||
269 | frame .screen.val.rb | |
270 | radiobutton .screen.val.rb.blank \ | |
271 | -variable screenblank -text "Blank" -relief flat \ | |
272 | -value "blank" -variable screenbla \ | |
273 | -activebackground Bisque1 | |
274 | radiobutton .screen.val.rb.pat \ | |
275 | -variable screenblank -text "Pattern" -relief flat \ | |
276 | -value "noblank" -variable screenbla \ | |
277 | -activebackground Bisque1 | |
278 | pack append .screen.val.rb \ | |
279 | .screen.val.rb.blank {top pady 4 frame w} \ | |
280 | .screen.val.rb.pat {top pady 4 frame w} | |
281 | frame .screen.val.le | |
282 | labelentry .screen.val.le.tim "Timeout (s)" 5 | |
283 | labelentry .screen.val.le.cyc "Cycle (s)" 5 | |
284 | pack append .screen.val.le \ | |
285 | .screen.val.le.tim {top pady 4 frame e} \ | |
286 | .screen.val.le.cyc {top pady 4 frame e} | |
287 | ||
288 | pack append .screen.val \ | |
289 | .screen.val.rb {left} \ | |
290 | .screen.val.le {left} | |
291 | ||
292 | pack append .screen \ | |
293 | .screen.label {top} \ | |
294 | .screen.val {top expand} | |
295 | ||
296 | # | |
297 | # Main window | |
298 | # | |
299 | ||
300 | pack append . \ | |
301 | .buttons {top fill} \ | |
302 | .bell {top fill pady 10 expand} \ | |
303 | .kbd {top fill pady 10 expand} \ | |
304 | .mouse {top fill pady 10 expand} \ | |
305 | .screen {top fill pady 10 expand} | |
306 | ||
307 | # | |
308 | # Let the user resize our window | |
309 | # | |
310 | wm minsize . 10 10 | |
311 | } | |
312 | ||
313 | ############################################################################## | |
314 | # Main program | |
315 | ||
316 | # | |
317 | # Listen what "xset" tells us... | |
318 | # | |
319 | ||
320 | readsettings | |
321 | ||
322 | # | |
323 | # Create all windows | |
324 | # | |
325 | ||
326 | createwindows | |
327 | ||
328 | # | |
329 | # Write xset parameters | |
330 | # | |
331 | ||
332 | dispsettings | |
333 | ||
334 | # | |
335 | # Now, wait for user actions... | |
336 | # |