"Fossies" - the Fresh Open Source Software Archive

Member "install-tl-20200916/tlpkg/tltcl/lib/tk8.6/demos/ixset" (17 Mar 2020, 8067 Bytes) of package /windows/misc/install-tl.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

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