Package: kbd Version: 1.15-1ubuntu4 Severity: wishlist I just uploaded this change to Ubuntu's kbd package, and I thought it prudent to send it upstream to Debian as well, as I suspect some Debian users might appreciate this utility.
I (co-)wrote a tool, /sbin/setvtrgb, that uses a clever ioctl() to dynamically adjust the virtual terminal's (console's) 16-color color map. There's a manpage included in the diff that explains how to (very simply) use the tool. A separate upload to another source package (console-setup) in Ubuntu will install a distro-recommended (though user-adjustable) conffile with an attractive palette and an upstart job that applies the configuration on boot. Debdiff attached. Thanks! -- System Information: Debian Release: squeeze/sid APT prefers natty-updates APT policy: (500, 'natty-updates'), (500, 'natty-security'), (500, 'natty') Architecture: amd64 (x86_64) Kernel: Linux 2.6.38-5-generic (SMP w/4 CPU cores) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Versions of packages kbd depends on: ii console-setup 1.57ubuntu11 console font and keymap setup prog ii initramfs-tools 0.98.8ubuntu2 tools for generating an initramfs ii libc6 2.13-0ubuntu4 Embedded GNU C Library: Shared lib ii lsb-base 4.0-0ubuntu9 Linux Standard Base 4.0 init scrip kbd recommends no packages. kbd suggests no packages. -- no debconf information
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 <seth.fors...@canonical.com> + Dustin Kirkland <kirkl...@canonical.com> diff -u kbd-1.15/debian/changelog kbd-1.15/debian/changelog --- kbd-1.15/debian/changelog +++ kbd-1.15/debian/changelog @@ -1,3 +1,14 @@ +kbd (1.15-1ubuntu4) natty; urgency=low + + * src/setvtrgb.c, man/man8/setvtrgb.8, COPYING, debian/rules, + debian/copyright: LP: #730672 + - Add a 'setvtrgb' utility to configure vt/console colors + - add to udeb (so that this can improve installer usability) + - add to /sbin, run by root + - update copyright statement + + -- Dustin Kirkland <kirkl...@ubuntu.com> Tue, 08 Mar 2011 15:32:10 +0000 + kbd (1.15-1ubuntu3) lucid; urgency=low * loadkeys: If not invoked with an explicit console parameter, try to find 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 diff -u kbd-1.15/src/loadkeys.c kbd-1.15/src/loadkeys.c 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 <seth.fors...@canonical.com> + Dustin Kirkland <kirkl...@canonical.com> + 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: only in patch2: unchanged: 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,135 @@ +/* + * setvtrgb - set the virtual terminal RGB colors + * Copyright (C) 2011 Canonical Ltd. + * + * Authors: Seth Forshee <seth.fors...@canonical.com> + * Dustin Kirkland <kirkl...@canonical.com> + * + * 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 <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <unistd.h> +#include <sys/ioctl.h> +#include <linux/kd.h> +#include <errno.h> + +/* 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++) { + /* 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*16] = (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); +} 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 <kirkl...@canonical.com> 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 && \