diff -u kbd-1.15/debian/copyright kbd-1.15/debian/copyright --- kbd-1.15/debian/copyright +++ kbd-1.15/debian/copyright @@ -63,0 +64,6 @@ + +Files: setvtrgb.c +Copyright © 2011 Canonical Ltd. +License: GPL-2+ +Authors: Seth Forshee + Dustin Kirkland diff -u kbd-1.15/debian/rules kbd-1.15/debian/rules --- kbd-1.15/debian/rules +++ kbd-1.15/debian/rules @@ -4,12 +4,12 @@ KBD = $(TOPDIR)/debian/kbd KBD_UDEB = $(TOPDIR)/debian/kbd-udeb -UDEB_BINARIES = loadkeys kbd_mode setfont +UDEB_BINARIES = loadkeys kbd_mode setfont setvtrgb EXTRA_BINARIES = screendump setlogcons setvesablank CONTRIB_BINARIES = codepage splitfont vcstime MOVE_TO_BIN = kbd_mode setfont fgconsole openvt chvt dumpkeys unicode_start loadkeys -MOVE_TO_SBIN = kbdrate +MOVE_TO_SBIN = kbdrate setvtrgb MOVE_TO_USR_SBIN = vcstime setvesablank configure: configure-stamp only in patch2: unchanged: --- kbd-1.15.orig/COPYING +++ kbd-1.15/COPYING @@ -28,6 +28,12 @@ (and changes to earlier mentioned programs) are Copyright (C) 1994-1999 Andries E. Brouwer. +The file + setvtrgb.c +is Copyright (C) 2011 Canonical Ltd. + Authors: Seth Forshee + Dustin Kirkland + All files in this package may be freely copied under the terms of the GNU General Public License (GPL), version 2, or at your option any later version - except possibly for the restrictions only in patch2: unchanged: --- kbd-1.15.orig/man/man8/setvtrgb.8 +++ kbd-1.15/man/man8/setvtrgb.8 @@ -0,0 +1,21 @@ +.\" @(#)man/man8/setvtrgb.8 1.0 Mar 3 12:32:18 CST 2011 +.TH SETVTRGB 8 "3 Mar 2011" "Set Virtual Terminal RGB Colors" +.SH NAME +setvtrgb \- set the virtual terminal RGB colors +.SH SYNOPSIS +.B setvtrgb +.I vga|[FILE] +.SH DESCRIPTION +The +.I setvtrgb +command takes a single argument, either the string "vga", or a path to a file containing the red, green, and blue colors to be used by the Linux virtual terminals. + +If you use the FILE parameter, FILE should be exactly 3 lines of 16 comma-separated decimal values for RED, GREEN, and BLUE. + +To seed a valid FILE: + cat /sys/module/vt/parameters/default_{red,grn,blu} > FILE + +And then edit the values in FILE. + +.SH AUTHOR +This manpage and the utility were written by Dustin Kirkland for Ubuntu systems (but may be used by others). Permission is granted to copy, distribute and/or modify this document and the utility under the terms of the GNU General Public License, Version 2 or any later version published by the Free Software Foundation. The complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL-2 on Debian/Ubuntu systems, or on the web at http://www.gnu.org/licenses/gpl2.txt. only in patch2: unchanged: --- kbd-1.15.orig/man/man8/Makefile.am +++ kbd-1.15/man/man8/Makefile.am @@ -1,6 +1,6 @@ gen_MANS = loadunimap.8 mapscrn.8 setfont.8 dist_man_MANS = getkeycodes.8 kbdrate.8 resizecons.8 setkeycodes.8 \ - showconsolefont.8 $(gen_MANS) + showconsolefont.8 setvtrgb.8 $(gen_MANS) install-data-hook: cd $(DESTDIR)$(mandir)/man8 && \ only in patch2: unchanged: --- kbd-1.15.orig/src/Makefile.am +++ kbd-1.15/src/Makefile.am @@ -4,7 +4,7 @@ PROGS = \ dumpkeys loadkeys showkey setfont showconsolefont \ setleds setmetamode kbd_mode chvt deallocvt \ - psfxtable kbdrate fgconsole openvt + psfxtable kbdrate fgconsole openvt setvtrgb if KEYCODES_PROGS PROGS += getkeycodes setkeycodes @@ -54,6 +54,7 @@ screendump_SOURCES = $(ALL_S) screendump.c $(XMAL_S) setfont_SOURCES = $(ALL_S) setfont.c $(FIND_S) $(XMAL_S) $(GETFD_S) mapscrn.c $(KDMA_S) $(PSF_S) $(UTF8_S) kdfontop.c kdfontop.h $(UNIM_S) setkeycodes_SOURCES = $(ALL_S) setkeycodes.c $(GETFD_S) +setvtrgb_SOURCES = $(ALL_S) setvtrgb.c $(GETFD_S) setlogcons_SOURCES = $(ALL_S) setlogcons.c $(GETFD_S) setpalette_SOURCES = $(ALL_S) setpalette.c $(GETFD_S) setvesablank_SOURCES = $(ALL_S) setvesablank.c $(GETFD_S) only in patch2: unchanged: --- kbd-1.15.orig/src/setvtrgb.c +++ kbd-1.15/src/setvtrgb.c @@ -0,0 +1,136 @@ +/* + * setvtrgb - set the virtual terminal RGB colors + * Copyright (C) 2011 Canonical Ltd. + * + * Authors: Seth Forshee + * Dustin Kirkland + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* Standard VGA terminal colors, matching those hardcoded in the Linux kernel's + * drivers/tty/vt/vt.c + */ +unsigned char vga_colors[] = { + 0x00, 0x00, 0x00, + 0xaa, 0x00, 0x00, + 0x00, 0xaa, 0x00, + 0xaa, 0x55, 0x00, + 0x00, 0x00, 0xaa, + 0xaa, 0x00, 0xaa, + 0x00, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, + 0x55, 0x55, 0x55, + 0xff, 0x55, 0x55, + 0x55, 0xff, 0x55, + 0xff, 0xff, 0x55, + 0x55, 0x55, 0xff, + 0xff, 0x55, 0xff, + 0x55, 0xff, 0xff, + 0xff, 0xff, 0xff, +}; + +/* Usage statement */ +void usage(void) { + fprintf(stderr, +"\nUSAGE: setvtrgb vga|[FILE]\n" +"\n" +"If you use the FILE parameter, FILE should be exactly 3 lines of\n" +"comma-separated decimal values for RED, GREEN, and BLUE.\n" +"\n" +"To seed a valid FILE:\n" +" cat /sys/module/vt/parameters/default_{red,grn,blu} > FILE\n" +"\n" +"And then edit the values in FILE.\n\n" +); + exit(EINVAL); +} + +int main(int argc, const char *argv[]) { + int fd; + FILE *fp = NULL; + int i, j; + char *c; + unsigned char *cmap; + char s[1024]; + + /* Must have at least one argument */ + if (argc != 2) + usage(); + + if (strcmp(argv[1], "vga") == 0) + /* Use the Standard VGA colors */ + cmap = vga_colors; + else if (fp = fopen(argv[1], "r" )) { + /* Use a color palette specified in a file */ + /* Allocate a 48 character array */ + cmap = calloc(3*16, sizeof(unsigned char)); + for (i=0; i<3; i++) { + j = 0; + /* Retrieve a line from file */ + /* Tokenize the CSV string, convert to int, then to char */ + if (fgets(s, sizeof(s), fp)) { + if ((c = strtok(s, ",")) != NULL) + cmap[i+j*3] = (unsigned char)atoi(c); + else { + fprintf(stderr, "ERROR: Error reading color value at line [%d], position [%d], file [%s]\n", i+1, 1, argv[1]); + usage(); + } + for (j=1; j<16; j++) { + if ((c = strtok(NULL, ",")) != NULL) + cmap[i+j*3] = (unsigned char)atoi(c); + else { + fprintf(stderr, "ERROR: Error reading color value at line [%d], position [%d], file [%s]\n", i+1, j+1, argv[1]); + usage(); + } + } + } else { + fprintf(stderr, "ERROR: Invalid file at [%s]\n", argv[1]); + usage(); + } + } + fclose(fp); + } else { + perror(argv[1]); + usage(); + } + + /* Ensure that this user can open tty, before going further */ + fd = open("/dev/tty0", O_RDONLY); + if (fd < 0) { + perror(argv[1]); + exit(errno); + } + + /* Apply the color map to the tty via ioctl */ + if (ioctl(fd, PIO_CMAP, cmap) < 0) { + perror("ioctl"); + exit(errno); + } + close(fd); + return(0); +}