pax_global_header00006660000000000000000000000064145006266300014514gustar00rootroot0000000000000052 comment=80f456d647442108366abb6cb663fdf545928096 vtgamma-0.5/000077500000000000000000000000001450062663000130145ustar00rootroot00000000000000vtgamma-0.5/.gitignore000066400000000000000000000000031450062663000147750ustar00rootroot00000000000000*~ vtgamma-0.5/LICENSE000066400000000000000000000002731450062663000140230ustar00rootroot00000000000000I 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.5/README000066400000000000000000000010601450062663000136710ustar00rootroot00000000000000If 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.5/vtgamma000077500000000000000000000104341450062663000144000ustar00rootroot00000000000000#!/usr/bin/perl -w use strict; my $esc="\e"; my $lab=0; my @args=[]; my $rv=0; my $perm=0; my $scheme; my $USAGE=<\e[0m [...] vtgamma \e[30;1m[-e] [-r] [-l]\e[0m \e[1m\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 my %palette = ( "vga"=> [0x000000, 0xaa0000, 0x00aa00, 0xaa5500, 0x0000aa, 0xaa00aa, 0x00aaaa, 0xaaaaaa, 0x555555, 0xff5555, 0x55ff55, 0xeedd00, 0x5555ff, 0xff55ff, 0x55ffff, 0xffffff], "ubuntu"=> [0x010101, 0xde382b, 0x39b54a, 0xffc706, 0x006fb8, 0x762671, 0x2cb5e9, 0xcccccc, 0x808080, 0xff0000, 0x00ff00, 0xffff00, 0x0000ff, 0xff00ff, 0x00ffff, 0xffffff], "gruvbox"=> [0x282828, 0xcc241d, 0x98971a, 0xd79921, 0x458588, 0xb16286, 0x689d6a, 0xa89984, 0x928374, 0xfb4934, 0xb8bb26, 0xfabd2f, 0x83a598, 0xd3869b, 0x8ec07c, 0xebdbb2], "gruvbox-light"=> [0xfbf1c7, 0xcc241d, 0x98971a, 0xd79921, 0x458588, 0xb16286, 0x689d6a, 0x7c6f64, 0x928374, 0x9d0006, 0x79740e, 0xb57614, 0x076678, 0x8f3f71, 0x427b58, 0x3c3836], "monokai"=> [0x272822, 0xf92672, 0xa6e22e, 0xf4bf75, 0x66d9ef, 0xae81ff, 0xa1efe4, 0xf8f8f2, 0x75715e, 0xf92672, 0xa6e22e, 0xf4bf75, 0x66d9ef, 0xae81ff, 0xa1efe4, 0xf9f8f5], ); 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 (/^[^-]/) { $scheme=$_; } 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)? $scheme ? (1,1,1) : 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"; my %reverse=(0=>15, 15=>0, 7=>8, 8=>7); my $pal; $scheme//="vga"; if ($rv && $palette{"$scheme-light"}) { $pal=$palette{$scheme.="-light"}; %reverse=(); } elsif (!($pal=$palette{$scheme})) { die "Unknown palette: ļ½¢$schemeļ½£\n"; } sub gamma($$) { my ($x,$k)=@_; return 0 if $x<=0; return ($x>=1)?1:0 if $k<=0; return exp(log($x)/$k); } sub unp($) { my $c=$_[0]; return ($c>>16, $c>>8 & 0xff, $c & 0xff); } sub rgb($) { my ($c)=@_; $c=$reverse{$c} if $rv && exists $reverse{$c}; # basic 16 colors return unp($$pal[$c]) if $pal && $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.5/vtgamma.1000066400000000000000000000065541450062663000145440ustar00rootroot00000000000000.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 ] " " .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. You may also select a different palette than default "\fBvga\fR". A palette may then have a gamma correction applied to it -- all options are allowed. .TP This version recognizes the following palettes: vga .br gruvbox .br monokai .br ubuntu .RE .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.