├── extra └── ttycolor.png ├── MANIFEST ├── README.md ├── Makefile.PL └── bin └── ttycolor /extra/ttycolor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trapd00r/ttycolor/HEAD/extra/ttycolor.png -------------------------------------------------------------------------------- /MANIFEST: -------------------------------------------------------------------------------- 1 | Makefile.PL 2 | MANIFEST This list of files 3 | bin/ttycolor 4 | MYMETA.json 5 | MYMETA.yml 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=65SFZJ25PSKG8¤cy_code=SEK&source=url) - Every tiny cent helps a lot! 2 | 3 | # NAME 4 | 5 | ttycolor - set the colors in the TTY / Linux Virtual Console 6 | 7 | ![shot](/extra/ttycolor.png) 8 | 9 | # USAGE 10 | 11 | ttycolor [colorscheme] 12 | 13 | # DESCRIPTION 14 | 15 | ttycolor allows you to change the colors in a Linux Virtual Console (TTY). 16 | It uses Term::ExtendedColor::TTY and Term::ExtendedColor::TTY::Colorschemes to 17 | perform this magic. 18 | 19 | # OPTIONS 20 | -l, --list list available colorschemes 21 | 22 | -h, --help show the help and exit 23 | -v, --version show version info and exit 24 | -m, --man show the manual and exit 25 | 26 | # SEE ALSO 27 | 28 | Term::ExtendedColor::TTY, Term::ExtendedColor::TTY::Colorschemes 29 | 30 | # AUTHOR 31 | Magnus Woldrich 32 | CPAN ID: WOLDRICH 33 | m@japh.se 34 | http://japh.se 35 | 36 | # REPORTING BUGS 37 | Report bugs on rt.cpan.org or to m@japh.se 38 | 39 | # COPYRIGHT 40 | 41 | Copyright (C) 2010, 2011, 2018- Magnus Woldrich. All right reserved. This program is 42 | free software; you can redistribute it and/or modify it under the same 43 | terms as Perl itself. 44 | -------------------------------------------------------------------------------- /Makefile.PL: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | use ExtUtils::MakeMaker; 4 | 5 | WriteMakefile1( 6 | META_MERGE => { 7 | q(meta-spec) => { version => 2 }, 8 | resources => { 9 | repository => { 10 | type => 'git', 11 | url => 'https://github.com/trapd00r/ttycolor.git', 12 | web => 'https://github.com/trapd00r/ttycolor', 13 | bugtracker => 'https://github.com/trapd00r/ttycolor/issues', 14 | }, 15 | }, 16 | }, 17 | 18 | NAME => 'App::ttycolor', 19 | AUTHOR => q{Magnus Woldrich }, 20 | ABSTRACT => 'Set the colors in the TTY / Linux Virtual Console', 21 | VERSION_FROM => 'bin/ttycolor', 22 | 'LICENSE' => 'perl', 23 | PL_FILES => {}, 24 | EXE_FILES => ['bin/ttycolor'], 25 | PREREQ_PM => { 26 | 'Term::ExtendedColor::TTY' => 0, 27 | 'Term::ExtendedColor::TTY::Colorschemes' => 0, 28 | }, 29 | META_ADD => { 30 | provides => { 31 | 'App::ttycolor' => { 32 | file => 'bin/ttycolor', 33 | }, 34 | }, 35 | }, 36 | MAN1PODS => { 37 | }, 38 | dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, 39 | clean => { FILES => 'ttycolor-*' }, 40 | ); 41 | 42 | sub WriteMakefile1 { 43 | my %params=@_; 44 | my $eumm_version=$ExtUtils::MakeMaker::VERSION; 45 | $eumm_version=eval $eumm_version; 46 | die "EXTRA_META is deprecated" if exists $params{EXTRA_META}; 47 | die "License not specified" if not exists $params{LICENSE}; 48 | if ($params{AUTHOR} and ref($params{AUTHOR}) eq 'ARRAY' 49 | and $eumm_version < 6.5705) { 50 | $params{META_ADD}->{author}=$params{AUTHOR}; 51 | $params{AUTHOR}=join(', ',@{$params{AUTHOR}}); 52 | } 53 | if ($params{BUILD_REQUIRES} and $eumm_version < 6.5503) { 54 | #EUMM 6.5502 has problems with BUILD_REQUIRES 55 | $params{PREREQ_PM}={ 56 | %{$params{PREREQ_PM} || {}} , %{$params{BUILD_REQUIRES}} 57 | }; 58 | delete $params{BUILD_REQUIRES}; 59 | } 60 | delete $params{CONFIGURE_REQUIRES} if $eumm_version < 6.52; 61 | delete $params{MIN_PERL_VERSION} if $eumm_version < 6.48; 62 | delete $params{META_MERGE} if $eumm_version < 6.46; 63 | delete $params{META_ADD} if $eumm_version < 6.46; 64 | delete $params{LICENSE} if $eumm_version < 6.31; 65 | delete $params{AUTHOR} if $] < 5.005; 66 | delete $params{ABSTRACT_FROM} if $] < 5.005; 67 | delete $params{BINARY_LOCATION} if $] < 5.005; 68 | 69 | WriteMakefile(%params); 70 | } 71 | -------------------------------------------------------------------------------- /bin/ttycolor: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | my $APP = 'ttycolor'; 3 | use vars qw($VERSION); 4 | $VERSION = '0.20'; 5 | 6 | use strict; 7 | use warnings; 8 | no warnings 'experimental::smartmatch'; 9 | 10 | use Term::ExtendedColor::TTY qw(set_tty_color); 11 | use Term::ExtendedColor::TTY::Colorschemes; 12 | use Getopt::Long; 13 | use Pod::Usage; 14 | 15 | 16 | GetOptions( 17 | 'l|list' => sub { print "$_\n" for get_colorschemes(); exit 0; }, 18 | 't|tty=i' => \(my $tty = ''), 19 | 'r|reset' => \my $reset, 20 | 21 | 'h|help' => sub { pod2usage(verbose => 1); }, 22 | 'm|man' => sub { pod2usage(verbose => 3); }, 23 | 'v|version' => sub { print "$APP v$VERSION\n" and exit 0; }, 24 | ); 25 | 26 | if($ENV{DISPLAY}) { 27 | print STDERR "ttycolor only works in a TTY; not in X.\n"; 28 | print STDERR "Proceed anyway? [N/y] "; 29 | chomp(my $choice = ); 30 | if(lc($choice) ne 'y') { 31 | exit 0; 32 | } 33 | } 34 | 35 | 36 | my $colorscheme = shift // 'woldrich'; 37 | my @colorschemes = get_colorschemes(); 38 | 39 | if( !($colorscheme ~~ @colorschemes) ) { 40 | $colorscheme = grab_new_colorscheme($colorscheme); 41 | } 42 | 43 | $colorscheme = set_tty_color( get_colorscheme($colorscheme) ); 44 | 45 | open(my $fh, '>', "/dev/tty$tty") or die("Can't open tty: $!"); 46 | 47 | 48 | if($reset) { 49 | syswrite $fh, "\033]R"; 50 | exit; 51 | } 52 | 53 | for my $index(sort(keys(%{$colorscheme}))) { 54 | syswrite $fh, $colorscheme->{$index}; 55 | } 56 | 57 | sub grab_new_colorscheme { 58 | my $c = shift; 59 | print "No such colorscheme '$c'\n"; 60 | RERUN: 61 | print "Available colorschemes:\n"; 62 | print "$_\n" for @colorschemes; 63 | print "> "; 64 | chomp(my $choice = ); 65 | 66 | if(!($choice ~~ @colorschemes)) { 67 | goto RERUN; 68 | } 69 | else { 70 | return $choice; 71 | } 72 | } 73 | 74 | =pod 75 | 76 | =head1 NAME 77 | 78 | ttycolor - set the colors in the TTY / Linux Virtual Console 79 | 80 | =head1 SYNOPSIS 81 | 82 | B [OPTIONS] [colorscheme] 83 | 84 | =head1 DESCRIPTION 85 | 86 | ttycolor allows you to change the colors in a Virtual Console. 87 | It uses L and L 88 | to perform that magic. 89 | 90 | =head1 OPTIONS 91 | 92 | -l, --list list available colorschemes 93 | -t, --tty=N specify TTY 94 | -r, --reset reset to default TTY palette 95 | 96 | -h, --help show the help and exit 97 | -v, --version show version info and exit 98 | -m, --man show the manual and exit 99 | 100 | =head1 SEE ALSO 101 | 102 | L, L 103 | 104 | =head1 AUTHOR 105 | 106 | Magnus Woldrich 107 | CPAN ID: WOLDRICH 108 | m@japh.se 109 | http://japh.se 110 | 111 | =head1 REPORTING BUGS 112 | 113 | Report bugs on rt.cpan.org or to m@japh.se 114 | 115 | =head1 COPYRIGHT 116 | 117 | Copyright (C) 2010, 2011, 2018 Magnus Woldrich. All right reserved. 118 | This program is free software; you can redistribute it and/or modify it under 119 | the same terms as Perl itself. 120 | 121 | =cut 122 | --------------------------------------------------------------------------------