#!/usr/local/bin/klone (setq max-level *maxint*) (setq title "Colas XFree Modeline Generator") (setq color "CCFFCC") (catch 'Ok (dolist (path '( "/htdocs/cgi-bin/nph-colas-modelines-aux" "/net/koala/bin/sh/xfree-modelines" "/usr/local/bin/xfree-modelines" )) (if (file-stats path) (throw 'Ok (setq script-path path))) ) (setq script-path "xfree-modelines") ) ;; a sample script to show modelines (defun main (&aux ) (cgi:init :error "/tmp/colas-klone-cgi-errors") ;; first, decide what want the user? (if (= cgi:path-info "") ;no subpart? mainpage (show-main-page) (= cgi:path-info "/list-all") ;list all possible modelines (show-modelines) (= cgi:path-info "/script") ; show oneself (show-script #[*arguments* 0]) (= cgi:path-info "/script-standalone") ; show oneself (show-script script-path) (= cgi:path-info "/kill") ; show oneself (wait (system "echo killing...;/usr/ucb/ps -axw | grep '[m]odelines'| ( while read P R;do echo \"killing $P $R\";kill $P;done )")) (PF "Unknown command!\n") ;there is a ball in the soup ) (cgi:end :validity 15) ) (defun show-main-page () (PF
This script will compute many possible values for the graphic modes of Xfree86, to be put in the ModeLines section of XF86Config.
Warning: This script is based on my experience on high-end monitors
(17"-24" multisync with more than 135Mhz of bandwidth), trying to squeeze the
most refresh rate at the highest resolution, and will not work for
lower specs monitors (15" and lower). See these comments by Koen
Gadeyne on why this script cannot be used for all purposes.
new July 1st 1998: this script implements now better heuristics
Please indicate the specs of your monitor and graphic card:
First, the maximal values that you should find in your graphic card and monitor specs (or on the internet). Important to determine the best resolutions and refresh rates you can get.
cgi:script-name ; %0 *version* ; %1 title ; %2 color ; %3 ) ) (defun show-modelines (&aux s (x 320) (y 240) (re-sm (regcomp "#[ \t]*([0-9]+)[ \t]*Hz")) (re-num (regcomp "^([0-9]+)$")) ) (with (*arguments* (list script-path "-load")) (load script-path) ) ;; get form values, set defaults (setq M-BW (Number (get cgi:arguments "bw" 200))) (if (> 1 M-BW) (setq M-BW 200)) (setq M-VF (Number (get cgi:arguments "vf" 150))) (if (> 1 M-VF) (setq M-VF 150)) (setq M-HF (Number (get cgi:arguments "hf" 100))) (if (> 1 M-HF) (setq M-HF 100)) (setq M-RR (Number (get cgi:arguments "rr" 100))) (if (> 1 M-RR) (setq M-RR 70)) (setq m-BW (Number (get cgi:arguments "mbw" 20))) (if (> 1 m-BW) (setq m-BW 20)) (if (>= m-BW M-BW) (setq m-BW (- M-BW 1))) (setq m-HF (Number (get cgi:arguments "mhf" 30))) (if (> 1 m-HF) (setq m-HF 30)) (if (>= m-HF M-HF) (setq m-HF (- M-HF 1))) (if (and (regexec re-num (get cgi:arguments "X" "")) (regexec re-num (get cgi:arguments "Y" ""))) (progn (setq X (Number (get cgi:arguments "X" 640))) (if (> 1 X) (setq x 640)) (setq Y (Number (get cgi:arguments "Y" 480))) (if (> 1 Y) (setq Y 480)) ) (setqn X () Y ()) ) (setq ratio (get cgi:arguments "ratio" "4/3")) (setq re-ratio (regcomp "^([0-9]+)[/]([0-9]+)$")) (if (regexec re-ratio ratio) (progn (setq ratio (vector (Int (regsub re-ratio 1))(Int (regsub re-ratio 2)))) ) t (setq ratio [4 3]) ) (setq correction (Number (get cgi:arguments "correction" 0))) (PFModeLine "name" dotclock width x x x heigth y y y #RefreshRate
title M-BW M-VF M-HF M-RR (getenv "HTTP_REFERER") color m-BW m-HF
)
(if (and X Y) (progn
(setq s (copy ""))
(with (*standard-output* (open s :type :string :direction :io))
(process-modeline (PF String "\"%0x%1\"" X Y) X Y M-VF)
)
(if (and (regexec re-sm s) (>= (Number (regsub re-sm 1)) M-RR))
(write-string s)
(if (= "" s)
(PF "# RESOLUTION TOO LOW: %0 x %1" X Y) ;too low, continue
(PF "# RESOLUTION TOO HIGH: %0 x %1" X Y)
)))
(catch 'Done (while t
(setq s (copy ""))
(setq y (/ (* (getn ratio 1) x) (getn ratio 0)))
(with (*standard-output* (open s :type :string :direction :io))
(process-modeline (PF String "\"%0x%1\"" x y) x y M-VF)
)
(if (and (regexec re-sm s) (>= (Number (regsub re-sm 1)) M-RR))
(write-string s)
(if (= "" s)
() ;too low, continue
(throw 'Done) ;ok, end there
))
(incf x 8)
)))
(PF "