Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
#!/usr/bin/perl use Getopt::Long; use strict; use warnings; my $foreground = 0; my $transparency = 1; my $alpha = 80; my $help = 0; my $result = Getopt::Long::GetOptions( 'fg|foreground' => \$foreground, 'transparency!' => \$transparency, 'alpha:i' => \$alpha, 'help|?' => \$help, ); die "Usage: $0 [--alpha <number>] [--foreground] [--[no]transparency] +[--[no]dark]\n" if @ARGV or not $result or $help; die "Option 'alpha' must be between 0 (transparent) and 100 (opaque)\n +" if $alpha < 0 or $alpha > 100; $alpha = 100 unless $transparency; $alpha = ( $alpha * 65535 ) / 100; my ($bg, $bg1, $fg) = random_colors( ); ($fg, $bg) = ($bg, $fg) if $foreground; $" = ", "; open(OSA,"|-", "osascript"); print OSA <<SCRIPT; tell front window of app "Terminal" set background color to {@$bg, $alpha} set normal text color to {@$fg} set bold text color to {@$bg1} set cursor color to {@$bg1} end tell SCRIPT close(OSA); exit 0; sub random_colors { my @rgb = map { int rand 256 } 1 .. 3; my $lum = ($rgb[0] * 0.3) + ($rgb[1] * 0.59) + ($rgb[2] * 0.11); my @rgb_bold = map { ( ( $_ + 128 ) % 256 ) * 257 } @rgb; @rgb = map { $_ * 257 } @rgb; my @rgb_fg = $lum < 128 ? (65535, 65535, 65535) : (0, 0, 0); return (\@rgb, \@rgb_bold, \@rgb_fg); }

In reply to Dynamically Generating Mac OSX Terminal.app Colors by techy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-04-19 02:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found