Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Random xterms in OpenWindows

by insensate (Hermit)
on Aug 13, 2004 at 15:38 UTC ( [id://382723]=CUFP: print w/replies, xml ) Need Help??

This relies on the /usr/openwin/bin/showrgbcommand (I'm a Solaris user... I'm sure there are equivs in other flavors/desktop mgrs) and obviously the xterm command. Read your xterm man pages for other options that can be passed as well.
#!/usr/bin/perl use strict; my @c=grep{s/\s//g;s/\d//g}`/usr/openwin/bin/showrgb`; my $i=rand@c; my $color=$c[$i]; exec("xterm -fg black -bg $color -font 6x13 -ls -sb -sl 1000 &");

Replies are listed 'Best First'.
Re: Random xterms in OpenWindows
by hawtin (Prior) on Aug 13, 2004 at 16:30 UTC

    There are some varients I put in my version, for a start I add "-e tcsh" because that's the shell I like. The next thing is to have a fixed set of fg/bg pairs (for example black/white, white/black, green/yellow, yellow/green) to give me context ("That was in the horrible pink xterm wasn't it"). Finally I fire off a set of xterms with a 1 second delay to let me select different CDE screens and make sure every CDE screen has an xterm on it.

    Maybe some of this will be of use

Re: Random xterms in OpenWindows
by jcc (Sexton) on Feb 16, 2006 at 20:22 UTC
    Since showrgb also prints out the rgb values you can use the brightness equation to determine foreground font (white or black)... something like:
    #!/usr/bin/perl use strict; my @colorinfo=<DATA>; my $i = rand @colorinfo; my $line=$colorinfo[$i]; $line=~/(\d+)\s+(\d+)\s+(\d+)\s+(.*)$/; my $brightness=($1*299+$2*587+$3*114)/1000; my $fg=$brightness>135?"black":"white"; exec("xterm -fg $fg -bg \'$4\' -font 6x13 -ls -sb -sl 1000 &"); __DATA__ 199 21 133 medium violet red 176 196 222 light steel blue 102 139 139 paleturquoise4 159 121 238 mediumpurple2 141 182 205 lightskyblue3 0 238 118 springgreen2 255 160 122 light salmon 154 205 50 yellowgreen 178 58 238 darkorchid2 69 139 116 aquamarine4 71 60 139 slateblue4 131 111 255 slateblue1 192 255 62 olivedrab1 139 105 20 goldenrod4 205 155 29 goldenrod3 142 229 238 cadetblue2
    ... and so forth. (I just concatenated showrgb to the bottom of my script.) 135 was about the value that worked best for my eyes in terms of a cut off between brightness warranting a black foreground color or a white.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: CUFP [id://382723]
Approved by hawtin
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2024-03-28 14:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found