3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 #-----------------------------------------------------------------------------
19 # Copyright 2000, Olivier Chapuis
20 #-----------------------------------------------------------------------------
25 my $version = '@VERSION@';
26 my $fvwmVersion = '@FVWM_VERSION@';
28 my $prefix = $ENV{'prefix'} || '@prefix@';
29 my $ROOT_PREFIX = $ENV{'ROOT_PREFIX'} || '@ROOT_PREFIX@';
30 $ROOT_PREFIX = $ENV{'DESTDIR'} if $ENV{'DESTDIR'};
31 my $datadir = "@datadir@";
33 my $userHome = $ENV{'HOME'} || "./.";
34 my $userDir = $ENV{'FVWM_USERDIR'} || "$userHome/.fvwm";
35 my $currentThemeName = 'current';
36 my $themesSubDir = 'themes';
37 my $currentThemeSubDir = "$themesSubDir/$currentThemeName";
38 my $personalDirName = 'personal';
39 my $localeDir = "@FT_DATADIR@/locale";
41 my $scriptName = ($0 =~ m:([^/]+)$:, $1);
50 my $comName = "script";
52 # in line doc and script msg
64 my $fontOnlyAdjustable = 0;
68 # "help" => \&showHelp,
69 # "version" => \&showVersion,
72 "ls-opt=s" => \$lsOptions,
75 "check-exec=s" => \$checkExec,
76 "globalfeel" => \$globalFeel,
77 "com-name=s" => \$comName,
78 "in-line-doc=s" => \$inLineDoc,
79 "line-length=i" => \$lineLength,
80 "get-msg=s" => \$getMsg,
83 "font-filter:s" => \$fontFilter,
84 "font-reset" => \$fontReset,
85 "font-index=s" => \$fontIndex,
86 "font-current=s" => \$fontCurrent,
87 "font-start" => \$fontStart,
88 "font-info" => \$fontInfo,
94 $comPid =~ s/script-//;
95 $comPid = 0 if ($comPid !~ /^\d+$/);
97 # we never return here
101 getDirListing($path, $lsOptions, $item, $type eq "dir", $type eq "file");
103 elsif ($checkExec ne "") {
104 my $r = checkExecInPath($checkExec);
107 elsif ($inLineDoc ne "") {
110 elsif ($getMsg ne "") {
119 # ----------------------------------------------------------------------------
122 my $fileName = shift;
124 open(FILE, "<$fileName") || die("Can't open $fileName: [$!]\n");
125 my $fileContent = join("", <FILE>);
126 close(FILE) || die("Can't close $fileName: [$!]\n");
127 return \$fileContent;
130 #----------------------------------------------------------------------------
131 # For FvwmScript-FontSelector
137 my $filterLists = { };
138 my $foudryFromIndex = "";
139 my $familyFromIndex = "";
143 my $ffFilter = "-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*";
144 my @filterList = qw(* * * * * * * * * * * * * *);
145 my @keys = qw (Weight Slant Width Style PixSize PtSize XRes YRes Spacing
147 my @allKeys = qw(Foundry Family);
148 my @filterKeys = qw(Foundry Weight Slant Style PixSize PtSize Width XRes YRes Spacing AvgWidth Charset);
149 push @allKeys, @keys;
156 my $ffHasChanged = 0;
158 my $ffHasNoMatch = 0;
160 $fontCurrent = "-misc-fixed-*-*-*-*-*-*-*-*-*-*-*-*-*"
161 if $fontCurrent eq "";
162 $ffFilter = "-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*";
164 fontInit($fontList, \$fontFilter, $filterLists);
166 @s = split('-',$fontCurrent);
167 $current{'Foundry'} = $s[1];
168 $current{'Family'} = $s[2];
169 $current{'Weight'} = $s[3];
170 $current{'Slant'} = $s[4];
171 $current{'Width'} = $s[5];
172 $current{'Style'} = $s[6];
173 $current{'PixSize'} = $s[7];
174 $current{'PtSize'} = $s[8];
175 $current{'XRes'} = $s[9];
176 $current{'YRes'} = $s[10];
177 $current{'Spacing'} = $s[11];
178 $current{'AvgWidth'} = $s[12];
179 $current{'Charset'} = $s[13] . "-" .$s[14];
182 "-$current{'Foundry'}-$current{'Family'}-*-*-*-*-*-*-*-*-*-*-*-*";
184 if ($fontIndex != 0) {
185 if (defined $fontList->[$fontIndex-1] &&
186 $fontList->[$fontIndex-1] =~ /^(.+) \((.+)\)$/) {
187 $ffFilter = "-$2-$1-*-*-*-*-*-*-*-*-*-*-*-*";
188 $current{'Foundry'} = $2;
189 $current{'Family'} = $1;
196 my @trueFontFilter = split('-',$fontFilter);
198 for($i = 1; $i < 14; $i++) {
199 $current{"$allKeys[$i-1]"} = $trueFontFilter[$i]
200 if $trueFontFilter[$i] ne '*';
201 $current{"$allKeys[$i-1]"} .= '-' . $trueFontFilter[14]
202 if ($i == 13 && $trueFontFilter[$i] ne '*')
206 my @f2 = split('-',$ffFilter);
207 my @f3 = split('-',$fontCurrent);
208 $ffHasChanged = 1 if $current{'Foundry'} ne $f3[1]
209 || $current{'Family'} ne $f3[2];
210 for($i = 0; $i < 15; $i++) {
212 $f = $trueFontFilter[$i] if $trueFontFilter[$i] ne '*';
213 $f = $f2[$i] if $f2[$i] ne '*';
214 $f = $f3[$i] if $f3[$i] ne '*' && $i > 2;
215 $filterList[$i] = $f;
218 if ($type =~ /^font-list/) {
220 my $ff = "$current{'Family'} ($current{'Foundry'})";
221 for($i = 0; defined $fontList->[$i] && $tmp == 0; $i++) {
223 if $fontList->[$i] eq $ff;
225 #$ffHasNoMatch = 1 if ($tmp == 0);
226 $tmp = "0" x (3 - length($tmp)) . $tmp;
228 foreach (@$fontList) { $return .= $_ . "|" }
229 if ($return eq $tmp) {
230 $return .= "||No fonts match the filter|"
233 # return also the filter:
234 for($i = 1; $i < 14; $i++) {
235 $return .= $trueFontFilter[$i];
236 $return .= "-" . $trueFontFilter[14] if ($i == 13);
241 if ($type =~ /all-list/) {
244 # check consitency if foundry and/or family have changed:
246 # remove: Spacing Width Slant Weight Charset if font is not found ...
247 my @prefKeys = qw(11 5 4 3 13);
248 # the size is computed later
249 $filterList[7] = '*';
254 for ($k = 1; $k < 15; $k++) {
255 $tmpFilter .= '-' . $filterList[$k];
257 open(XLS,"xlsfonts -fn '$tmpFilter' 2>/dev/null |") ||
258 ($return = "Impossible to open xlsfont\n");
259 while(<XLS> && $notdone) { $notdone = 0 }
262 $filterList[$prefKeys[$j]] = '*'
263 if $trueFontFilter[$prefKeys[$j]] eq '*';
264 if ($j == 4 && $trueFontFilter[$prefKeys[$j]] eq '*') {
265 $filterList[13] = '*';
266 $filterList[14] = '*';
270 $notdone = 0 if $j == 5;
274 # see if we are ajustable (what follows seems false but this work, I do
275 # not know really why :o)
277 for ($k = 1; $k < 7; $k++) {
278 $tmpFilter .= '-' . $filterList[$k];
280 $tmpFilter .= '-0-0-0-0';
281 for ($k = 12; $k < 15; $k++) {
282 $tmpFilter .= '-' . $filterList[$k];
284 open(XLS,"xlsfonts -fn '$tmpFilter' 2>/dev/null |") ||
285 ($return = "Impossible to open xlsfont\n");
286 while(<XLS> && $adjustable !=2) { $adjustable = 2 }
289 # now build the lists
291 foreach $key (@keys) {
295 if ($adjustable == 2 && $fontOnlyAdjustable) {
296 for ($k = 1; $k < 7; $k++) {
297 if ($k == $j) { $tmpFilter .= '-*'; }
298 else { $tmpFilter .= '-' . $filterList[$k]; }
300 $tmpFilter .= '-0-0-0-0';
301 for ($k = 12; $k < 15; $k++) {
302 $tmpFilter .= '-' . $filterList[$k];
305 for ($k = 1; $k < 15; $k++) {
306 if ($k == $j && $trueFontFilter[$k] eq '*') {
308 if ($key eq "Charset") {
313 else { $tmpFilter .= '-' . $filterList[$k] }
316 open(XLS,"xlsfonts -fn '$tmpFilter'|") ||
317 ($return = "Impossible to open xlsfont\n");
323 $list->[$i]->{"$key"} = $s[$j];
324 $list->[$i]->{"$key"} .= "-" . $s[$j+1] if $key eq "Charset";
333 foreach $key (@keys) {
336 #needed if filter gives no font
337 if ($key eq "Charset") {
338 unshift @l, "$trueFontFilter[$j]-$trueFontFilter[$j+1]"
339 if $trueFontFilter[$j] ne '*';
341 unshift @l, $trueFontFilter[$j] if $trueFontFilter[$j] ne '*';
344 if ($adjustable == 2 && $key eq "PixSize") {
345 @l = qw(4 5 6 7 8 9 10 11 12 13 14 15 16 18 20 22 24 26 28 30
348 for($i = 0; defined $list->[$i]->{"$key"}; $i++) {
349 push @l, $list->[$i]->{"$key"}
351 if ($key =~ /Size$/ || $key =~ /Res$/ || $key =~ /^AvgWidth$/) {
352 @l = sort {$a <=> $b} @l;
362 push @newl, $_ if $_ ne $prev;
366 if ($key eq "Charset") {
367 unshift @newl, '*-*' if $trueFontFilter[$j] eq '*';
369 unshift @newl, '*' if $trueFontFilter[$j] eq '*';
372 # now adjust the index and compute the real font:
377 foreach ($i = 0; defined $newl[$i]; $i++) {
378 $index = $i+1 if $newl[$i] eq $current{"$key"};
379 if ($key eq "PixSize" && $newl[$i] ne '*' &&
380 $current{"$key"} ne '*' &&
381 $diff > abs($newl[$i] - $current{"$key"})) {
383 $real{"$key"} = $newl[$i];
384 $diff = abs($newl[$i] - $current{"$key"});
389 $real{"$key"} = $newl[0];
391 $index = "0" . $index if length($index) == 1;
404 if ($trueFontFilter[$i] eq '*') {
405 $realFont .= $real{"$_"} . "!"
407 $realFont .= $trueFontFilter[$i];
409 $realFont .= "-" . $trueFontFilter[$i+1];
415 $return .= $realFont;
416 $return .= $adjustable . "!";
417 $return .= $ffHasNoMatch . "!";
420 if ($type =~ /filter-list/) {
422 foreach $key (@filterKeys) {
423 my @l = @{$filterLists->{"$key"}};
425 foreach ($i = 0; defined $l[$i]; $i++) {
426 $index = $i+1 if ($l[$i] eq $trueFontFilter[$j] ||
427 $l[$i] eq "$trueFontFilter[13]-$trueFontFilter[14]");
432 $index = "0" . $index if length($index) == 1;
440 if ($j == 1) { $j=3; }
444 $return .= "!misc!fixed!*!*!*!*!*!*!*!*!*!*!*-*!0!0!";
448 #print STDERR $return . "\n";
453 # ---------------------------------------
456 my $fontList = shift;
457 my $fontFilter = shift;
458 my $filterLists = shift;
461 my $oldFontFilter = "";
462 my $file = "$userDir/.FvwmScript-FontSelector";
463 my @filterKeys = qw(Foundry Weight Slant Style PixSize PtSize Width XRes YRes Spacing AvgWidth Charset);
464 #my @filterKeys = qw(Foundry Family Weight Slant Width XRes YRes Spacing Charset);
465 if (! -f $file || $fontReset) {
466 #print STDERR "create RC\n";
467 $$fontFilter = $oldFontFilter = "-*-*-*-*-*-*-*-*-*-*-*-*-*-*";
468 my $list = myXlsfonts("$$fontFilter");
471 for($i = 0; defined $list->[$i]; $i++) {
472 my $a = $list->[$i]->{'Family'};
473 my $b = $list->[$i]->{'Foundry'};
474 my $newFont = $a . " (" . $b . ")";
475 push @$fontList, $newFont if $newFont ne $prev;
478 @$fontList = sort @$fontList;
480 foreach $key (@filterKeys) {
483 for($i = 0; defined $list->[$i]->{"$key"}; $i++) {
484 push @l, $list->[$i]->{"$key"}
486 if ($key =~ /Size$/ || $key =~ /Res$/ || $key =~ /^AvgWidth$/) {
487 @l = sort {$a <=> $b} @l;
493 next if $_ eq '0' || $_ eq '';
494 push @newl, $_ if $_ ne $prev;
497 if ($key eq "Charset") {
498 unshift @newl, '*-*';
504 $filterLists->{"$key"}->[$i] = $_;
509 $str .= "filter=-*-*-*-*-*-*-*-*-*-*-*-*-*-*\n";
510 foreach(@$fontList) { $str .= "$_\n"; }
512 foreach $hash (@filterKeys) {
513 $str .= "hash=$hash\n";
514 for($i=0; defined $filterLists->{"$hash"}->[$i];$i++) {
515 $str .= $filterLists->{"$hash"}->[$i] ."\n";
519 #print STDERR "load RC\n";
520 my $c = loadFile($file);
521 my @f = split(/\n/,$$c);
526 if (/^filter=(.+)$/) {
529 } elsif (/^hash=(.+)$/) {
530 last if ! $type =~ /filter/;
534 } elsif ($hash eq "") {
538 $filterLists->{"$hash"}->[$i] = $_;
544 $$fontFilter = $oldFontFilter if ($$fontFilter eq "");
546 if ($oldFontFilter ne $$fontFilter) {
547 #print STDERR "Re create RC\n";
549 my $list = myXlsfonts("$$fontFilter");
552 for($i = 0; defined $list->[$i]; $i++) {
553 my $a = $list->[$i]->{'Family'};
554 my $b = $list->[$i]->{'Foundry'};
555 my $newFont = $a . " (" . $b . ")";
556 push @$fontList, $newFont if $newFont ne $prev;
559 @$fontList = sort @$fontList;
561 $str .= "filter=$$fontFilter\n";
562 foreach(@$fontList) { $str .= "$_\n"; }
564 foreach $hash (@filterKeys) {
565 $str .= "hash=$hash\n";
566 for($i=0; defined $filterLists->{"$hash"}->[$i];$i++) {
567 $str .= $filterLists->{"$hash"}->[$i] ."\n";
572 if ($str ne "") { saveToFile($str,$file); }
575 #-----------------------------------------
583 open(XLS,"xlsfonts -fn '$filter'|") ||
584 die "Impossible to open xlsfont\n";
589 $list->[$i]->{'Foundry'} = $s[1];
590 $list->[$i]->{'Family'} = $s[2];
591 $list->[$i]->{'Weight'} = $s[3];
592 $list->[$i]->{'Slant'} = $s[4];
593 $list->[$i]->{'Width'} = $s[5];
594 $list->[$i]->{'Style'} = $s[6];
595 $list->[$i]->{'PixSize'} = $s[7];
596 $list->[$i]->{'PtSize'} = $s[8];
597 $list->[$i]->{'XRes'} = $s[9];
598 $list->[$i]->{'YRes'} = $s[10];
599 $list->[$i]->{'Spacing'} = $s[11];
600 $list->[$i]->{'AvgWidth'} = $s[12];
601 $list->[$i]->{'Charset'} = $s[13] . "-" .$s[14];
609 # -------------------
615 open(XLS,"xlsfonts -fn '$fontCurrent'|") ||
616 ($return = "Impossible to open xlsfont\n");
617 while(<XLS>) { chomp; $obtained = $_ if $obtained eq ""; }
619 open(XLS,"xlsfonts -ll -fn '$obtained'|") ||
620 ($return = "Impossible to open xlsfont\n");
625 next if !(/^\s*name.+/ || /^\s*[A-Z].+/ || /^\s*$/);
628 $return .= $_ . "|" if $count;
633 print $return . "\n";
636 #----------------------------------------------------------------------------
637 # build MSG for scripts
641 $lang = $ENV{'LANG'} if $lang eq "" && $ENV{'LANG'};
647 $lang = substr($lang, 0, 2);
650 my $lc_ctype = $ENV{'LC_CTYPE'} || "";
652 if (!(system("fvwm-config --supports-multibyte") == 0 &&
655 if ($getMsg =~ /^\//) {
659 $file = "$localeDir/$lang/$getMsg.$msgExt" if ($lang ne "");
660 $file = "$localeDir/en/$getMsg.$msgExt" if (! -f $file);
663 my $file = "$getMsg.$msgExt";
664 print STDERR "[fvwm-themes]: Cannot find localized or default $file\n";
665 print "END 0003end\n";
669 open(MSG, $file) || die "Cannot open the msg for $getMsg: [$!]\n";
673 if (/([A-Za-z0-9]+)\s+\{(.*)\}\s*/) {
676 my $l1 = length($id);
677 my $l2 = length($msg) - 1;
678 my $l3 = length($l2);
681 $id = $id . " " x (12 - $l1);
683 $l2 = "0" x (4-$l3) . $l2;
684 $return .= $id . $l2 . $msg;
687 print $return . "END 0003end\n";
692 #----------------------------------------------------------------------------
693 # build the doc for FvwmScript-Help
695 # very simple HTML text parser, could be library function
696 # don't show this code to Mozilla, lynx or w3c developers
701 return "" if $lineLen <= 0;
704 my $blockIndentLen = 2; # probably 3 or 4 is better
706 my $olPrefix = "0. ";
707 my $headerData = [ # <h1> .. <h6>
708 # [ $isCentered, $dashChar ]
717 # we don't support tag parameters for now, skip them
718 $html =~ s/<(\w+)(\s+\w+(\s*=\s*([^>\s]*|"[^"]+?"))?)\s*>/<$1>/sg;
720 #" convert all whitespaces (currently <pre> is not supported)
723 # title may be supported later, so this function may return [title, body]
725 <(title|javascript|style)> .*? </(title|javascript|style)> \040*
731 # be sgml compliant about comments :-)
732 ( < [^>]+? ) -- .+? -- ( [^>]+ > )
738 $html =~ s/<[!?].*?> *//sg;
740 # support emphasis; how about *bold* and _underline_?
748 <blockquote> \040* (.*?) </blockquote> \040*
750 my $txt = "\n" . parseHtml($1, $lineLen - $blockIndentLen);
751 $txt =~ s/\n/"\n" . (" " x $blockIndentLen)/sge;
756 <h([1-6])> \040* (.*?) </h\d> \040*
758 my ($isCentered, $dashChar) = @{$headerData->[$1 - 1]};
761 $dashLine = ($dashChar x length($headLine)) . "\n" if defined $dashChar;
763 my $identLen = int(($lineLen - length($headLine)) / 2);
764 $identLen = 0 if $identLen < 0;
765 $headLine = (" " x $identLen) . $headLine;
766 $dashLine = (" " x $identLen) . $dashLine if $dashLine ne "";
768 "\n\n$headLine\n$dashLine\n"
771 # supporting a bad html is not guaranteed (<li> without <ul>)
773 my $listItemPrefixes = [ ];
779 if ($1 eq "p") { "\n\n" }
780 elsif ($1 eq "br") { "\n" }
781 elsif ($1 eq "ul") { $listItemPrefixes->[$listLevel++] = $ulPrefix; "\n" }
782 elsif ($1 eq "/ul") { $listLevel-- if $listLevel > 0; "\n\n" }
783 elsif ($1 eq "ol") { $listItemPrefixes->[$listLevel++] = $olPrefix; "\n" }
784 elsif ($1 eq "/ul") { $listLevel-- if $listLevel > 0; "\n\n" }
786 my $ident = " " x ($listLevel * $blockIndentLen);
787 if ($listItemPrefixes->[$listLevel - 1] =~ /^(\d+)(.*)$/) {
788 $listItemPrefixes->[$listLevel - 1] = ($1 + 1) . $2;
790 my $prefix = $listItemPrefixes->[$listLevel - 1];
796 # don't support more than 2 new-lines
797 $html =~ s/\n{3,}/\n\n/sg;
798 $html =~ s/^\n{2,}/\n/s;
800 # split long lines to shorter ones
805 while (($totalLen = length($line)) > $lineLen) {
807 while ($i >= 0 && substr($line, $i, 1) ne " ") { $i-- }
808 $i = $lineLen if $i < 0; # give up, split a word
809 $formatted .= substr($line, 0, $i) . "\n";
810 $line = substr($line, $i, $totalLen);
820 $lang = $ENV{'LANG'} if $lang eq "";
821 $lang = substr($lang, 0, 2);
822 my $fileExt = "html";
823 # migo: actually, I think that in a proper system, "fixed" alias already
824 # points to localized font, but this may be good to support any --lang.
825 # This info may be read from locale/LANG/fonts.cfg probably.
827 'en' => "-*-fixed-medium-r-semicondensed-*-13-*",
828 'ru' => "-cronyx-fixed-medium-r-semicondensed--*-*-*-*-*-*-koi8-*",
830 my $fontLang = exists $fixedFont{$lang}? $lang: 'en';
833 if ($inLineDoc =~ /^\//) {
836 $file = "$localeDir/$lang/$inLineDoc.$fileExt";
838 $file = "$localeDir/en/$inLineDoc.$fileExt" unless -f $file;
844 print "|Documentation is not found...\n";
848 print $fixedFont{"$fontLang"} . "|";
850 my $contentRef = loadFile($file);
851 my $parsedText = parseHtml($$contentRef, $lineLength);
853 print join("|", split("\n", $parsedText)) . "\n";
857 # this function should be removed later
860 $lang = $ENV{'LANG'} if $lang eq "";
866 $lang = substr($lang,0,2);
867 if ($inLineDoc =~ /^\//) {
871 $file = "$localeDir/$lang/$inLineDoc.$txtExt";
872 $file = "$localeDir/C/$inLineDoc.$txtExt" if (! -f $file);
873 $file = "$localeDir/en/$inLineDoc.$txtExt" if (! -f $file);
876 print "Documentation in progress ...";
879 #$doc = `fmt -w $lineLength $file`;
882 open(DOC,"$file") || die "cannot open the doc for $inLineDoc";
885 my $previousWasBlanc = 0;
892 if ($line =~ /^<verb>/) {
894 $doc .= "|" if $doc !~ /\|$/ || $previousWasBlanc;
897 if ($line =~ /^<\/verb>/) {
899 $previousWasBlanc = 1;
907 next if ($line =~ /^<abstract>/ || $line =~ /^<\/abstract>/);
909 if ($line =~ /^<title>/ || $line =~ /^<sec>/) {
911 $type = "s" if $line =~ /^<sec>/;
912 $line =~ s/^<title>\s*//;
913 $line =~ s/^<sec>\s*//;
918 $t = int (($lineLength - $l) / 2);
921 $doc .= "|" if $doc !~ /\|$/ || $previousWasBlanc;
922 $doc .= " "x$t . $line . "|" . " "x$t . "-"x$l ."|";
924 $previousWasBlanc = 1;
928 if ($line =~ /^\s*$/) {
933 $doc .= "|" if ($previousWasBlanc);
934 $previousWasBlanc = 1;
938 $previousWasBlanc = 0;
940 #my $space = substr($line,0,index($line," ")+1);
942 my $cl = length($line);
943 if ($cl + $l <= $lineLength) {
944 $doc .= " " if $doc !~ /\|$/;
949 my @larray = split(" ",$line);
953 if ($wl + $l + 1 <= $lineLength) {
954 $doc .= " " if $doc !~ /\|$/;
971 #----------------------------------------------------------------------------
974 my ($path, $lsOptions, $index, $dirsOnly, $filesOnly) = @_;
976 if ($path eq "PATH") { $path = $ENV{'PATH'} || '/bin'; }
977 my @dirList = grep { $_ && -d $_ } split(':', $path);
978 return "No such directory:|$path\n" unless @dirList;
983 foreach $dir (@dirList) {
984 open(LSPROC, "ls $lsOptions '$dir' |"); # pipe implies ls -1
988 $test =~ s/[@*\/=|]$// if $lsOptions =~ /F|--classify/;
989 #s/[@*\/=|]$// if $lsOptions =~ /F|--classify/ && $index > 0;
990 if (-d "$dir/$test") { push @dirs, $_; }
991 else { push @files, $_; }
996 if (@dirList) { @dirs = sort(@dirs); @files = sort(@files); }
997 my @items = ($dirsOnly? @dirs: $filesOnly? @files: (@dirs, @files));
999 $items[$index - 1] =~ s/[@*\/=|]$//
1000 if $lsOptions =~ /F|--classify/ && $index > 0;
1002 return ($index > 0? $items[$index - 1]: join("|", @items)) . "\n";
1006 sub checkExecInPath {
1008 my @pathDirs = split(':',$ENV{PATH});
1010 foreach $dir (@pathDirs) {
1011 if ( -x "$dir/$app" ) { return 1 }
1016 #----------------------------------------------------------------------------
1018 # the global feel com loop
1020 #----------------------------------------------------------------------------
1022 sub globalFeelComLoop {
1023 my $outFifo = ".tmp-com-out-" . $comName;
1024 my $inFifo = ".tmp-com-in-" . $comName;
1025 my $lockFifo = ".tmp-com-lock-" . $comName;
1029 my @components = ("globalfeel");
1031 # "files" and "script" config
1033 my $lastHardRead = "";
1035 my $saveState = { };
1038 # "themes" config init
1039 my $personalThemes = [ ];
1040 $personalThemes->[0] = "personal";
1041 my $themesConfig = { };
1042 my $currentConfig = { };
1043 my $optConfig = { };
1046 foreach (@components) {
1047 $saveState->{$_}->{'file'} = "$userDir/$themesSubDir/personal/$_";
1048 $saveState->{$_}->{'theme'} = "personal";
1049 $hardRead->{$_} = "";
1050 $currentConfig->{$_} = "default";
1053 # get "themes" config
1054 getThemesConfig($personalThemes,$themesConfig,$currentConfig,
1055 $optConfig,$hardRead);
1057 foreach $tmp (@components) {
1058 foreach (@$personalThemes) {
1059 if (defined $currentConfig->{$tmp} && $currentConfig->{$tmp} eq $_) {
1060 $saveState->{$tmp}->{'file'} = "$userDir/$themesSubDir/$_/$tmp";
1061 $saveState->{$tmp}->{'theme'} = "$_";
1067 my ($redMask,$greenMask,$blueMask) = getXdpyInfo();
1068 # persistante fvwm Config:
1069 my $internalConfig = { };
1071 chdir($userDir) || die "No FvwmConfigHome $userDir";
1074 myMakeFifo($lockFifo);
1079 local $SIG{ALRM} = \&checkScript;
1081 # block until com want to communicate
1082 open(LOCK,">$lockFifo") || die "cannot write fifo $lockFifo";
1086 if ($@ =~ /^cannot/) {
1087 print STDERR "$comName: cannot write fifo $lockFifo\n";
1088 unlink("$lockFifo");
1091 if ($@ =~ /^NoScript/) {
1092 print STDERR "$comName: No more FvwmScript-ConfigCenter: exit!\n";
1093 unlink("$lockFifo");
1096 if ($@ =~ /^Script/) {
1101 local $SIG{ALRM} = sub { die "Timeout" };
1103 # block unless com is ready to write on $outFifo
1104 open(IN,"$outFifo") || die "cannot open $outFifo";
1109 if ($@ =~ /^cannot/) {
1110 print STDERR "$comName: cannot read fifo $outFifo\n";
1114 if ($@ =~ /^Timeout/) {
1115 print STDERR "$comName: com give an unvalide unlock!\n";
1118 #print STDERR "msg com 2\n";
1119 #------------------------------------------------------------------------
1123 #-----------------------------------
1124 if ($command eq "get-perso-themes") {
1125 foreach (@$personalThemes) {
1130 #-----------------------------------
1131 elsif ($command =~ /^get-themes-info\s+(.+)$/) {
1133 $return .= "$saveState->{$comp}->{'theme'}\n";
1134 $return .= "$currentConfig->{$comp}\n";
1135 my $compCfg = $themesConfig->{$comp};
1136 my $themesList = "";
1138 foreach $k (sort keys %$compCfg) {
1139 $themesList .= "$k|";
1141 $themesList =~ s/\|$//;
1142 $return .= "$themesList\n";
1143 my $options = $optConfig->{$comp};
1145 if (ref($options) eq 'ARRAY') {
1146 foreach $opt (@$options) {
1147 $return .= "$opt->{'current'}\n";
1151 #--------------------------------------------------------
1152 elsif ($command =~ /^get-config\s+(.+)\s+(.+)\s+(.+)$/) {
1157 if ($comp eq "All") {
1158 @list = @components;
1164 foreach $ct (@list) {
1166 my $themeshash = $themesConfig->{$ct};
1167 if ($theme eq "current") {
1168 $t = $currentConfig->{$ct};
1170 elsif ($theme =~ /^\d+$/) {
1172 foreach (sort keys %$themeshash) {
1173 $t = $_ if $i == $theme;
1177 else { $t = $theme; }
1179 $file = $themeshash->{$t}->{'file'};
1180 if (defined $file && -f $file) {
1181 my $parseFunc = "parse_" . $ct . "_Config";
1182 my $configForScript = { };
1184 #print STDERR "$file, $theme, $ct\n";
1187 $parseFunc->($file,$configForScript,$keys,
1188 $internalConfig,$optConfig->{$ct});
1190 $error = "Internal: $@" if $@;
1191 $return .= "$error\n";
1193 $return .= "$configForScript->{$_}"
1194 if $_ eq $whichPart || $whichPart eq "All";
1198 $return = "config file for $ct\@$t not found!";
1203 #-------------------------------------------------------------
1204 elsif ($command eq "get-preferences") {
1205 $return = get_globalfeel_Preferences();
1207 #-------------------------------------------------------------
1208 elsif ($command =~ /^save-try-config\s+([A-Za-z0-9]+)\s+([A-Za-z0-9]+)\s+(\d)\s+(.+)$/) {
1211 my $configFromScript = $4;
1212 my $how = $3; # 0: check, 1: try, 2:save, 3: try and save
1213 my $buildFunc = "build_" . $comp . "_Config";
1214 my $fvwmConfig = { };
1219 $buildFunc->($configFromScript,$fvwmConfig,$error,$keys);
1221 my $err = $@ ? "Internal: $@|" : "";
1222 $err .= "$error->{All}|"
1223 if defined $error->{'All'} && $error->{'All'} ne "";
1225 $err .= "$error->{$_}|"
1226 if defined $error->{$_} && $error->{$_} ne "" &&
1227 ($_ eq $whichPart || $whichPart eq "All");
1230 $err = "ok" if $err eq "";
1231 $lastHardRead = $hardRead->{$comp};
1235 $lastBuild .= "$fvwmConfig->{$_}";
1237 $lastHardRead = $hardRead->{$comp};
1241 if ($how == 1 || $how == 3) {
1242 $return = $lastBuild;
1244 if ($how == 2 || $how == 3) {
1245 saveToFile($lastBuild,$saveState->{$comp}->{'file'});
1246 my $theme = $saveState->{$lastComp}->{'theme'};
1247 system("fvwm-themes-config --load $lastComp\@$theme &");
1251 #---------------------------------------------------
1252 elsif ($command =~ /^save-try-last-build\s+(\d)$/) {
1254 if ($how == 1 || $how == 3) {
1255 $return = $lastBuild . $lastHardRead;
1257 if ($how == 2 || $how == 3) {
1258 saveToFile($lastBuild,$saveState->{$lastComp}->{'file'});
1259 my $theme = $saveState->{$lastComp}->{'theme'};
1260 system("fvwm-themes-config --load $lastComp\@$theme &");
1263 # ---------------------------------------------------
1264 elsif ($command =~ /^set-save-file\s+(.+)\s+(\d+)$/) {
1267 $return = $personalThemes->[$i-1];
1268 $saveState->{$comp}->{'file'} =
1269 "$userDir/$themesSubDir/$return/$comp";
1270 $saveState->{$comp}->{'theme'} = $return;
1272 # ---------------------------------------------------
1273 elsif ($command =~ /^hexcolor-2-value\s+\#([a-fA-F0-9][a-fA-F0-9])([a-fA-F0-9][a-fA-F0-9])([a-fA-F0-9][a-fA-F0-9])$/) {
1277 if ($redMask*$greenMask*$blueMask != 0) {
1278 $b = int( $b * ($blueMask+1) / 256);
1279 $g = $g * ( (1+($greenMask/($blueMask+1))) / 256 );
1280 $g = int($g) * ($blueMask + 1);
1281 #$r = int( $r * $redMask / 255 );
1282 $r = $r * ( (1+($redMask/($greenMask+$blueMask+1))) / 256 );
1283 $r = int($r) * ($greenMask + $blueMask + 1);
1284 $return = $r + $g +$b;
1285 $return = 1 if $return == 0;
1288 # ---------------------------------------------------
1289 elsif ($command =~ /^value-2-hexcolor\s+(.*)$/) {
1293 if ($d =~ /^\d+/ && $redMask*$greenMask*$blueMask != 0) {
1294 my ($r,$g,$b) = (0, 0, 0);
1295 $r = int ( $d / ($greenMask + $blueMask + 1));
1296 $d = $d - $r * ($greenMask + $blueMask + 1);
1297 $r = int( $r*255 / ($redMask/($greenMask + $blueMask + 1)) );
1298 $g = int ( $d / ($blueMask + 1));
1299 $d = $d - $g * ($blueMask + 1);
1300 $g = int ( $g*255 / ($greenMask/($blueMask + 1)) );
1301 $b = int ( $d*255 / $blueMask );
1302 $r = 255 if $r > 255;
1303 $g = 255 if $g > 255;
1304 $b = 255 if $b > 255;
1305 $return = "#". int2hex($r) . int2hex($g) . int2hex($b);
1308 # --------------------------
1309 elsif ($command =~ /^save-preferences\s+(\d+)(\d+)(\d+)$/) {
1310 my $pref = "TryIsGlobal=$1\nDefaultIsGlobal=$2\nSaveIsGlobal=$3\n";
1311 saveToFile($pref,"$userDir/.FvwmScript-GlobalFeel");
1313 # --------------------------
1314 elsif ($command eq "exit") {
1319 print STDERR "$comName: unknown command $command\n";
1322 #------------------------------------------------------------------------
1324 myMakeFifo($inFifo);
1326 local $SIG{ALRM} = sub { die "Timeout" };
1328 # this line block until com take the answer
1329 open(OUT,">$inFifo") || die "cannot write fifo $inFifo";
1331 print OUT "ok\n" . $return;
1335 if ($@ =~ /cannot/) {
1336 print STDERR "$comName: cannot write on fifo $inFifo\n";
1341 if ($@ =~ /Timeout/) {
1342 print STDERR "$comName: com do not read my answer!\n";
1347 #----------------------------------------------------------------------------
1348 # An alarm handler (called from eval block):
1351 die "Script" unless ($comPid);
1354 my $lockFifo = ".tmp-com-lock-" . $comName;
1356 $test = 1 if kill 0 => $comPid;
1358 if ($test) { die "Script"; }
1359 else { unlink($lockFifo) if -p "$lockFifo"; die "NoScript"; }
1362 #-----------------------------------------------------------------------------
1366 system("mkfifo '$fifo'"); # not portable: mknod '$fifo' p
1369 #-----------------------------------------------------------------------------
1370 # For killing FvwmScript-ConfigCenter if an error happen in this script!
1374 my $lockFifo = ".tmp-com-lock-" . $comName;
1375 my $inFifo = ".tmp-com-in-" . $comName;
1376 my $message = "fvwm-themes-script: internal error $?\n";
1377 # actually $@ is never defined in END
1378 $message .= "\teval error: $@\n" if $@;
1379 $message .= "\tOS error: $!\n" if $!;
1380 # actually the following is never executed on unix
1381 $message .= "\tOS error 2: $^E\n" if $^E && !($! && $^E eq $!);
1383 unlink($lockFifo) if -p "$lockFifo";
1384 unlink($inFifo) if -p "$lockFifo";
1387 $message .= "\tkilling FvwmScript-ConfigCenter";
1389 print STDERR "$message\n";
1394 # -----------------------------------------------------------------------------
1395 # get the themes info from fvwm-themes-config
1397 sub getThemesConfig {
1398 my $personalThemes = shift;
1399 my $themesConfig = shift;
1400 my $currentConfig = shift;
1401 my $optConfig = shift;
1402 my $hardRead = shift;
1404 my $in = `fvwm-themes-config --config-center`;
1406 my @input = split(/\n/, $in);
1415 while(defined $input[$i]) {
1416 if ($input[$i] =~ /^configuration of (.+) for the Config Center$/) {
1423 if ($input[$i] =~ /END/) { $inHardRead = 0 }
1424 else { $hardRead->{'globalfeel'} .= "$input[$i]\n" }
1428 if ($input[$i] =~ /^OPTIONS/) {
1435 if ($input[$i] =~ /^END/) { $inOptions = 0 }
1437 my ($tmp1,$tmp2) = split (":",$input[$i]);
1438 $optConfig->{$comp}->[$o]->{'file'} = $tmp1;
1439 $optConfig->{$comp}->[$o]->{'current'} = $tmp2;
1446 if ($input[$i] ne "personal") {
1447 $personalThemes->[$k] = $input[$i];
1454 $currentConfig->{$comp} = $input[$i];
1459 $theme = $input[$i];
1464 $themesConfig->{$comp}->{$theme}->{'file'} = "$input[$i]";
1472 #----------------------------------------------------------------------------
1473 # get the globalfeel preferences
1475 sub get_globalfeel_Preferences {
1476 my $file = "$userDir/.FvwmScript-GlobalFeel";
1478 return "000" if (! -f $file);
1480 my $tryIsGlobal = 0;
1481 my $defaultIsGlobal = 0;
1482 my $saveIsGlobal = 0;
1486 if ($_ =~ /^TryIsGlobal=(\d+)$/) {
1489 elsif ($_ =~ /^DefaultIsGlobal=(\d+)$/) {
1490 $defaultIsGlobal = $1;
1492 elsif ($_ =~ /^SaveIsGlobal=(\d+)$/) {
1497 return "$tryIsGlobal$defaultIsGlobal$saveIsGlobal";
1500 #----------------------------------------------------------------------------
1501 # build globalfeel from a sequence
1503 sub build_globalfeel_Config {
1504 my $configFromScript = shift;
1505 my $fvwmConfig = shift;
1510 my ($tmp,$tmp2,$hide,$x,$y);
1511 my $impossible = "An Impossible error happen, GASP!";
1513 @$keys = ("Focus", "Move", "Paging", "Transient", "Hints");
1515 # check for the good number of "!"
1516 my @test = split(/!/,$configFromScript);
1519 "Why do you enter a ! in a field where you have to enter numbers? ($#test)|";
1522 # -------------------------------------------- Focus
1523 $fvwmConfig->{'Focus'} .=
1524 "\n# -------------------------- Focus and Placement ".
1525 "--------------------------\n\n";
1526 $tmp = substr($configFromScript,$index,1);
1527 if ($tmp == 1) { $fvwmConfig->{'Focus'} .= "Style * ClickToFocus" }
1528 elsif ($tmp == 2) { $fvwmConfig->{'Focus'} .= "Style * MouseFocus" }
1529 elsif ($tmp == 3) { $fvwmConfig->{'Focus'} .= "Style * SloppyFocus" }
1530 else { $err->{'Focus'} .= "$impossible|" }
1533 $tmp = substr($configFromScript,$index,1);
1534 if ($tmp == 1) { $fvwmConfig->{'Focus'} .= ", ClickToFocusPassesClick" }
1535 elsif ($tmp == 0) { $fvwmConfig->{'Focus'} .= ", ClickToFocusPassesClickOff"}
1536 else { $err->{'Focus'} .= "$impossible|" }
1539 $tmp = substr($configFromScript,$index,1);
1541 $fvwmConfig->{'Focus'} .= ", ClickToFocusRaises, MouseFocusClickRaises"
1544 $fvwmConfig->{'Focus'} .=
1545 ", ClickToFocusRaisesOff, MouseFocusClickRaisesOff"
1547 else { $err->{'Focus'} .= "$impossible|" }
1548 $fvwmConfig->{'Focus'} .= "\n";
1551 $tmp = substr($configFromScript,$index,1);
1552 if ($tmp == 1) { $fvwmConfig->{'Focus'} .= "ColormapFocus FollowsFocus\n" }
1553 elsif ($tmp == 0) { $fvwmConfig->{'Focus'} .= "ColormapFocus FollowsMouse\n"}
1554 else { $err->{'Focus'} .= "$impossible|" }
1557 $tmp = substr($configFromScript,$index,1);
1559 $fvwmConfig->{'Focus'} .=
1560 "Style * TileCascadePlacement"
1563 $fvwmConfig->{'Focus'} .=
1564 "Style * TileManualPlacement"
1567 $fvwmConfig->{'Focus'} .=
1568 "Style * MinOverlapPlacement"
1571 $fvwmConfig->{'Focus'} .=
1572 "Style * MinOverlapPercentPlacement"
1575 $fvwmConfig->{'Focus'} .=
1576 "Style * ManualPlacement"
1579 $fvwmConfig->{'Focus'} .=
1580 "Style * CascadePlacement"
1582 else { $err->{'Focus'} .= "$impossible|" }
1585 $tmp = substr($configFromScript,$index,1);
1586 if ($tmp == 1) { $fvwmConfig->{'Focus'} .= ", GrabFocus" }
1587 elsif ($tmp == 0) { $fvwmConfig->{'Focus'} .= ", GrabFocusOff" }
1588 else { $err->{'Focus'} .= "$impossible|" }
1591 $tmp = substr($configFromScript,$index,1);
1592 if ($tmp == 1) { $fvwmConfig->{'Focus'} .= ", UsePPosition" }
1593 elsif ($tmp == 0) { $fvwmConfig->{'Focus'} .= ", NoPPosition" }
1594 else { $err->{'Focus'} .= "$impossible|" }
1595 $fvwmConfig->{'Focus'} .= "\n";
1597 # ----------------------------------------------- Move
1598 $fvwmConfig->{'Move'} .=
1599 "\n# ---------------------------- Move and Resize ".
1600 "----------------------------\n\n";
1602 $tmp = substr($configFromScript,$index,1);
1603 if ($tmp == 0) { $fvwmConfig->{'Move'} .= "Style * ResizeOpaque\n" }
1604 elsif ($tmp == 1) { $fvwmConfig->{'Move'} .= "Style * ResizeOutLine\n" }
1605 else { $err->{'Move'} .= "$impossible|" }
1608 $tmp = substr($configFromScript,$index,index($configFromScript,"!")-$index);
1609 $index += length($tmp)+1;
1610 $configFromScript = substr($configFromScript,$index);
1612 if ($tmp =~ /^\d+$/) { $fvwmConfig->{'Move'} .= "OpaqueMoveSize $tmp\n" }
1614 $err->{'Move'} = "Percentage for opaque move size must be an integer|";
1618 $tmp = substr($configFromScript,$index,1);
1619 if ($tmp == 0) { $fvwmConfig->{'Move'} .= "Emulate MWM\n" }
1620 elsif ($tmp == 1) { $fvwmConfig->{'Move'} .= "Emulate FVWM\n" }
1621 else { $err->{'Move'} .= "$impossible|" }
1624 $tmp = substr($configFromScript,$index,1);
1626 if ($tmp == 1) { $hide = 1 }
1627 elsif ($tmp == 0) {}
1628 else { $err->{'Move'} .= "$impossible|" }
1631 $tmp = substr($configFromScript,$index,1);
1632 if ($tmp == 1) { $hide = ($hide) ? 3 : 2 }
1633 elsif ($tmp == 0) {}
1634 else { $err->{'Move'} .= "$impossible|" }
1635 if ($hide == 0) {$fvwmConfig->{'Move'} .= "HideGeometryWindow Never\n" }
1636 elsif ($hide == 1) {$fvwmConfig->{'Move'} .= "HideGeometryWindow Resize\n" }
1637 elsif ($hide == 2) {$fvwmConfig->{'Move'} .= "HideGeometryWindow Move\n" }
1638 else { $fvwmConfig->{'Move'} .= "HideGeometryWindow\n" }
1641 $tmp = substr($configFromScript,$index,1);
1643 $fvwmConfig->{'Move'} .= "BugOpts FlickeringMoveWorkaround Off\n"
1646 $fvwmConfig->{'Move'} .= "BugOpts FlickeringMoveWorkaround On\n"
1648 else { $err->{'Move'} .= "$impossible|" }
1651 $tmp = substr($configFromScript,$index,index($configFromScript,"!")-$index);
1652 $index += length($tmp)+1;
1653 $configFromScript = substr($configFromScript,$index);
1655 $tmp = 0 if $tmp eq "";
1656 if ($tmp =~ /^\d+$/) { $fvwmConfig->{'Move'} .= "SnapAttraction $tmp " }
1658 $err->{'Move'} = "Distance for snap attraction must be an integer >= 0|";
1661 $tmp = substr($configFromScript,$index,1);
1662 if ($tmp == 1 || $tmp == 5) { $fvwmConfig->{'Move'} .= "All" }
1663 elsif ($tmp == 2 || $tmp == 6) { $fvwmConfig->{'Move'} .= "SameType" }
1664 elsif ($tmp == 3 || $tmp == 7) { $fvwmConfig->{'Move'} .= "Windows" }
1665 elsif ($tmp == 4 || $tmp == 8) { $fvwmConfig->{'Move'} .= "Icons" }
1666 else { $err->{'Move'} .= "$impossible" }
1667 if ($tmp >= 5) { $fvwmConfig->{'Move'} .= " Screen" }
1668 $fvwmConfig->{'Move'} .= "\n";
1671 $tmp = substr($configFromScript,$index,index($configFromScript,"!")-$index);
1672 $index += length($tmp)+1;
1673 $configFromScript = substr($configFromScript,$index);
1675 $tmp = 0 if $tmp eq "";
1676 if ($tmp =~ /^\d+$/) { $fvwmConfig->{'Move'} .= "SnapGrid $tmp " }
1678 $err->{'Move'} .= "X attraction grid coordinate must be an integer >= 0|";
1681 $tmp = substr($configFromScript,$index,index($configFromScript,"!")-$index);
1682 $index += length($tmp)+1;
1683 $configFromScript = substr($configFromScript,$index);
1685 $tmp = 0 if $tmp eq "";
1686 if ($tmp =~ /^\d+$/) { $fvwmConfig->{'Move'} .= "$tmp" }
1688 $err->{'Move'} .= "Y attraction grid coordinate must be an integer >= 0|";
1690 $fvwmConfig->{'Move'} .= "\n";
1692 $tmp = substr($configFromScript,$index,1);
1693 if ($tmp == 0) { $fvwmConfig->{'Move'} .= "XorValue " }
1694 elsif ($tmp == 1) { $fvwmConfig->{'Move'} .= "XorPixmap " }
1695 else { $err->{'Move'} .= "$impossible|" }
1698 $tmp = substr($configFromScript,$index,index($configFromScript,"!")-$index);
1699 $index += length($tmp)+1;
1700 $configFromScript = substr($configFromScript,$index);
1702 $fvwmConfig->{'Move'} .= "$tmp\n";
1704 # ------------------------------------------ Paging
1705 $fvwmConfig->{'Paging'} .=
1706 "\n# ---------------------- Paging and Mouse Parameters ".
1707 "----------------------\n\n";
1708 $tmp = substr($configFromScript,$index,1);
1710 $tmp2 = substr($configFromScript,$index,1);
1711 $tmp2 = ($tmp2) ? 1000 : 1;
1713 if ($tmp == 0) { $x = 0 }
1714 elsif ($tmp == 1) { $x = 100 * $tmp2 }
1715 elsif ($tmp == 2) { $x = 90 * $tmp2 }
1716 elsif ($tmp == 3) { $x = 75 * $tmp2 }
1717 elsif ($tmp == 4) { $x = 66 * $tmp2 }
1718 elsif ($tmp == 5) { $x = 50 * $tmp2 }
1719 elsif ($tmp == 6) { $x = 33 * $tmp2 }
1720 elsif ($tmp == 7) { $x = 25 * $tmp2 }
1721 elsif ($tmp == 8) { $x = 10 * $tmp2 }
1722 elsif ($tmp == 9) { $x = 5 * $tmp2 }
1723 else { $err->{'Paging'} .= "$impossible|" }
1726 $tmp = substr($configFromScript,$index,1);
1728 $tmp2 = substr($configFromScript,$index,1);
1729 $tmp2 = ($tmp2) ? 1000 : 1;
1731 if ($tmp == 0) { $y = 0 }
1732 elsif ($tmp == 1) { $y = 100 * $tmp2 }
1733 elsif ($tmp == 2) { $y = 90 * $tmp2 }
1734 elsif ($tmp == 3) { $y = 75 * $tmp2 }
1735 elsif ($tmp == 4) { $y = 66 * $tmp2 }
1736 elsif ($tmp == 5) { $y = 50 * $tmp2 }
1737 elsif ($tmp == 6) { $y = 33 * $tmp2 }
1738 elsif ($tmp == 7) { $y = 25 * $tmp2 }
1739 elsif ($tmp == 8) { $y = 10 * $tmp2 }
1740 elsif ($tmp == 9) { $y = 5 * $tmp2 }
1741 else { $err->{'Paging'} .= "$impossible|" }
1742 $fvwmConfig->{'Paging'} .= "EdgeScroll $x $y\n";
1745 $tmp = substr($configFromScript,$index,index($configFromScript,"!")-$index);
1746 $index += length($tmp)+1;
1747 $configFromScript = substr($configFromScript,$index);
1749 $tmp = 0 if $tmp eq "";
1750 if ($tmp =~ /^\d+$/) { $x = "$tmp " }
1751 else { $err->{'Paging'} = "Paging delay must be an integer >= 0|" }
1753 $tmp = substr($configFromScript,$index,index($configFromScript,"!")-$index);
1754 $index += length($tmp)+1;
1755 $configFromScript = substr($configFromScript,$index);
1757 $tmp = 0 if $tmp eq "";
1758 if ($tmp =~ /^\d+$/) { $y = "$tmp " }
1759 else { $err->{'Paging'} = "Moving resistance must be an integer >= 0|" }
1760 $fvwmConfig->{'Paging'} .= "EdgeResistance $x $y\n";
1762 $tmp = substr($configFromScript,$index,1);
1763 if ($tmp == 1) { $fvwmConfig->{'Paging'} .= "EdgeThickness 1\n" }
1764 elsif ($tmp == 2) { $fvwmConfig->{'Paging'} .= "EdgeThickness 1\n" }
1765 else { $err->{'Paging'} .= "$impossible|" }
1768 $tmp = substr($configFromScript,$index,index($configFromScript,"!")-$index);
1769 $index += length($tmp)+1;
1770 $configFromScript = substr($configFromScript,$index);
1772 $tmp = 150 if $tmp eq "";
1773 if ($tmp =~ /^\d+$/) { $fvwmConfig->{'Paging'} .= "ClickTime $tmp\n" }
1774 else { $err->{'Paging'} = "Double Click time must be an integer >= 0|" }
1776 $tmp = substr($configFromScript,$index,index($configFromScript,"!")-$index);
1777 $index += length($tmp)+1;
1778 $configFromScript = substr($configFromScript,$index);
1780 $tmp = 3 if $tmp eq "";
1781 if ($tmp =~ /^\d+$/) { $fvwmConfig->{'Paging'} .= "MoveThreshold $tmp\n" }
1782 else { $err->{'Paging'} = "Move Threshold must be an integer >= 0|" }
1784 # ----------------------------------------------- Transient
1785 $fvwmConfig->{'Transient'} .=
1786 "\n# -------------------- Transient Windows and Animation ".
1787 "--------------------\n\n";
1788 $tmp = substr($configFromScript,$index,1);
1790 $fvwmConfig->{'Transient'} .= "Style * DecorateTransient"
1793 $fvwmConfig->{'Transient'} .= "Style * NakedTransient"
1795 else { $err->{'Transient'} .= "$impossible|" }
1798 $tmp = substr($configFromScript,$index,1);
1799 if ($tmp == 0) { $fvwmConfig->{'Transient'} .= ", DontRaiseTransient" }
1800 elsif ($tmp == 1) { $fvwmConfig->{'Transient'} .= ", RaiseTransient" }
1801 else { $err->{'Transient'} .= "$impossible|" }
1804 $tmp = substr($configFromScript,$index,1);
1805 if ($tmp == 0) { $fvwmConfig->{'Transient'} .= ", DontLowerTransient" }
1806 elsif ($tmp == 1) { $fvwmConfig->{'Transient'} .= ", LowerTransient" }
1807 else { $err->{'Transient'} .= "$impossible|" }
1810 $tmp = substr($configFromScript,$index,1);
1811 if ($tmp == 0) { $fvwmConfig->{'Transient'} .= ", DontStackTransientParent"}
1812 elsif ($tmp == 1) { $fvwmConfig->{'Transient'} .= ", StackTransientParent" }
1813 else { $err->{'Transient'} .= "$impossible|" }
1816 $tmp = substr($configFromScript,$index,1);
1817 if ($tmp == 0) { $fvwmConfig->{'Transient'} .= ", GrabFocusTransientOff" }
1818 elsif ($tmp == 1) { $fvwmConfig->{'Transient'} .= ", GrabFocusTransient" }
1819 else { $err->{'Transient'} .= "$impossible|" }
1820 $fvwmConfig->{'Transient'} .= "\n";
1823 $tmp = substr($configFromScript,$index,index($configFromScript,"!")-$index);
1824 $index += length($tmp)+1;
1825 $configFromScript = substr($configFromScript,$index);
1827 $tmp = 20 if $tmp eq "";
1828 if ($tmp =~ /^\d+$/) {
1829 $fvwmConfig->{'Transient'} .= "Style * WindowShadeSteps $tmp"
1831 else { $err->{'Transient'} = "Shade step must be an integer >= 0|" }
1833 $tmp = substr($configFromScript,$index,1);
1834 if ($tmp == 1) { $fvwmConfig->{'Transient'} .= ", WindowShadeScrolls" }
1835 elsif ($tmp == 0) { $fvwmConfig->{'Transient'} .= ", WindowShadeShrinks" }
1836 else { $err->{'Transient'} .= "$impossible|" }
1837 $fvwmConfig->{'Transient'} .= "\n";
1840 $tmp = substr($configFromScript,$index,index($configFromScript,"!")-$index);
1841 $index += length($tmp)+1;
1842 $configFromScript = substr($configFromScript,$index);
1844 $tmp = 10 if $tmp eq "";
1845 if ($tmp =~ /^\d+$/) { $fvwmConfig->{'Transient'} .= "SetAnimation $tmp " }
1846 else { $err->{'Transient'} = "Animation speed must be an integer >= 0|" }
1848 $tmp = substr($configFromScript,$index,index($configFromScript,"!")-$index);
1849 $index += length($tmp)+1;
1850 $configFromScript = substr($configFromScript,$index);
1852 @list = split(/\s+/,$tmp);
1854 foreach (@list) { $tmp2 = 0 if $_ !~ /^-?\d*\.?\d*$/ }
1855 if ($tmp2) { $fvwmConfig->{'Transient'} .= " $tmp" }
1857 $err->{'Transient'} =
1858 "Animation Steps must be a sequence of < 17 rationals around 0 to 1|"
1860 $fvwmConfig->{'Transient'} .= "\n";
1862 # ----------------------------------------------- Hints
1863 $fvwmConfig->{'Hints'} .=
1864 "\n# -------------------- Hints, Busy Cursor and Advanced ".
1865 "--------------------\n\n";
1866 $tmp = substr($configFromScript,$index,1);
1867 if ($tmp == 0) { $fvwmConfig->{'Hints'} .= "Style * NoDecorHint" }
1868 elsif ($tmp == 1) { $fvwmConfig->{'Hints'} .= "Style * MwmDecor" }
1869 else { $err->{'Hints'} .= "$impossible|" }
1872 $tmp = substr($configFromScript,$index,1);
1873 if ($tmp == 0) { $fvwmConfig->{'Hints'} .= ", NoOLDecor" }
1874 elsif ($tmp == 1) { $fvwmConfig->{'Hints'} .= ", OLDecor" }
1875 else { $err->{'Hints'} .= "$impossible|" }
1878 $tmp = substr($configFromScript,$index,1);
1879 if ($tmp == 0) { $fvwmConfig->{'Hints'} .= ", HintOverride" }
1880 elsif ($tmp == 1) { $fvwmConfig->{'Hints'} .= ", NoOverride" }
1881 else { $err->{'Hints'} .= "$impossible|" }
1884 $tmp = substr($configFromScript,$index,1);
1885 if ($tmp == 0) { $fvwmConfig->{'Hints'} .= ", NoFuncHint" }
1886 elsif ($tmp == 1) { $fvwmConfig->{'Hints'} .= ", MwmFunctions" }
1887 else { $err->{'Hints'} .= "$impossible|" }
1890 $tmp = substr($configFromScript,$index,1);
1891 if ($tmp == 0) { $fvwmConfig->{'Hints'} .= ", GNOMEIgnoreHints" }
1892 elsif ($tmp == 1) { $fvwmConfig->{'Hints'} .= ", GNOMEUseHints" }
1893 else { $err->{'Hints'} .= "$impossible|" }
1894 $fvwmConfig->{'Hints'} .= "\n";
1897 $tmp = substr($configFromScript,$index,1);
1898 if ($tmp == 0) { $fvwmConfig->{'Hints'} .= "BugOpts ModalityIsEvil off\n" }
1899 elsif ($tmp == 1) { $fvwmConfig->{'Hints'} .= "BugOpts ModalityIsEvil on\n" }
1900 else { $err->{'Hints'} .= "$impossible|" }
1903 $tmp = substr($configFromScript,$index,1);
1904 if ($tmp == 0) { $fvwmConfig->{'Hints'} .= "BusyCursor Read off" }
1905 elsif ($tmp == 1) { $fvwmConfig->{'Hints'} .= "BusyCursor Read on" }
1906 else { $err->{'Hints'} .= "$impossible|" }
1909 # Need to be "fixed" in other places ...
1910 $tmp = substr($configFromScript,$index,1);
1912 #$fvwmConfig->{'Hints'} .= ", Recapture off"
1915 #$fvwmConfig->{'Hints'} .= ", Recapture on"
1917 else { $err->{'Hints'} .= "$impossible|" }
1920 $tmp = substr($configFromScript,$index,1);
1921 if ($tmp == 0) { $fvwmConfig->{'Hints'} .= ", Wait off" }
1922 elsif ($tmp == 1) { $fvwmConfig->{'Hints'} .= ", Wait on" }
1923 else { $err->{'Hints'} .= "$impossible|" }
1926 $tmp = substr($configFromScript,$index,1);
1927 if ($tmp == 0) { $fvwmConfig->{'Hints'} .= ", ModuleSynchronous off" }
1928 elsif ($tmp == 1) { $fvwmConfig->{'Hints'} .= ", ModuleSynchronous on" }
1929 else { $err->{'Hints'} .= "$impossible|" }
1930 $fvwmConfig->{'Hints'} .= "\n";
1933 $tmp = substr($configFromScript,$index,1);
1934 if ($tmp == 1) { $fvwmConfig->{'Hints'} .= "# Automatic detection of the color limit\n" }
1935 elsif ($tmp == 2) { $fvwmConfig->{'Hints'} .= "ColorLimit 2\n" }
1936 elsif ($tmp == 3) { $fvwmConfig->{'Hints'} .= "ColorLimit 9\n" }
1937 elsif ($tmp == 4) { $fvwmConfig->{'Hints'} .= "ColorLimit 19\n" }
1938 elsif ($tmp == 5) { $fvwmConfig->{'Hints'} .= "ColorLimit 29\n" }
1939 elsif ($tmp == 6) { $fvwmConfig->{'Hints'} .= "ColorLimit 39\n" }
1940 elsif ($tmp == 7) { $fvwmConfig->{'Hints'} .= "ColorLimit 49\n" }
1941 elsif ($tmp == 8) { $fvwmConfig->{'Hints'} .= "ColorLimit 61\n" }
1942 elsif ($tmp == 9) { $fvwmConfig->{'Hints'} .= "ColorLimit 0\n" }
1943 else { $err->{'Hints'} .= "$impossible|" }
1946 $tmp = substr($configFromScript,$index,1);
1948 $fvwmConfig->{'Hints'} .= "BugOpts MixedVisualWorkaround off\n"
1951 $fvwmConfig->{'Hints'} .= "BugOpts MixedVisualWorkaround on\n"
1953 else { $err->{'Hints'} .= "$impossible|" }
1956 $tmp = substr($configFromScript,$index,1);
1958 $fvwmConfig->{'Hints'} .= "BugOpts RaiseOverNativeWindows off\n"
1961 $fvwmConfig->{'Hints'} .= "BugOpts RaiseOverNativeWindows on\n"
1963 else { $err->{'Hints'} .= "$impossible|" }
1966 $tmp = substr($configFromScript,$index,1);
1967 if ($tmp == 0) { $fvwmConfig->{'Hints'} .= "Style * SaveUnderOff" }
1968 elsif ($tmp == 1) { $fvwmConfig->{'Hints'} .= "Style * SaveUnder"}
1969 else { $err->{'Hints'} .= "$impossible|" }
1972 $tmp = substr($configFromScript,$index,1);
1973 if ($tmp == 0) { $fvwmConfig->{'Hints'} .= ", BackingStoreOff" }
1974 elsif ($tmp == 1) { $fvwmConfig->{'Hints'} .= ", BackingStore" }
1975 else { $err->{'Hints'} .= "$impossible|" }
1976 $fvwmConfig->{'Hints'} .= "\n";
1979 $tmp = substr($configFromScript,$index,1);
1980 if ($tmp == 1) { $fvwmConfig->{'Hints'} .= "ModuleTimeout 2\n" }
1981 elsif ($tmp == 2) { $fvwmConfig->{'Hints'} .= "ModuleTimeout 5\n" }
1982 elsif ($tmp == 3) { $fvwmConfig->{'Hints'} .= "ModuleTimeout 7\n" }
1983 elsif ($tmp == 4) { $fvwmConfig->{'Hints'} .= "ModuleTimeout 10\n" }
1984 elsif ($tmp == 5) { $fvwmConfig->{'Hints'} .= "ModuleTimeout 15\n" }
1985 elsif ($tmp == 6) { $fvwmConfig->{'Hints'} .= "ModuleTimeout 30\n" }
1986 elsif ($tmp == 7) { $fvwmConfig->{'Hints'} .= "ModuleTimeout 45\n" }
1987 elsif ($tmp == 8) { $fvwmConfig->{'Hints'} .= "ModuleTimeout 60\n" }
1988 elsif ($tmp == 8) { $fvwmConfig->{'Hints'} .= "ModuleTimeout 120\n" }
1990 else { $err->{'Hints'} .= "$impossible|" }
1994 #-----------------------------------------------------------------------------
1995 # Parse globalfeel file and build a sequence "for" FvwmScript
1997 sub parse_globalfeel_Config {
1999 my $configForScript = shift;
2003 default_globalfeel_Config($config);
2004 @$keys = ("Focus", "Move", "Paging", "Transient", "Hints");
2006 open(FILE,"$file") || return "Err: cannot open $file";
2009 my $oldPlacement = 0;
2013 if ( /\\$/ && ! /\\\\$/) {
2015 $multiline = $multiline . $_;
2018 $line= $multiline . $_;
2021 # remove starting blanc:
2024 next if $line =~ /^\#/;
2026 $line =~ s/\s+\#.*$//;
2029 if ($line =~ /^ColormapFocus\s+FollowsMouse/i) {
2030 $config->{'colormapmouse'} = 0
2032 elsif ($line =~ /^ColormapFocus\s+FollowsFocus/i) {
2033 $config->{'colormapmouse'} = 1
2035 elsif ($line =~ /^OpaqueMoveSize/i) {
2036 if ($line =~ /^OpaqueMoveSize\s+(\d+)/i) {
2037 $config->{'OpaqueMoveSize'} = $1
2040 $config->{'OpaqueMoveSize'} = 5
2043 elsif ($line =~ /^Emulate/i) {
2044 if ($line =~ /^Emulate\s+mwm/i) {
2045 $config->{'emulate'} = 0
2048 $config->{'emulate'} = 1
2051 elsif ($line =~ /^HideGeometryWindow\s+(.*)/i) {
2056 $config->{'hidemove'} = 0; $config->{'hideresize'} = 0
2058 elsif (/^Move/) { $config->{'hidemove'} = 1 }
2059 elsif (/^Resize/) { $config->{'hideresize'} = 1 }
2062 elsif ($line =~ /^SnapAttraction\s+([-]*\d+)\s*(\w*)\s*(.*)/i) {
2065 $config->{'snapdistance'} = $1;
2066 $type = $2 if defined $2;
2067 $screen = 1 if defined $3 && $3 =~ /^screen/i;
2068 if ($type =~ /^All$/i) {
2069 $config->{'snapbehavior'} = 1
2071 elsif ($type =~ /^SameType$/i) {
2072 $config->{'snapbehavior'} = 2
2074 elsif ($type =~ /^Windows$/i) {
2075 $config->{'snapbehavior'} = 3
2077 elsif ($type =~ /^Icons$/i) {
2078 $config->{'snapbehavior'} = 4
2080 $config->{'snapbehavior'} += 4 if ($screen eq "1");
2082 elsif ($line =~ /^SnapGrid\s+(\d+)\s+(\d+)/i) {
2083 $config->{'snap_X'} = $1;
2084 $config->{'snap_Y'} = $2;
2086 elsif ($line =~ /^BugOpts\s+(.+)$/i) {
2088 while($token ne "") {
2089 my $opt = getNextToken(\$token);
2090 my $bool = getBoolArg(\$token);
2091 if ($opt =~ /^FlickeringMoveWorkaround$/i) {
2092 $config->{'FlickeringMoveWorkaround'} = ($bool eq "1") ? 1:0;
2094 elsif ($opt =~ /^ModalityIsEvil$/i) {
2095 $config->{'ModalityIsEvil'} = ($bool eq "0") ? 0:1;
2097 elsif ($opt =~ /^MixedVisualWorkaround$/i) {
2098 $config->{'MixedVisualWorkaround'} = ($bool eq "1") ? 1:0;
2100 elsif ($opt =~ /^RaiseOverNativeWindow$/i) {
2101 $config->{'RaiseOverNativeWindows'} = ($bool eq "1") ? 1:0;
2105 elsif ($line =~ /^xorvalue\s+(\d+)$/i) {
2106 $config->{'xor'}= 0;
2107 $config->{'xor_value'}= $1;
2109 elsif ($line =~ /^xorpixmap\s+(.+)$/i) {
2110 $config->{'xor'}= 1;
2111 $config->{'xor_pixmap'}= $1;
2113 elsif ($line =~ /^BusyCursor\s+(.+)$/i) {
2115 while($token ne "") {
2116 my $opt = getNextToken(\$token);
2117 my $bool = getBoolArg(\$token);
2118 next if $bool != 0 && $bool != 1;
2119 if ($opt =~ /^Read$/i) {
2120 $config->{'Busy_Read'}=$bool;
2122 elsif ($opt =~ /^Read$/i) {
2123 $config->{'Busy_Recapture'}=$bool;
2125 elsif ($opt =~ /^Recapture$/i) {
2126 $config->{'Busy_Recapture'}=$bool;
2128 elsif ($opt =~ /^Wait$/i) {
2129 $config->{'Busy_Wait'}=$bool;
2131 elsif ($opt =~ /^ModuleSynchronous$/i) {
2132 $config->{'Busy_Module'}=$bool;
2136 elsif ($line =~ /^ColorLimit\s+(\d+)/) {
2137 $config->{'ColorLimit'} = $1
2139 elsif ($line =~ /^ModuleTimeout\s+(\d+)/) {
2140 $config->{'ModuleTimeout'} = $1
2142 elsif ($line =~ /^EdgeScroll\s+(\d+)\s+(\d+)/) {
2143 $config->{'EdgeScroll_H'} = $1;
2144 $config->{'EdgeScroll_V'} = $2;
2146 elsif ($line =~ /^EdgeThickness\s+(\d)/) {
2147 $config->{'EdgeThickness'} = 2 if $1 == 2
2149 elsif ($line =~ /EdgeResistance\s+(\d+)\s+(\d+)/) {
2150 $config->{'EdgeResistance_delay'} = $1;
2151 $config->{'EdgeResistance_move'} = $2;
2153 elsif ($line =~ /^ClickTime\s+(\d*)\s*$/) {
2154 $config->{'ClickTime'} = $1;
2156 elsif ($line =~ /^MoveThreshold\s+(\d*)\s*$/) {
2157 $config->{'MoveThreshold'} = $1;
2159 elsif ($line =~ /^SetAnimation\s*(\d*)\s*(.*)/i) {
2160 $config->{'SetAnimatin_speed'} = $1 if defined $1;
2161 $config->{'SetAnimatin_frac'} = $2 if defined $2;
2163 elsif ($line =~ /^Style\s+["]*[*]["]*\s+(.+)$/i) {
2165 while($token ne "") {
2166 my $style = getNextStyle(\$token);
2167 if ($style =~ /^ClickToFocus$/i) {
2168 $config->{'focus'} = 1
2170 elsif ($style=~/^MouseFocus$/i || $style=~/^FocusFollowsMouse$/i) {
2171 $config->{'focus'} = 2
2173 elsif ($style =~ /^SloppyFocus$/i) {
2174 $config->{'focus'} = 3
2176 elsif ($style =~ /^ClickToFocusPassesClick$/i) {
2177 $config->{'ClickToFocusPassesClick'} = 1
2179 elsif ($style =~ /^ClickToFocusPassesClickOff$/i) {
2180 $config->{'ClickToFocusPassesClick'} = 0
2182 elsif ($style =~ /^ClickToFocusRaises$/i) {
2183 $config->{'ClickToFocusRaises'} = 1
2185 elsif ($style =~ /^ClickToFocusRaisesOff$/i) {
2186 $config->{'ClickToFocusRaises'} = 0
2188 elsif ($style =~ /^MouseFocusClickRaisesOff$/i) {
2189 $config->{'MouseFocusClickRaisesOff'} = 1
2191 elsif ($style =~ /^MouseFocusClickRaises$/i) {
2192 $config->{'MouseFocusClickRaisesOff'} = 0
2194 ### old placement style (style supported)
2195 elsif ($style =~ /^SmartPlacement$/i) {
2197 $config->{'SmartPlacement'} = 1
2199 elsif ($style =~ /^DumbPlacement$/i) {
2201 $config->{'SmartPlacement'} = 0
2203 elsif ($style =~ /^CleverPlacementOff$/i) {
2205 $config->{'CleverPlacementOff'} = 1
2207 elsif ($style =~ /^CleverPlacement$/i) {
2209 $config->{'CleverPlacementOff'} = 0
2211 elsif ($style =~ /^RandomPlacement$/i) {
2213 $config->{'RandomPlacement'} = 1
2215 elsif ($style =~ /^ActivePlacement$/i) {
2217 $config->{'RandomPlacement'} = 0
2219 ### new placement style
2220 elsif ($style =~ /^TileCascadePlacement$/i) {
2222 $config->{'placement'} = 1
2224 elsif ($style =~ /^TileManualPlacement$/i) {
2226 $config->{'placement'} = 2
2228 elsif ($style =~ /^MinOverlapPlacement$/i) {
2230 $config->{'placement'} = 3
2232 elsif ($style =~ /^MinOverlapPercentPlacement$/i) {
2233 $config->{'placement'} = 4
2235 elsif ($style =~ /^ManualPlacement$/i) {
2237 $config->{'placement'} = 5
2239 elsif ($style =~ /^CascadePlacement$/i) {
2241 $config->{'placement'} = 6
2243 # end of new placement style
2244 elsif ($style =~ /^GrabFocusOff$/i) {
2245 $config->{'GrabFocusOff'} = 0
2247 elsif ($style =~ /^GrabFocus$/i) {
2248 $config->{'GrabFocusOff'} = 1
2250 elsif ($style =~ /^NoPPosition$/i) {
2251 $config->{'NoPPosition'} = 0
2253 elsif ($style =~ /^UsePPosition$/i) {
2254 $config->{'NoPPosition'} = 1
2256 elsif ($style =~ /^ResizeOutLine$/i) {
2257 $config->{'ResizeOutLine'} = 1
2259 elsif ($style =~ /^ResizeOpaque$/i) {
2260 $config->{'ResizeOutLine'} = 0
2262 elsif ($style =~ /^SaveUnderOff$/i) {
2263 $config->{'SaveUnderOff'} = 0
2265 elsif ($style =~ /^SaveUnder$/i) {
2266 $config->{'SaveUnderOff'} = 1
2268 elsif ($style =~ /^BackingStoreOff$/i) {
2269 $config->{'BackinStoreOff'} = 0
2271 elsif ($style =~ /^BackingStore$/i) {
2272 $config->{'BackingStoreOff'} = 1
2274 elsif ($style =~ /^NakedTransient$/i) {
2275 $config->{'NakedTransient'} = 1
2277 elsif ($style =~ /^DecorateTransient$/i) {
2278 $config->{'NakedTransient'} = 0
2280 elsif ($style =~ /^DontRaiseTransient$/i) {
2281 $config->{'DontRaiseTransient'} = 0
2283 elsif ($style =~ /^RaiseTransient$/i) {
2284 $config->{'DontRaiseTransient'} = 1
2286 elsif ($style =~ /^DontLowerTransient$/i) {
2287 $config->{'DontLowerTransient'} = 0
2289 elsif ($style =~ /^LowerTransient$/i) {
2290 $config->{'DontLowerTransient'} = 1
2292 elsif ($style =~ /^DontStackTransientParent$/i) {
2293 $config->{'DontStackTransientParent'} = 0
2295 elsif ($style =~ /^StackTransientParent$/i) {
2296 $config->{'DontStackTransientParent'} = 1
2298 elsif ($style =~ /^GrabFocusTransientOff$/i) {
2299 $config->{'GrabFocusTransientOff'} = 0
2301 elsif ($style =~ /^GrabFocusTransient$/i) {
2302 $config->{'GrabFocusTransientOff'} = 1
2304 elsif ($style =~ /^WindowShadeSteps$/i) {
2305 if ($line = /\s*(\d+)/) {
2306 $config->{'WindowShadeSteps'} = $1;
2307 my $dummy = getNextToken(\$token);
2310 elsif ($style =~ /^WindowShadeScrolls$/i) {
2311 $config->{'WindowShadeScrolls'} = 1;
2313 elsif ($style =~ /^WindowShadeShrinks$/i) {
2314 $config->{'WindowShadeScrolls'} = 0;
2316 elsif ($style =~ /^NoDecorHint$/i) {
2317 $config->{'NoDecorHint'} = 0;
2319 elsif ($style =~ /^MwmDecor$/i) {
2320 $config->{'NoDecorHint'} = 1;
2322 elsif ($style =~ /^NoOLDecor$/i) {
2323 $config->{'NoOLDecor'} = 0;
2325 elsif ($style =~ /^OLDecor$/i) {
2326 $config->{'NoOLDecor'} = 1;
2328 elsif ($style =~ /^NoOverride$/i) {
2329 $config->{'NoOverride'} = 1;
2331 elsif ($style =~ /^HintOverride$/i) {
2332 $config->{'NoOverride'} = 0;
2334 elsif ($style =~ /^NoFuncHint$/i) {
2335 $config->{'NoFuncHint'} = 0;
2337 elsif ($style =~ /^MwmFunctions$/i) {
2338 $config->{'NoDecorHint'} = 1;
2340 elsif ($style =~ /^GNOMEUseHints$/i) {
2341 $config->{'GNOMEUseHints'} = 1;
2343 elsif ($style =~ /^GNOMEIgnoreHints$/i) {
2344 $config->{'GNOMEUseHints'} = 1;
2351 # compute clickraise
2352 if ($config->{'focus'} == 1) {
2353 $config->{'clickraise'} = $config->{'ClickToFocusRaises'}
2356 $config->{'clickraise'} = $config->{'MouseFocusClickRaisesOff'} ? 0:1
2359 if ($oldPlacement) {
2360 if ($config->{'SmartPlacement'}) {
2361 if (!$config->{'RandomPlacement'}) {
2362 $config->{'placement'} = 2
2364 elsif ($config->{'CleverPlacementOff'}) {
2365 $config->{'placement'} = 1
2368 $config->{'placement'} = 3
2371 elsif ($config->{'RandomPlacement'}) {
2372 $config->{'placement'} = 6
2375 $config->{'placement'} = 5
2378 # compute EdgeScroll
2379 my $scroll_h = int($config->{'EdgeScroll_H'}/1000);
2380 if ($scroll_h <= 0) { $config->{'circular_h'} = 0 }
2381 else { $config->{'EdgeScroll_H'} = $scroll_h; $config->{'circular_h'} = 1 }
2382 if ($config->{'EdgeScroll_H'} <= 0) { $config->{'edgescroll_h'} = 0 }
2383 elsif ($config->{'EdgeScroll_H'} <= 7) { $config->{'edgescroll_h'} = 9 }
2384 elsif ($config->{'EdgeScroll_H'} <= 17) { $config->{'edgescroll_h'} = 8 }
2385 elsif ($config->{'EdgeScroll_H'} <= 29) { $config->{'edgescroll_h'} = 7 }
2386 elsif ($config->{'EdgeScroll_H'} <= 41) { $config->{'edgescroll_h'} = 6 }
2387 elsif ($config->{'EdgeScroll_H'} <= 58) { $config->{'edgescroll_h'} = 5 }
2388 elsif ($config->{'EdgeScroll_H'} <= 70) { $config->{'edgescroll_h'} = 4 }
2389 elsif ($config->{'EdgeScroll_H'} <= 82) { $config->{'edgescroll_h'} = 3 }
2390 elsif ($config->{'EdgeScroll_H'} <= 95) { $config->{'edgescroll_h'} = 2 }
2391 else { $config->{'edgescroll_h'} = 1 }
2392 my $scroll_v = int($config->{'EdgeScroll_V'}/1000);
2393 if ($scroll_v <= 0) { $config->{'circular_v'} = 0 }
2394 else { $config->{'EdgeScroll_V'} = $scroll_v; $config->{'circular_v'} = 1 }
2395 if ($config->{'EdgeScroll_V'} <= 0) { $config->{'edgescroll_v'} = 0 }
2396 elsif ($config->{'EdgeScroll_V'} <= 7) { $config->{'edgescroll_v'} = 9 }
2397 elsif ($config->{'EdgeScroll_V'} <= 17) { $config->{'edgescroll_v'} = 8 }
2398 elsif ($config->{'EdgeScroll_V'} <= 29) { $config->{'edgescroll_v'} = 7 }
2399 elsif ($config->{'EdgeScroll_V'} <= 41) { $config->{'edgescroll_v'} = 6 }
2400 elsif ($config->{'EdgeScroll_V'} <= 58) { $config->{'edgescroll_v'} = 5 }
2401 elsif ($config->{'EdgeScroll_V'} <= 70) { $config->{'edgescroll_v'} = 4 }
2402 elsif ($config->{'EdgeScroll_V'} <= 82) { $config->{'edgescroll_v'} = 3 }
2403 elsif ($config->{'EdgeScroll_V'} <= 95) { $config->{'edgescroll_v'} = 2 }
2404 else { $config->{'edgescroll_v'} = 1 }
2405 # Compute Color Limit
2406 if ($config->{'ColorLimit'} < 0) { $config->{'color_limit'} = 1 }
2407 elsif ($config->{'ColorLimit'} == 0) { $config->{'color_limit'} = 9 }
2408 elsif ($config->{'ColorLimit'} <= 2) { $config->{'color_limit'} = 2 }
2409 elsif ($config->{'ColorLimit'} <= 14) { $config->{'color_limit'} = 3 }
2410 elsif ($config->{'ColorLimit'} <= 24) { $config->{'color_limit'} = 4 }
2411 elsif ($config->{'ColorLimit'} <= 34) { $config->{'color_limit'} = 5 }
2412 elsif ($config->{'ColorLimit'} <= 44) { $config->{'color_limit'} = 6 }
2413 elsif ($config->{'ColorLimit'} <= 54) { $config->{'color_limit'} = 7 }
2414 else { $config->{'color_limit'} = 8 }
2415 # Compute module timeout
2416 if ($config->{'ModuleTimeout'} <= 0) { $config->{'module_timeout'} = 6 }
2417 elsif ($config->{'ModuleTimeout'} <= 3) { $config->{'module_timeout'} = 1 }
2418 elsif ($config->{'ModuleTimeout'} <= 6) { $config->{'module_timeout'} = 2 }
2419 elsif ($config->{'ModuleTimeout'} <= 8) { $config->{'module_timeout'} = 3 }
2420 elsif ($config->{'ModuleTimeout'} <= 12) { $config->{'module_timeout'} = 4 }
2421 elsif ($config->{'ModuleTimeout'} <= 20) { $config->{'module_timeout'} = 5 }
2422 elsif ($config->{'ModuleTimeout'} <= 38) { $config->{'module_timeout'} = 6 }
2423 elsif ($config->{'ModuleTimeout'} <= 53) { $config->{'module_timeout'} = 7 }
2424 elsif ($config->{'ModuleTimeout'} <= 90) { $config->{'module_timeout'} = 8 }
2425 else { $config->{'module_timeout'} = 9 }
2427 $configForScript->{'Focus'} = $config->{'focus'} .
2428 $config->{'ClickToFocusPassesClick'} . $config->{'clickraise'} .
2429 $config->{'colormapmouse'} . $config->{'placement'} .
2430 $config->{'GrabFocusOff'} . $config->{'NoPPosition'};
2432 $configForScript->{'Move'} = $config->{'ResizeOutLine'} .
2433 $config->{'OpaqueMoveSize'} . "!" . $config->{'emulate'} .
2434 $config->{'hideresize'} . $config->{'hidemove'} .
2435 $config->{'FlickeringMoveWorkaround'} .
2436 $config->{'snapdistance'} . "!" . $config->{'snapbehavior'} .
2437 $config->{'snap_X'} . "!" . $config->{'snap_Y'} . "!" .
2438 $config->{'xor'} . $config->{'xor_value'} . "!" .
2439 $config->{'xor_pixmap'} . "!";
2441 $configForScript->{'Paging'} = $config->{'edgescroll_h'} .
2442 $config->{'circular_h'} . $config->{'edgescroll_v'} .
2443 $config->{'circular_v'} . $config->{'EdgeResistance_delay'} ."!".
2444 $config->{'EdgeResistance_move'}."!". $config->{'EdgeThickness'} .
2445 $config->{'ClickTime'} ."!". $config->{'MoveThreshold'}."!";
2447 $configForScript->{'Transient'} = $config->{'NakedTransient'} .
2448 $config->{'DontRaiseTransient'} . $config->{'DontLowerTransient'} .
2449 $config->{'DontStackTransientParent'} .
2450 $config->{'GrabFocusTransientOff'} .
2451 $config->{'WindowShadeSteps'}. "!" . $config->{'WindowShadeScrolls'} .
2452 $config->{'SetAnimatin_speed'}. "!". $config->{'SetAnimatin_frac'}."!";
2454 $configForScript->{'Hints'} = $config->{'NoDecorHint'} .
2455 $config->{'NoOLDecor'} . $config->{'NoOverride'} .
2456 $config->{'NoFuncHint'} . $config->{'GNOMEUseHints'} .
2457 $config->{'ModalityIsEvil'} .
2458 $config->{'Busy_Read'} . $config->{'Busy_Recapture'} .
2459 $config->{'Busy_Wait'} . $config->{'Busy_Module'} .
2460 $config->{'color_limit'} . $config->{'MixedVisualWorkaround'} .
2461 $config->{'RaiseOverNativeWindow'} . $config->{'SaveUnderOff'} .
2462 $config->{'BackingStoreOff'} . $config->{'module_timeout'};
2466 # ---------------------------------------------------------------------------
2467 # "default" config (but in theory the theme/default/* is loaded
2469 sub default_globalfeel_Config {
2472 $config->{'ClickToFocusPassesClick'} = 0;
2473 $config->{'ClickToFocusRaises'} = 1;
2474 $config->{'MouseFocusClickRaisesOff'} = 1;
2475 $config->{'focus'} = 0;
2476 $config->{'colormapmouse'} = 0;
2477 $config->{'SmartPlacement'} = 1;
2478 $config->{'RandomPlacement'} = 1;
2479 $config->{'CleverPlacementOff'} = 1;
2480 $config->{'placement'} = 0;
2481 $config->{'GrabFocusOff'} = 0;
2482 $config->{'NoPPosition'} = 0;
2483 $config->{'ResizeOutLine'} = 1;
2484 $config->{'OpaqueMoveSize'} = 5;
2485 $config->{'emulate'} = 1;
2486 $config->{'hideresize'} = 0;
2487 $config->{'hidemove'} = 0;
2488 $config->{'FlickeringMoveWorkaround'} = 0;
2489 $config->{'snapdistance'} = 0;
2490 $config->{'snapbehavior'} = 1;
2491 $config->{'snap_X'} = 1;
2492 $config->{'snap_Y'} = 1;
2493 $config->{'xor'} = 0; # 0 Value, 1 Pixmap
2494 $config->{'xor_value'} = 0; # fvwm default
2495 $config->{'xor_pixmap'} = "";
2496 $config->{'BackingStoreOff'} = 0;
2497 $config->{'EdgeScroll_H'} = 0;
2498 $config->{'EdgeScroll_V'} = 0;
2499 $config->{'edgescroll_h'} = 1;
2500 $config->{'edgescroll_v'} = 1;
2501 $config->{'circular_h'} = 0;
2502 $config->{'circilar_v'} = 0;
2503 $config->{'EdgeResistance_delay'} = 0;
2504 $config->{'EdgeResistance_move'} = 0;
2505 $config->{'EdgeThickness'} = 1;
2506 $config->{'ClickTime'} = 150;
2507 $config->{'MoveThreshold'} = 3;
2508 $config->{'NakedTransient'} = 1;
2509 $config->{'DontRaiseTransient'} = 0;
2510 $config->{'DontLowerTransient'} = 0;
2511 $config->{'DontStackTransientParent'} = 0;
2512 $config->{'GrabFocusTransientOff'} = 0;
2513 $config->{'WindowShadeSteps'} = 20;
2514 $config->{'WindowShadeScrolls'} = 1;
2515 $config->{'EdgeResistance_delay'} = 0;
2516 $config->{'EdgeResistance_move'} = 0;
2517 $config->{'SetAnimatin_speed'} = 10;
2518 $config->{'SetAnimatin_frac'} = "1 0 .01 .03 .08 .18 .3 .45 .6 .75 " .
2519 ".85 .90 .94 .97 .99 1.0";
2520 $config->{'NoDecorHint'} = 1;
2521 $config->{'NoOLDecor'} = 1;
2522 $config->{'NoOverride'} = 0;
2523 $config->{'NoFuncHint'} = 1;
2524 $config->{'GNOMEUseHints'} = 1;
2525 $config->{'ModalityIsEvil'} = 1;
2526 $config->{'Busy_Read'} = 0;
2527 $config->{'Busy_Recapture'} = 1;
2528 $config->{'Busy_Wait'} = 0;
2529 $config->{'Busy_Module'} = 0;
2530 $config->{'ColorLimit'} = -1; # No color limit config command!
2531 $config->{'color_limit'} = 1;
2532 $config->{'MixedVisualWorkaround'} = 0;
2533 $config->{'RaiseOverNativeWindow'} = 0;
2534 $config->{'SaveUnderOff'} = 0;
2535 $config->{'BackingStoreOff'} = 0;
2536 $config->{'ModuleTimeout'} = 30;
2537 $config->{'module_timeout'} = 6;
2541 # -----------------------------------------------------------------------------
2548 $$line =~ s/^\s*,\s*//;
2550 $quote = "\"" if ($$line =~ /^\"/);
2551 $quote = "\'" if ($$line =~ /^\'/);
2552 $quote = "\`" if ($$line =~ /^\`/);
2553 $$line =~ s/^$quote//;
2555 if ($$line =~ /$quote/) {
2556 $token = substr($$line,0,index($$line,$quote));
2560 $$line = substr($$line,length($token));
2561 $token =~ s/$quote$//;
2570 $$line =~ s/^\s*,\s*//;
2572 if ($$line =~ /,/) {
2573 $token = substr($$line,0,index($$line,","));
2577 $$line = substr($$line,length($token));
2587 if ($$line =~ /^(on\s*,*\s*)/i) {
2591 elsif ($$line =~ /^(off\s*,*\s*)/i) {
2595 elsif ($$line =~ /^(yes\s*,*\s*)/i) {
2599 elsif ($$line =~ /^(y\s*,*\s*)/i) {
2603 elsif ($$line =~ /^(no\s*,*\s*)/i) {
2607 elsif ($$line =~ /^(n\s*,*\s*)/i) {
2611 elsif ($$line =~ /^(True\s*,*\s*)/i) {
2615 elsif ($$line =~ /^(T\s*,*\s*)/i) {
2619 elsif ($$line =~ /^(False\s*,*\s*)/i) {
2623 elsif ($$line =~ /^(False\s*,*\s*)/i) {
2628 elsif ($$line =~ /^(toggle[,]\s*)/i) {
2632 $$line = substr($$line,$l);
2636 #----------------------------------------------------------------------------
2643 my $dir = substr($file,0,rindex($file,"/"));
2644 # using decimal (not octal) 755 is incorrect; also I have umask 02, not 022
2645 mkdir($dir, 0777 - umask()) if (! -d $dir);
2647 my $date = `date +'%d-%b-%Y %T'`;
2649 my $user = $ENV{'USER'} || "unknown";
2650 my $host = $ENV{'HOSTNAME'} || "unknown";
2651 my $save = "# Automatically generated by FVWM-Themes $version on $date\n" .
2652 "# for $user\@$host\n";
2653 $out = $save . $out;
2655 open(OUT, ">$file");
2660 #----------------------------------------------------------------------------
2664 my @Hex=(0 .. 9, "a" .. "f");
2666 # modified for speed (olicha)
2667 my $h = $Hex[$i/16] . $Hex[$i%16];
2672 #----------------------------------------------------------------------------
2679 my $defaultVisual = "";
2682 open(XDPY,"xdpyinfo |");
2684 if (/default visual id:\s+(.*)$/) {
2685 $defaultVisual = $1;
2687 if (/visual id:\s+$defaultVisual$/) {
2690 if ($ok && /red, green, blue masks:\s+([0-9a-fA-Fx]+),\s+([0-9a-fA-Fx]+),\s+([0-9a-fA-Fx]+)$/) {
2692 $greenMask = hex($2);
2693 $blueMask = hex($3);
2699 return ($redMask,$greenMask,$blueMask)