#!/usr/bin/perl -w # # xcolors: Find the X11 rgb.txt file. # # ???: Written by Steven J. DeRose, sderose@acm.org. # 2010-09-23 sjd: Clean up, Getopt, etc. # # To do: # use strict; use Getopt::Long; my $version = "2010-09-23"; my $quiet = 0; my $verbose = 0; ############################################################################### # Getopt::Long::Configure ("ignore_case"); my $result = GetOptions( "h|help" => sub { system "perldoc xcolors"; exit; }, "q!" => \$quiet, "v+" => \$verbose, "version" => sub { die "Version of $version, by Steven J. DeRose.\n"; } ); ($result) || die "Bad options.\n"; ############################################################################### # my @paths = ( "/usr/share/X11/rgb.txt", "/usr/X11R6/lib/X11/rgb.txt", "/usr/X11R6/share/X11/rgb.txt". "/usr/share/emacs/22.2/etc/rgb.txt", "/etc/X11/rgb.txt", "/host/Python25/Tools/pynche/X/rgb.txt", "/host/cygwin/usr/share/emacs/23.0.92/etc/rgb.txt", ); if ($verbose) { print "xcolors: Finds and displays the X Windows rgb.txt file, from:\n"; print " " . join("\n ",@paths) . "\n"; exit; } my $nFound = 0; for my $path (@paths) { if (-f $path) { warn "File found: $path\n"; ($quiet) || system "more $path"; $nFound++; } } ($nFound) || die "Can't find X11 'rgc.txt' color file (use -v to see path checked).\n"; ############################################################################### # sub showUsage { warn " =head1 Usage xcolors [options] file =head1 Options (prefix 'no' to negate where applicable) =over =item * B<-q> Suppress most messages, and avoid printing the content of the rgb.txt file itself (just show the path). =item * B<-v> Add more messages, including the entire list of directories where the script tries to find rgc.txt. =item * B<-version> Show version info and exit. =back =head1 Related commands. Pretty much the same as 'showrgb'. =head1 Ownership This work by Steven J. DeRose is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License. For further information on this license, see http://creativecommons.org/licenses/by-sa/3.0/. The author's present email is sderose at acm.org. For the most recent version, see http://www.derose.net/steve/utilities/. =cut "; }