pax_global_header00006660000000000000000000000064132063414660014517gustar00rootroot0000000000000052 comment=f77b234b015c6fe022f9426d6acfe9c8c3c2cfd5 vtgamma-0.4/000077500000000000000000000000001320634146600130165ustar00rootroot00000000000000vtgamma-0.4/.gitignore000066400000000000000000000000031320634146600147770ustar00rootroot00000000000000*~ vtgamma-0.4/LICENSE000066400000000000000000000002731320634146600140250ustar00rootroot00000000000000I hereby disclaim all copyright on this software and the packaging, and put it in the Public Domain. If this is impossible in a given jurisdiction, an all-permissive license is granted. vtgamma-0.4/README000066400000000000000000000010601320634146600136730ustar00rootroot00000000000000If the text on your terminal is too dark -- or if one of RGB components, usually blue, is too dark -- vtgamma allows you to apply a correction. This is usually useful on Linux console, as most graphical terminals supply more persistent means of adjusting colors; vtgamma is still helpful on those which don't, or if you can't cope with unfriendly settings such as xterm's. Not all terminals allow palette control (so vtgamma might not work for you), the palette might be lost when a program resets the terminal (so you may want to use PROMPT_COMMAND or PS1). vtgamma-0.4/vtgamma000077500000000000000000000062011320634146600143770ustar00rootroot00000000000000#!/usr/bin/perl -w use strict; my $esc="\e"; my $lab=0; my @args=[]; my $rv=0; my $perm=0; my $USAGE=<\e[0m vtgamma \e[30;1m[-e] [-r]\e[0m \e[31;1m<\e[0;31mred gamma\e[1m>\e[0m \e[32;1m<\e[0;32mgreen gamma\e[1m>\e[0m \e[1;34m<\e[0;34mblue gamma\e[1m>\e[0m END $USAGE=~s/\e\[[0-9;]*m//g unless -t STDERR; my $PIO_CMAP=0x4B71; # Linux while(@ARGV) { $_=shift; if (/^-e|--escape$/) { $esc='\e'; } elsif (/^-l|--lab|--Lab|--lchab|--LCHab$/) { $lab=1; require Graphics::ColorObject; } elsif (/^-r|--reverse$/) { $rv=1; } elsif (/^(\d*\.?\d+)$/) { push @args, $1; } elsif (/^-p|--permanent$/) { $^O eq "linux" or die "PIO_CMAP supported only on Linux.\n"; $perm=1; } else { die "Invalid argument: \"$_\"\n$USAGE"; } } my ($r,$g,$b)= ($#args==0)? die "$USAGE": ($#args==1)? ($args[1],$args[1],$args[1]): ($#args==2)? die "Only 2 gammas given, 1 or 3 required.\n": ($#args==3)? $lab ? die "Can't give RGB gamma in LCHab mode.\n": ($args[1],$args[2],$args[3]): die "Too many gammas given.\n$USAGE"; sub gamma($$) { my ($x,$k)=@_; return 0 if $x<=0; return ($x>=1)?1:0 if $k<=0; return exp(log($x)/$k); } sub irgb($$) { my ($c,$bit)=@_; return ($c&8?0x55:0) + ($c&$bit?0xaa:0); } my %reverse=(0=>15, 15=>0, 7=>8, 8=>7); sub rgb($) { my ($c)=@_; $c=$reverse{$c} if $rv && exists $reverse{$c}; # basic 16 colors return (0xaa, 0x55, 0x00) if $c == 3; # Real CGA/VGA brown. return (0xee, 0xdd, 0x00) if $c == 11; # Less white yellow, especially when reversed. return (irgb($c,1), irgb($c,2), irgb($c,4)) if $c < 16; # 6x6x6 color cube if ($c < 232) { $c -= 16; use integer; my ($r,$g,$b) = ($c / 36, $c / 6 % 6, $c % 6); return ($r ? $r*0x28+0x37:0, $g ? $g*0x28+0x37:0, $b ? $b*0x28+0x37:0); } # grayscale ramp $c = $c*10-2312; return ($c, $c, $c); } my $setcolor; my $ncolors=15; my $out=""; if ($perm) { $setcolor = sub { shift; $out .= sprintf("%c%c%c", @_); }; } elsif ($ENV{"TERM"}=~/^linux/) { $setcolor = sub { printf "%s]P%1X%02X%02X%02X", $esc, @_; }; } elsif ($ENV{"TERM"}=~/^hurd/) { # Neither supports nor cleanly ignores. die "Hurd console doesn't support palette control, sorry.\n"; } else { $setcolor = sub { printf "%s]4;%d;rgb:%02x/%02x/%02x%s", $esc, @_, $esc eq '\e' ? '\e\\' : "\e\\"; }; $ncolors=255; } for(0..$ncolors) { my @rgb = rgb $_; if ($lab) { my $c=Graphics::ColorObject->new_RGB255(\@rgb); my @lab=@{$c->as_LCHab()}; $lab[0]=100*gamma($lab[0]/100, $r); @rgb=@{Graphics::ColorObject->new_LCHab(\@lab)->as_RGB255()}; } else { $rgb[0]=255*gamma $rgb[0]/255, $r; $rgb[1]=255*gamma $rgb[1]/255, $g; $rgb[2]=255*gamma $rgb[2]/255, $b; } $setcolor->($_, @rgb); } if ($perm) { ioctl(STDOUT,$PIO_CMAP,$out) or die "$0: PIO_CMAP failed: $^E\n"; } else { print "\n" if $esc ne "\e"; } vtgamma-0.4/vtgamma.1000066400000000000000000000060601320634146600145360ustar00rootroot00000000000000.TH vtgamma 1 2006-07-10 Debian "Linux console" .SH NAME vtgamma \- set gamma correction on text terminals .SH SYNOPSIS .B vtgamma .RI [ -e ] " " [ -r ] " " [ -l ] " " .br .B vtgamma .RI [ -e ] " " [ -r ] " " .SH DESCRIPTION .B vtgamma allows you to set the gamma correction on Linux console. It also works on most terminal emulators as well. A good deal of monitors tend to have too dark blue -- human eye is far less sensitive to blue light. This is acceptable for photographic images that should look realistically, but can cause blue, especially dark blue, text to be hard to read. .B vtgamma is also useful on aged CRT monitors, which tend to rapidly lose the luminance-to-voltage ratio. Even after just 2-3 years, typical CRT often needs gamma of as much as 1.6 to resemble a new one. The author of this words has seen a specimen that needed gamma of 2 2 6 (ie, with a big loss of blue) despite still having sharp display. Gamma correction is given as a positive floating-point number, with 1.0 being the default. .RB "To affect the login prompt, it's best to: " "vtgamma" .I 1.6 .BR ">>/etc/issue" ", where " .IR 1.6 " is the gamma correction you want (but see \fB-p\fR)." Without \fB-p\fR, the color profile lasts either until the next time a program resets the terminal. While this is quite a rare thing, it happens, and thus you'll probably want to have the gamma refreshed every time a program exits. The recommended way is to include \fBvtgamma\fR in \fBPROMPT_COMMAND\fR: .br .HP .I PROMPT_COMMAND='vtgamma 1.6' .HP 0 although if you don't want to spawn a process every prompt, you may instead edit .B ~/.bashrc and include the output of .BI "vtgamma -e " 1.6 .RB "in " PS1 ", enclosed between " \(rs[ " and " \(rs] "." Unfortunately, this won't work when you switch between terminals using different ways of setting gamma (currently Linux console vs most graphical terminals); \fBMidnight Commander\fR can't cope well with prompts containing such codes either. .SH OPTIONS .TP .BR -e | --escape Escapes the codes in a form suitable for .BR "echo -e" "," C/Perl/... literals, etc. You might want to include this in \fB/etc/issue\fR. .TP .BR -p | --permanent On Linux console (VT) only, sets the palette in a way that's permanent until reboot. This uses an ioctl rather than terminal codes, thus can't be captured and written as a string. .TP .BR -r | --reverse Black on white mode. Note that this does what you'd expect only on certain terminals, such as Linux console. On most graphical terminal emulators this affects only "real" black and white but not primary text and background colors. .TP .BR -l | --lab | --Lab | --lchab | --LCHab Uses the LCHab color space (a variant of Lab) instead of RGB, this allows brightening colors above FF0000. Requires the \fIGraphics::ColorObject\fR library (on Debian, install \fIlibgraphics-colorobject-perl\fR). .SH "SEE ALSO" .IR xgamma ( 1 ) .SH AUTHOR Both the program and this man page are the fault of Adam Borowski. Both of them are in the Public Domain, or the closest approximation allowed by law.