1 WindowTitle {Color Selector}
3 Font -adobe-helvetica-bold-r-*-*-12-*
13 Set $arg = (GetScriptArgument $i)
17 If $arg == {--viewer-colorset} Then
18 Set $ViewerColorset = (GetScriptArgument $j)
19 If $arg == {--launched} Then
20 Set $Launched = (GetScriptArgument $j)
21 If $arg == {--lang} Then
22 Set $Lang = (GetScriptArgument $j)
23 If $arg == {--color} Then
24 Set $Color = (GetScriptArgument $j)
26 Set $arg = (GetScriptArgument $i)
29 Set $SelFont = {-adobe-helvetica-bold-r-*-*-12-*}
30 Set $ShadeFont = {-adobe-helvetica-medium-r-*-*-12-*}
32 Set $nonDefaultFont = 0
36 # ------------------------------------- Internationalization.
38 Set $nonDefaultFont = 0
42 Set $cmd = {echo "$LANG" | cut -c1-2}
43 Set $Lang = (GetOutput $cmd 1 -1)
51 Set $cmd = {fvwm-themes-script --get-msg }FvwmScript-ColorSelector{ --lang }$Lang
52 Set $MSG = (GetOutput $cmd 1 -1)
55 While $notdone == 1 Do
57 Set $index = (Add $index 1)
58 Set $id = (StrCopy $MSG $index (Add $index 11))
59 Set $index = (Add $index 12)
60 Set $tmp = (StrCopy $MSG $index (Add $index 3))
61 Set $index = (Add $index 4)
62 Set $pos = (Add $index $tmp)
63 Set $msg = (StrCopy $MSG $index $pos)
64 Set $index = (Add $index $tmp)
65 #Do {Echo id:}$id{:msg:}$msg{:}
74 If $id == {Title } Then
76 If $id == {SelColor } Then
78 If $id == {Help } Then
84 If $id == {Cancel } Then
86 If $id == {ChangeFont } Then
87 Set $nonDefaultFont = $msg
88 If $id == {SelFont } Then
90 If $id == {ShadeFont } Then
92 If $id == {FixedFont } Then
96 If $nonDefaultFont == 1 Then
99 ChangeFont 14 $SelFont
100 # these 4 one display number
101 ChangeFont 17 $FixedFont
102 ChangeFont 30 $FixedFont
103 ChangeFont 32 $FixedFont
104 ChangeFont 34 $FixedFont
105 ChangeFont 992 $SelFont
106 ChangeFont 993 $SelFont
107 ChangeFont 994 $SelFont
108 # when the doc will be written
109 #ChangeFont 994 $FixedFont
112 # ---------------------- Color init
114 Set $cmd = {echo "$FT_DATADIR"}
115 Set $FtDataDir = (GetOutput $cmd 1 -1)
116 Set $RainbowFile = $FtDataDir{/images/fvwmscript/palette-rainbow.xpm}
117 Set $GreyFile = $FtDataDir{/images/fvwmscript/palette-gray.xpm}
119 # get the rainbow color line
120 Set $cmd = {if [ -f }$RainbowFile{ ]; then echo 1; else echo "0"; fi}
121 Set $test = (GetOutput $cmd 1 -1)
124 Do {Echo [FvwmScript-ColorSelector] Unable to find }$RainbowFile
125 Do {Echo [FvwmScript-ColorSelector] exiting!}
130 Set $cmd = {cat }$RainbowFile
131 Set $ColorLine = (GetOutput $cmd 282 -1)
134 # get the grey color line
135 Set $cmd = {if [ -f }$GreyFile{ ]; then echo "1"; else echo "0"; fi}
136 Set $test = (GetOutput $cmd 1 -1)
139 Do {Echo [FvwmScript-ColorSelector] Unable to find }$GreyFile
140 Do {Echo [FvwmScript-ColorSelector] exiting!}
145 Set $cmd = {cat }$GreyFile
146 Set $GreyColorLine = (GetOutput $cmd 282 -1)
150 Set $CurrentColor = $Color
152 Set $CurrentColor = {#02EEFF}
154 Set $UpdateColors = 1
156 Do {Colorset 29 fg black, bg #908090, HGradient 190 2 #000000 50 }$CurrentColor{ 50 #ffffff, NoShape}
157 Set $LightColor = $CurrentColor
158 Set $LightNumRed = (HexToNum (StrCopy $LightColor 2 3))
159 Set $LightNumGreen = (HexToNum (StrCopy $LightColor 4 5))
160 Set $LightNumBlue = (HexToNum (StrCopy $LightColor 6 7))
163 #----------------------------------------------------------------------------
168 If $UpdateColors == 1 Then
170 Set $UpdateColors = 0
171 ChangeBackColor 15 $CurrentColor
172 ChangeTitle 17 $CurrentColor
173 Set $Red = (StrCopy $CurrentColor 2 3)
174 Set $Green = (StrCopy $CurrentColor 4 5)
175 Set $Blue = (StrCopy $CurrentColor 6 7)
176 Set $NumRed = (HexToNum $Red)
177 Set $NumGreen = (HexToNum $Green)
178 Set $NumBlue = (HexToNum $Blue)
180 Set $NumG = $NumGreen
184 ChangeValue 31 $NumRed
187 ChangeValue 33 $NumGreen
190 ChangeValue 35 $NumBlue
195 # ----------------------------------------------------------------------------
235 Icon fvwmscript/palette-rainbow.xpm
240 Set $X = (GetMinValue 10)
241 Set $index = (Mult $X 2)
242 Set $index = (Add $index 2)
243 Set $end = (Add $index 1)
244 Set $name = (StrCopy $ColorLine $index $end)
245 Set $a = (StrCopy $name 1 1)
246 Set $b = (StrCopy $name 2 2)
255 # do we have to protec other characters?
256 Set $cmd = {grep "[}$a{][}$b{] c #" }$RainbowFile
257 Set $tmp = (GetOutput $cmd 1 -1)
258 Set $LightColor = (StrCopy $tmp 7 19)
259 Set $LightRed = (StrCopy $LightColor 2 3)
260 Set $LightGreen = (StrCopy $LightColor 6 7)
261 Set $LightBlue = (StrCopy $LightColor 10 11)
262 Set $LightColor = {#} $LightRed $LightGreen $LightBlue
263 Do {Colorset 29 fg black, bg #908090, HGradient 256 2 #000000 50 }$LightColor{ 50 #ffffff, NoShape}
264 Set $LightNumRed = (HexToNum $LightRed)
265 Set $LightNumGreen = (HexToNum $LightGreen)
266 Set $LightNumBlue = (HexToNum $LightBlue)
279 Icon fvwmscript/palette-rainbow.xpm
284 Set $X = (GetMinValue 13)
285 Set $index = (Mult $X 2)
286 Set $index = (Add $index 2)
287 Set $end = (Add $index 1)
288 Set $name = (StrCopy $ColorLine $index $end)
289 Set $a = (StrCopy $name 1 1)
290 Set $b = (StrCopy $name 2 2)
299 # do we have to protec other characters?
300 Set $cmd = {grep "[}$a{][}$b{] c #" }$RainbowFile
301 Set $tmp = (GetOutput $cmd 1 -1)
302 Set $SecondColor = (StrCopy $tmp 7 19)
303 Set $SecondRed = (StrCopy $SecondColor 2 3)
304 Set $SecondGreen = (StrCopy $SecondColor 6 7)
305 Set $SecondBlue = (StrCopy $SecondColor 10 11)
306 Set $SecondColor = {#} $SecondRed $SecondGreen $SecondBlue
307 Do {Colorset 29 fg black, bg #908090, HGradient 256 }$SecondColor{ }$CurrentColor{, NoShape}
308 Set $SecondNumRed = (HexToNum $SecondRed)
309 Set $SecondNumGreen = (HexToNum $SecondGreen)
310 Set $SecondNumBlue = (HexToNum $SecondBlue)
311 Set $OrigNumRed = $NumRed
312 Set $OrigNumGreen = $NumGreen
313 Set $OrigNumBlue = $NumBlue
326 Icon fvwmscript/palette-gray.xpm
331 Set $X = (GetMinValue 11)
332 Set $index = (Mult $X 2)
333 Set $index = (Add $index 2)
334 Set $end = (Add $index 1)
335 Set $name = (StrCopy $GreyColorLine $index $end)
336 Set $a = (StrCopy $name 1 1)
337 Set $b = (StrCopy $name 2 2)
346 # do we have to protec other characters?
347 Set $cmd = {grep "[}$a{][}$b{] c #" }$GreyFile
348 Set $tmp = (GetOutput $cmd 1 -1)
349 Set $SecondColor = (StrCopy $tmp 7 19)
350 Set $SecondRed = (StrCopy $SecondColor 2 3)
351 Set $SecondGreen = (StrCopy $SecondColor 6 7)
352 Set $SecondBlue = (StrCopy $SecondColor 10 11)
353 Set $SecondColor = {#} $SecondRed $SecondGreen $SecondBlue
354 Do {Colorset 29 fg black, bg #908090, HGradient 256 }$SecondColor{ }$CurrentColor{, NoShape}
356 Set $SecondNumRed = (HexToNum $SecondRed)
357 Set $SecondNumGreen = (HexToNum $SecondGreen)
358 Set $SecondNumBlue = (HexToNum $SecondBlue)
359 Set $OrigNumRed = $NumRed
360 Set $OrigNumGreen = $NumGreen
361 Set $OrigNumBlue = $NumBlue
377 Set $X = (GetMinValue 12)
378 If $IsSecond == 0 Then
382 Set $X = (Add $X -128)
383 Set $cmd = {perl -e '$ln = }$LightNumRed{; $x = }$X{; $r = $ln + ($x/128)*(256-$ln); $r = int($r); $r = 255 if $r > 255; print "$r\n"'}
384 Set $NumRed = (GetOutput $cmd 1 -1)
385 Set $cmd = {perl -e '$ln = }$LightNumGreen{; $x = }$X{; $r = $ln + ($x/128)*(256-$ln); $r = int($r); $r = 255 if $r > 255; print "$r\n"'}
386 Set $NumGreen = (GetOutput $cmd 1 -1)
387 Set $cmd = {perl -e '$ln = }$LightNumBlue{; $x = }$X{; $r = $ln + ($x/128)*(256-$ln); $r = int($r); $r = 255 if $r > 255; print "$r\n"'}
388 Set $NumBlue = (GetOutput $cmd 1 -1)
392 Set $cmd = {perl -e '$ln = }$LightNumRed{; $x = }$X{; $r = ($x/128)*($ln); $r = int($r); print "$r\n"'}
393 Set $NumRed = (GetOutput $cmd 1 -1)
394 Set $cmd = {perl -e '$ln = }$LightNumGreen{; $x = }$X{; $r = ($x/128)*($ln); $r = int($r);print "$r\n"'}
395 Set $NumGreen = (GetOutput $cmd 1 -1)
396 Set $cmd = {perl -e '$ln = }$LightNumBlue{; $x = }$X{; $r = ($x/128)*($ln); $r = int($r);print "$r\n"'}
397 Set $NumBlue = (GetOutput $cmd 1 -1)
402 Set $cmd = {perl -e '$ln = }$OrigNumRed{; $g = }$SecondNumRed{; $x = }$X{; $r = (($ln - $g)*$x)/256 + $g; $r = int($r); print "$r\n"'}
403 Set $NumRed = (GetOutput $cmd 1 -1)
404 Set $cmd = {perl -e '$ln = }$OrigNumGreen{; $g = }$SecondNumGreen{; $x = }$X{; $r = (($ln - $g)*$x)/256 + $g; $r = int($r); print "$r\n"'}
405 Set $NumGreen = (GetOutput $cmd 1 -1)
406 Set $cmd ={perl -e '$ln = }$OrigNumBlue{; $g = }$SecondNumBlue{; $x = }$X{; $r = (($ln - $g)*$x)/256 + $g; $r = int($r); print "$r\n"'}
407 Set $NumBlue = (GetOutput $cmd 1 -1)
409 Set $Red = (NumToHex $NumRed 2)
410 Set $Green = (NumToHex $NumGreen 2)
411 Set $Blue = (NumToHex $NumBlue 2)
412 Set $CurrentColor = {#} $Red $Green $Blue
413 Set $UpdateColors = 1
417 # Selected Color (title):
445 Set $LightGreen = $Green
446 Set $LightBlue = $Blue
447 Set $LightColor = {#} $LightRed $LightGreen $LightBlue
448 Do {Colorset 29 fg black, bg #908090, HGradient 256 2 #000000 50 }$LightColor{ 50 #ffffff, NoShape}
449 Set $LightNumRed = $NumRed
450 Set $LightNumGreen = $NumGreen
451 Set $LightNumBlue = $NumBlue
506 Font -*-fixed-medium-r-semicondensed-*-13-*
513 Set $NumR = (GetValue 31)
514 Set $NumG = (GetValue 33)
515 Set $NumB = (GetValue 35)
516 Set $test = (Mult $NumR -1)
517 Set $test = (Add $test $NumRed)
520 Set $test = (Mult $NumRed -1)
521 Set $test = (Add $test $NumR)
524 Set $NumRed = (GetValue 31)
525 Set $NumGreen = (GetValue 33)
526 Set $NumBlue = (GetValue 35)
527 Set $Red = (NumToHex $NumRed 2)
528 Set $Green = (NumToHex $NumGreen 2)
529 Set $Blue = (NumToHex $NumBlue 2)
530 Set $CurrentColor = {#} $Red $Green $Blue
531 ChangeBackColor 15 $CurrentColor
532 ChangeTitle 17 $CurrentColor
559 Font -*-fixed-medium-r-semicondensed-*-13-*
571 Set $NumR = (GetValue 31)
572 Set $NumG = (GetValue 33)
573 Set $NumB = (GetValue 35)
574 Set $test = (Mult $NumG -1)
575 Set $test = (Add $test $NumGreen)
578 Set $test = (Mult $NumGreen -1)
579 Set $test = (Add $test $NumG)
582 Set $NumRed = (GetValue 31)
583 Set $NumGreen = (GetValue 33)
584 Set $NumBlue = (GetValue 35)
585 Set $Red = (NumToHex $NumRed 2)
586 Set $Green = (NumToHex $NumGreen 2)
587 Set $Blue = (NumToHex $NumBlue 2)
588 Set $CurrentColor = {#} $Red $Green $Blue
589 ChangeBackColor 15 $CurrentColor
590 ChangeTitle 17 $CurrentColor
593 ChangeValue 31 $NumRed
596 ChangeValue 33 $NumGreen
599 ChangeValue 35 $NumBlue
624 Font -*-fixed-medium-r-semicondensed-*-13-*
632 Set $NumR = (GetValue 31)
633 Set $NumG = (GetValue 33)
634 Set $NumB = (GetValue 35)
635 Set $test = (Mult $NumB -1)
636 Set $test = (Add $test $NumBlue)
639 Set $test = (Mult $NumBlue -1)
640 Set $test = (Add $test $NumB)
643 Set $NumRed = (GetValue 31)
644 Set $NumGreen = (GetValue 33)
645 Set $NumBlue = (GetValue 35)
646 Set $Red = (NumToHex $NumRed 2)
647 Set $Green = (NumToHex $NumGreen 2)
648 Set $Blue = (NumToHex $NumBlue 2)
649 Set $CurrentColor = {#} $Red $Green $Blue
650 ChangeBackColor 15 $CurrentColor
651 ChangeTitle 17 $CurrentColor
654 ChangeValue 31 $NumRed
657 ChangeValue 33 $NumGreen
660 ChangeValue 35 $NumBlue
664 #----------------------------------------------------------------------------
678 If $Launched == {yes} Then
680 Set $ret = $CurrentColor
681 SendToScript (GetScriptFather) $ret
699 Set $arg={FvwmScript-Help --in-line-doc FvwmScript-ColorSelector --title "Color Selector"}
700 If $ViewerColorset <> {} Then
701 Set $arg=$arg{ --text-colorset }$ViewerColorset
703 Set $arg=$arg{ --lang }$Lang
704 Set $dummy = (LaunchScript $arg)
720 If $Launched == {yes} Then
721 SendToScript (GetScriptFather) {Cancel}