xrootconsole-0.6/0040775000175000017500000000000010015510660012203 5ustar bobbobxrootconsole-0.6/.cvsignore0100664000175000017500000000002110015500730014166 0ustar bobbobxrootconsole *.o xrootconsole-0.6/COPYING0100664000175000017500000004310107052327402013241 0ustar bobbob GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. xrootconsole-0.6/CREDITS0100664000175000017500000000124310015506646013231 0ustar bobbobxrootconsole contributors: Eric Youngblut http://www.cs.washington.edu/homes/yngblut/ -- original author Bob Galloway http://de-fac.to/bob/ -- current maintainer Alexandre Duret-Lutz http://www.epita.fr/~duret_g/ -- eliminated flicker by storing background pixmap, drawing off-screen Zak Johnson -- man page Joseph Gorse -- FreeBSD patches Didier Verna -- patch to honor a virtual root window (eg KDE's icon layer) Martin Parm -- patch to parse standard colornames as well as #RRGGBB colorcodes xrootconsole-0.6/Makefile0100664000175000017500000000455710015500730013650 0ustar bobbob# vi:set ts=4 sw=4 et: # # Makefile # xrootconsole # Copyright (C) 1988,1999 Eric Youngblut & Bob Galloway # # $Id: Makefile,v 1.4 2004/02/20 21:53:28 bob Exp $ # # ########################################################################### # 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # The author of the original version of this software can be reached # by e-mail at yngblut@cs.washington.edu. The original version of # this software can be found at http://www.cs.washington.edu/homes/yngblut/ # # The author of the current version of this software can be reached # by e-mail at bgallowa@wso.williams.edu. The latest version of this # software can be found at http://wso.williams.edu/~bgallowa/ # ########################################################################### EXEC = xrootconsole BINDIR = /usr/local/bin MANFILE = xrootconsole.1 MANDIR = /usr/local/share/man/man1 VERSION = $(shell tag=$$(echo '$$Name: RELEASE-0_6 $$' | sed -e 's/\$$//g' -e 's/Name://g'); \ if [ $$tag ]; \ then echo $$tag; \ else echo Bleeding Edge Version; \ fi;) CC = gcc CPPFLAGS = # for production CFLAGS = -O2 -DNDEBUG -Wall "-DXROOTCONSOLE_VERSION=\"$(VERSION)\"" \ -I /usr/X11R6/include LDFLAGS = -s # for testing #CFLAGS = -g -Wall "-DXROOTCONSOLE_VERSION=\"$(VERSION) (debug build)\"" \ -I /usr/X11R6/include #LDFLAGS = LIBS = -L/usr/X11R6/lib -lX11 -lutil OBJS = main.o util.o # targets ----------------------------------------------------------------- all: $(EXEC) $(EXEC): $(OBJS) Makefile $(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o $@ $(OBJS): %.o: %.c util.h Makefile clean: rm -f *.o core *~ realclean: rm -f $(EXEC) *.o core *~ install: $(EXEC) cp $(EXEC) $(BINDIR) cp $(MANFILE) $(MANDIR) xrootconsole-0.6/NEWS0100664000175000017500000000202210015510213012665 0ustar bobbobxrootconsole 0.6 20Feb2004 * Fixes window placement to honor a virtual root window * FreeBSD patch (includes Xos.h for BSD compatability) * parses colornames ("darkgreen") as well as RGB colorcodes ("#336633") xrootconsole 0.5 30Jun2002 * fixed bug where XMaskEvent() would block indefinitely, silently halting the program. xrootconsole 0.4 19Dec2001 * refactored the hell out of the code, eliminated globals * minor performance gains * added a man page xrootconsole 0.3 05mar2000 * added -c option for multiple text columns * fixed printing of last line in window xrootconsole 0.2 27feb2000 * greatly reduced flicker * added --solid option for solid-color (opaque) background xrootconsole 0.1 15feb2000 * added shaded transparent background * reads from named file, not hard-coded /dev/console * maintainership passed from Youngblut to Galloway xrootconsole 0.0 19jan1999 (hey, every versioning system should start with 0) * first version (AFABobK) xrootconsole-0.6/README0100664000175000017500000000272507410061203013065 0ustar bobbobxrootconsole Copyright 1998,1999,2000 by several people; see the CREDITS file for details. Distributed under the GNU GPL version >= 2; see the COPYING file for details. Usage: xrootconsole [options] [console] Scroll the console to a transparent window placed on the X root window. -geometry GEO the geometry of the window (default 80x10+0+0) -fn FONT the font to use (default fixed) -fg COLOR foreground color of the text (default white) -bg COLOR background AND-mask for shaded transparency (default clear) -bd COLOR border color (default white) -bw WIDTH border width (default 0) -c COLUMNS split window into number of text columns (default 1) --solid make background a solid color, not shaded-transparent --topdown insert lines at the top and scroll the rest down --wrap wrap long lines, instead of cutting them off -h or --help a familiar-looking help screen -v or --version displays version number [console] filename to read (defaults to standard input) Report bugs to . To install: If you're on Debian (GNU/)Linux, type "make" and then "make install". If you're on some other UNIX, give it a try, and tweak the Makefile if and when you get errors. If you're really ticked off because there's no configure script, read the TODO file, and help out -- I'm going to delve into the byzantine mysteries of autoconf/automake, but only in my spare time. xrootconsole-0.6/TODO0100664000175000017500000000100507507774612012711 0ustar bobbob This is my to-do list (if you weren't paying attention). I'll get to it eventually, but maybe you'll find the missing feature more annoying than I do... The items are sorted in decreasing importance. * Automatic refresh (under shaded transparency) when xroot screen changes. * Split out heavyweight features like shaded transparency into compile time options, or different run-time strategies -- don't make people pay memory for features they aren't using. * Automake/autoconf help. xrootconsole-0.6/main.c0100664000175000017500000004430210015505331013272 0ustar bobbob/* vim:set ts=4 sw=4 et: * * main.c * xrootconsole * Original version: Copyright (C) 1998, 1999 Eric Youngblut * Current version: Copyright (C) 1999 Eric Youngblut & Bob Galloway * * (The transparency stuff was inspired by -- pulled from the still-warm * body of -- wterm. Many thanks to wterm's "anonymous coder!") * * $Id: main.c,v 1.13 2004/02/20 22:31:53 bob Exp $ * * * * ************************************************************************** * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * The author of the original version of this software can be reached * by e-mail at yngblut@cs.washington.edu. The original version of * this software can be found at http://www.cs.washington.edu/homes/yngblut/ * * The author of the current version of this software can be reached * by e-mail at bgallowa@wso.williams.edu. The latest version of this * software can be found at http://de-fac.to/bob/xrootconsole/ **************************************************************************/ #include "util.h" #include #include #include #include #include #include #include #include #include #include #include #ifndef XROOTCONSOLE_VERSION #define XROOTCONSOLE_VERSION "undefined" #endif #define USAGE \ "Usage: xrootconsole [options] [console]\n" \ "Scroll the console to a transparent window placed on the X root window.\n" \ "\n" \ " -geometry GEO the geometry of the window (default 80x10+0+0)\n" \ " -fn FONT the font to use (default fixed)\n" \ " -fg COLOR foreground color of the text (default white)\n" \ " -bg COLOR background AND-mask for shaded transparency (default clear)\n" \ " -bd COLOR border color (default white)\n" \ " -bw WIDTH border width (default 0)\n" \ " -c COLUMNS split window into number of text columns (default 1)\n" \ " --solid make background a solid color, not shaded-transparent\n" \ " --topdown insert lines at the top and scroll the rest down\n" \ " --wrap wrap long lines, instead of cutting them off\n" \ " -h or --help a familiar-looking help screen\n" \ " -v or --version displays the version number\n" \ " [console] filename to read (defaults to standard input)\n" \ "\n" \ "Report bugs to .\n" #define DEFAULT_X 0 #define DEFAULT_Y 0 #define DEFAULT_COLS 80 #define DEFAULT_ROWS 10 #define DEFAULT_FONT_NAME "fixed" #define DEFAULT_FOREGROUND_COLOR "white" #define DEFAULT_BACKGROUND_COLOR "white" #define DEFAULT_BORDER_COLOR "white" #define DEFAULT_BORDER_WIDTH 0 #define DEFAULT_TEXT_COLUMNS 1 #define DEFAULT_WRAP False #define DEFAULT_TOPDOWN False #define DEFAULT_SOLID False typedef struct { const char* fg; const char* bg; const char* bd; const char* geometry; const char* console_name; const char* font_name; int bw; int tc; /* number of text columns (NOT characters) */ int wrap; int topdown; int solid; } InitOptions; typedef struct { int x_root; /* position of the window (in pixels) */ int y_root; int width; /* size of the window (in pixels) */ int height; unsigned int cols; /* size of the window (in characters) */ unsigned int rows; int geometry; Display* dpy; Window win; Pixmap buf; /* the main drawable, copied to win by exposures */ Pixmap bkg; /* the background pixmap, copied to buf before each drawing */ XFontStruct* fn; /* text font */ GC foregc; GC backgc; int colwidth; /* width of a column in characters */ int nlines; /* number of lines to keep in memory */ int intercolgap; /* width between two columns */ XSetWindowAttributes swa; } WindowSettings; typedef struct { const char* console; /* name of the console file */ int fd; /* file descriptor of the console file */ char* text; /* circular buffer to store the characters */ int pos; /* where the actual first line in text is */ } ConsoleSettings; /* * put */ void put(const char* s, InitOptions *io, WindowSettings *ws, ConsoleSettings *cs) { static int x = 0, y = 0; while (*s != '\0') { switch (*s) { case '\n': x = 0; if (io->topdown) { cs->pos = (cs->pos + ws->nlines - 1) % ws->nlines; memset(cs->text + cs->pos * ws->colwidth, ' ', ws->colwidth); } else if (y == ws->nlines - 1) { memset(cs->text + cs->pos * ws->colwidth, ' ', ws->colwidth); cs->pos = (cs->pos + 1) % ws->nlines; } else y++; break; case '\t': x = (x / 8 + 1) * 8; if (x >= ws->cols && io->wrap) put("\n",io,ws,cs); break; default: if (*s >= ' ' && x < ws->colwidth) { cs->text[x + ((y + cs->pos) % ws->nlines) * ws->colwidth] = *s; if (++x == ws->colwidth && io->wrap) put("\n",io,ws,cs); } break; } s++; } } /* * write the text in the pixmap */ void draw_pixmap(InitOptions *io, WindowSettings *ws, ConsoleSettings *cs) { int rowc = cs->pos + (io->topdown==True); /* row in caracters */ int rowp = ws->fn->ascent; /* row in pixels */ int i,j; /* setup the background */ XCopyArea(ws->dpy, ws->bkg, ws->buf, ws->foregc, 0, 0, ws->width, ws->height, 0, 0); /* write the string */ for (i = ws->rows; i>0; --i) { for (j = 0; j < io->tc; ++j) { XDrawString(ws->dpy, ws->buf, ws->foregc, j * (ws->colwidth * ws->fn->max_bounds.width + ws->intercolgap), rowp, cs->text + ((rowc + j*(ws->rows)) % ws->nlines)*(ws->colwidth), ws->colwidth); } rowp += ws->fn->ascent + ws->fn->descent; ++rowc; } } /* * init */ void init_options(char **argv, InitOptions *io) { /* initialize InitOptions struct*/ io->console_name = NULL; io->geometry = NULL; io->fg = DEFAULT_FOREGROUND_COLOR; io->bg = DEFAULT_BACKGROUND_COLOR; io->bd = DEFAULT_BORDER_COLOR; io->bw = DEFAULT_BORDER_WIDTH; io->tc = DEFAULT_TEXT_COLUMNS; io->font_name = DEFAULT_FONT_NAME; io->wrap = DEFAULT_WRAP; io->topdown = DEFAULT_TOPDOWN; io->solid = DEFAULT_SOLID; /* Process command-line arguments */ while (*++argv != NULL) { if (!strcmp(*argv, "-geometry") || !strcmp(*argv, "-geo")) io->geometry = *++argv; else if (!strcmp(*argv, "-font") || !strcmp(*argv, "-fn")) io->font_name = *++argv; else if (!strcmp(*argv, "-foreground") || !strcmp(*argv, "-fg")) io->fg = *++argv; else if (!strcmp(*argv, "-background") || !strcmp(*argv, "-bg")) io->bg = *++argv; else if (!strcmp(*argv, "-bordercolor") || !strcmp(*argv, "-bd")) io->bd = *++argv; else if (!strcmp(*argv, "-borderwidth") || !strcmp(*argv, "-bw")) io->bw = atoi(*++argv); else if (!strcmp(*argv, "-columns") || !strcmp(*argv, "-c")) io->tc = atoi(*++argv); else if (!strcmp(*argv, "--solid")) io->solid = True; else if (!strcmp(*argv, "--wrap")) io->wrap = True; else if (!strcmp(*argv, "--topdown")) io->topdown = True; else if (!strcmp(*argv, "--version") || !strcmp(*argv, "-v")) { fprintf(stderr, "xrootconsole %s\n", XROOTCONSOLE_VERSION); exit(EXIT_SUCCESS); } else if (!strcmp(*argv, "--help") || !strcmp(*argv, "-h")) { fprintf(stderr, "xrootconsole %s\n%s", XROOTCONSOLE_VERSION,USAGE); exit(EXIT_SUCCESS); } else { io->console_name = *argv; } /* sanity check! */ if (io->tc < 1) io->tc = DEFAULT_TEXT_COLUMNS; } } int open_console(const char* console) { int fd; assert(console!=NULL); fd = open(console, O_RDONLY|O_NONBLOCK); if (fd < 0) { fprintf(stderr,"Console %s can't be opened! ",console); perror("Error"); exit (EXIT_FAILURE); } return fd; } void reset_console(ConsoleSettings *cs) { assert(cs->fd >= 0); assert((cs->fd >= 1) || (cs->console == NULL)); if (cs->console == NULL) exit(EXIT_SUCCESS); close(cs->fd); cs->fd = -1; } void init_console(const char *console, int colwidth, int nlines, ConsoleSettings *cs) { /* we never modify the name through a ConsoleSettings*, so don't bother copying the string */ cs->console = console; /* Create the text array. We can display "nlines-1" # of rows, and the extra one is for the line being read. */ cs->text = (char*)malloc(colwidth * nlines); memset(cs->text, ' ', colwidth * nlines); cs->pos = 0; if (cs->console == NULL) cs->fd = 0; /* STDIN special case, */ else cs->fd = open_console(cs->console); /* or open normal file */ } /* Return the root window, or a virtual root window if any. */ static Window root_window(Display *display) { Atom __SWM_VROOT = XInternAtom(display, "__SWM_VROOT", False); if (__SWM_VROOT != None) { Window unused, *windows; unsigned int count; if (XQueryTree(display, DefaultRootWindow (display), &unused, &unused, &windows, &count)) { int i; for (i=0; ix_root = DEFAULT_X; ws->y_root = DEFAULT_Y; ws->cols = DEFAULT_COLS; ws->rows = DEFAULT_ROWS; ws->intercolgap = 0; if (io->geometry) { ws->geometry = XParseGeometry(io->geometry, &(ws->x_root), &(ws->y_root), &(ws->cols), &(ws->rows)); } /* Connect to the X server */ ws->dpy = XOpenDisplay(NULL); if (ws->dpy == NULL) { fprintf(stderr, "Cannot open display\n"); exit(EXIT_FAILURE); } ws->fn = load_font(io->font_name, ws->dpy); /* compute text column geometry */ ws->nlines = ws->rows * io->tc + 1; ws->colwidth = ws->cols / io->tc; if (io->tc > 1) { /* ensure at least a 1 char gap between columns */ if ((ws->cols - ws->colwidth*io->tc)/(io->tc-1) < 1) --(ws->colwidth); ws->intercolgap = (ws->cols - ws->colwidth*io->tc) * ws->fn->max_bounds.width / (io->tc-1); } /* Calculate the position of window on the screen */ ws->width = ws->cols * ws->fn->max_bounds.width; ws->height = ws->rows * (ws->fn->ascent + ws->fn->descent); ws->x_root = (ws->geometry & XNegative) ? (DisplayWidth(ws->dpy, DefaultScreen(ws->dpy)) - ws->width + ws->x_root - (2*io->bw)) : ws->x_root; ws->y_root = (ws->geometry & YNegative) ? (DisplayHeight(ws->dpy, DefaultScreen(ws->dpy)) - ws->height + ws->y_root - (2*io->bw)) : ws->y_root; ws->swa.background_pixmap = ParentRelative; ws->swa.border_pixel = load_color(io->bd, ws->dpy); ws->swa.event_mask = ExposureMask; ws->swa.override_redirect = True; ws->win = XCreateWindow(ws->dpy, root_window(ws->dpy), ws->x_root, ws->y_root, ws->width, ws->height, io->bw, CopyFromParent, CopyFromParent, DefaultVisual(ws->dpy, DefaultScreen(ws->dpy)), CWOverrideRedirect | CWBackPixmap | CWEventMask | CWBorderPixel, &(ws->swa)); XMapWindow(ws->dpy, ws->win); /* Create the pixmaps */ ws->bkg = XCreatePixmap(ws->dpy, ws->win, ws->width, ws->height, DefaultDepth(ws->dpy, DefaultScreen(ws->dpy))); ws->buf = XCreatePixmap(ws->dpy, ws->win, ws->width, ws->height, DefaultDepth(ws->dpy, DefaultScreen(ws->dpy))); /* Create the foreground GC */ values.font = ws->fn->fid; values.foreground = load_color(io->fg, ws->dpy); values.graphics_exposures = 0; ws->foregc = XCreateGC(ws->dpy, ws->win, GCFont | GCForeground | GCGraphicsExposures, &values); /* initialize the background pixmap */ values.background = values.foreground; values.foreground = load_color(io->bg, ws->dpy); if (io->solid == True) { XLowerWindow(ws->dpy, ws->win); ws->backgc = XCreateGC(ws->dpy, ws->win, GCForeground | GCBackground, &values); XFillRectangle(ws->dpy, ws->bkg, ws->backgc, 0, 0, ws->width, ws->height); } else { /* shaded/transparent background */ values.function = GXand; ws->backgc = XCreateGC(ws->dpy, ws->win, GCForeground | GCBackground | GCFunction, &values); /* fill the window with root pixmap */ XClearWindow(ws->dpy,ws->win); /* take a snapshot for the root pixmap */ XCopyArea(ws->dpy, ws->win, ws->bkg, ws->foregc, 0, 0, ws->width, ws->height, 0, 0); /* in order to get the full pixmap we have to wait until the pixmap is copied before lowering the window */ XLowerWindow(ws->dpy, ws->win); /* AND-shade the background */ XFillRectangle(ws->dpy, ws->bkg, ws->backgc, 0, 0, ws->width, ws->height); } /* prevent the server from redrawing the background */ ws->swa.background_pixmap = None; XChangeWindowAttributes(ws->dpy, ws->win, CWBackPixmap, &(ws->swa)); } /* * handle_expose */ void handle_expose(XExposeEvent* ev, WindowSettings *ws) { XCopyArea(ws->dpy, ws->buf, ws->win, ws->foregc, ev->x, ev->y, ev->width, ev->height, ev->x, ev->y ); } /* * event_loop */ void event_loop(InitOptions *io, WindowSettings *ws, ConsoleSettings *cs) { fd_set rfds; fd_set efds; int Xfd = ConnectionNumber(ws->dpy); int maxfd; struct timeval select_timeout; XEvent ev; maxfd = (cs->fd > Xfd ? cs->fd : Xfd) + 1; while (1) { while ((XPending(ws->dpy) > 0) && (XCheckMaskEvent(ws->dpy, ExposureMask, &ev) == True)) { handle_expose((XExposeEvent*)&ev.xexpose, ws); } XLowerWindow(ws->dpy, ws->win); /* has the file moved from under us? re-open if so. */ if (cs->fd < 0) { cs->fd = open_console(cs->console); maxfd = (cs->fd > Xfd ? cs->fd : Xfd) + 1; } FD_ZERO(&rfds); FD_ZERO(&efds); FD_SET(Xfd, &rfds); FD_SET(cs->fd, &rfds); FD_SET(cs->fd, &efds); select_timeout.tv_sec = 5; select_timeout.tv_usec = 0; if (select(maxfd, &rfds, NULL, &efds, &select_timeout) == -1) { perror("select error"); exit(EXIT_FAILURE); } if (FD_ISSET(cs->fd, &rfds)) { char buf[1024]; int n; n = read(cs->fd, buf, sizeof(buf) - 1); if (n == -1) { sleep(1); if (errno != EAGAIN) {reset_console(cs);} } else if (n > 0) { buf[n] = '\0'; put(buf,io,ws,cs); draw_pixmap(io,ws,cs); /* make an exposure event */ XClearArea(ws->dpy, ws->win, 0, 0, 0, 0, True); } else { /* n == 0 --> EOF */ sleep(1); } } else if (FD_ISSET(cs->fd, &efds)) { reset_console(cs); sleep(1); } } /* end loop */ } /* * main */ int main(int argc, char** argv) { InitOptions io; ConsoleSettings cs; WindowSettings ws; init_options(argv, &io); init_window(&io,&ws); init_console(io.console_name, ws.colwidth, ws.nlines, &cs); /* Display a message */ put("xrootconsole ",&io,&ws,&cs); put(XROOTCONSOLE_VERSION,&io,&ws,&cs); put("\n",&io,&ws,&cs); draw_pixmap(&io,&ws,&cs); event_loop(&io,&ws,&cs); XCloseDisplay(ws.dpy); exit(EXIT_SUCCESS); } xrootconsole-0.6/test0100775000175000017500000000121610015502456013111 0ustar bobbob#!/bin/sh # simple test script # yes, I know the color scheme is painful and wrong. :) ping -i 5 localhost |./xrootconsole -bw 2 -bd '#000000' -fg 'darkgreen' -bg '#660099' --wrap -geometry +100+260 $@ # testing long lines, column wrapping #{ while [ 1 ] ; do sleep 1; echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx; done; } |./xrootconsole -bw 2 -bd '#000000' -fg '#FF3333' -bg '#660099' --wrap -geometry +100+260 $@ xrootconsole-0.6/util.c0100664000175000017500000000427610015502456013336 0ustar bobbob/* vi:set ts=4 sw=4 et: * * util.c * xrootconsole * Original version: Copyright (C) 1998, 1999 Eric Youngblut * * * $Id: util.c,v 1.4 2004/02/20 22:07:42 bob Exp $ * * * * ************************************************************************** * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * The author of the original version of this software can be reached * by e-mail at yngblut@cs.washington.edu. The original version of * this software can be found at http://www.cs.washington.edu/homes/yngblut/ * * The author of the current version of this software can be reached * by e-mail at bgallowa@wso.williams.edu. The latest version of this * software can be found at http://wso.williams.edu/~bgallowa/ **************************************************************************/ #include "util.h" #include #include XFontStruct* load_font(const char* s, Display *dpy) { XFontStruct* f = XLoadQueryFont(dpy, s); if (f == NULL) { fprintf(stderr, "Unable to open font"); exit(EXIT_FAILURE); } return f; } unsigned long load_color(const char* s, Display *dpy) { XColor ce; Colormap colormap = DefaultColormap(dpy, DefaultScreen(dpy)); if (XParseColor(dpy, colormap, s, &ce)) { if (XAllocColor(dpy, colormap, &ce)) return ce.pixel; fprintf(stderr, "Warning: could not allocate color\n"); return WhitePixel(dpy, DefaultScreen(dpy)); } fprintf(stderr, "Warning: could not parse color\n"); return WhitePixel(dpy, DefaultScreen(dpy)); } xrootconsole-0.6/util.h0100664000175000017500000000317707170476121013351 0ustar bobbob/* vi:set ts=4 sw=4 et: * * util.h * xrootconsole * Original version: Copyright (C) 1998, 1999 Eric Youngblut * * * $Id: util.h,v 1.3 2000/10/10 02:17:53 bob Exp $ * * * ************************************************************************** * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * The author of the original version of this software can be reached * by e-mail at yngblut@cs.washington.edu. The original version of * this software can be found at http://www.cs.washington.edu/homes/yngblut/ * * The author of the current version of this software can be reached * by e-mail at bgallowa@wso.williams.edu. The latest version of this * software can be found at http://wso.williams.edu/~bgallowa/ **************************************************************************/ #ifndef __XRC_UTIL_H #define __XRC_UTIL_H #include XFontStruct* load_font(const char* s, Display *dpy); unsigned long load_color(const char* s, Display *dpy); #endif xrootconsole-0.6/xrootconsole.10100664000175000017500000000465507507774612015057 0ustar bobbob.Dd May 19, 2000 .Dt XROOTCONSOLE 1 .Os .Sh NAME .Nm xrootconsole .Nd display a file (or stdin) to a transparent window .Sh SYNOPSIS .Nm xrootconsole .Op options .Op Ar file .Sh DESCRIPTION xrootconsole is a small utility which displays its input in a transparent text box on X's root window. It will read from any file listed on the command line or, by default, from stdin. It is most useful when it reads from a FIFO; this allows you to redirect multiple commands to the FIFO and monitor their output. .Pp The options are as follows: .Bl -tag -width Fl .It Fl fg Ar color This option specifies the color to use for displaying text. The default is .Dq black. .It Fl bg Ar color This option specifies the color to AND with the root window, for shaded transparency. The default is .Dq clear. .It Fl bw Ar number This option specifies the width of the border around xrootconsole in pixels. The default is 0. .It Fl bd Ar color This option specifies the color to use for the border of the window. The default is .Dq black. .It Fl fn Ar font This option specifies the font to use for displaying text. The default is .Dq fixed. .It Fl c Ar number This option produces output that is .Ar number columns wide. Text is written vertically down each column in the order in which text is received from the input file. The default is 1. .It Fl -topdown Forces xrootconsole to display new lines from its input at the top of the screen, scrolling previous lines down. Default behavior is to insert new lines at the bottom and scroll the previous lines up. .It Fl -wrap Rather than truncating long lines, this option specifies that xrootconsole should wrap excess text to the following line or lines, as necessary. .It Fl geometry Ar geometry This option specifies the preferred size and position of the window; see .Xr X 1 . The default is .Dq 80x10+0+0. .It Fl h , Fl -help Displays a detailed usage message and exits. .It Fl v , Fl -version Displays the program version and exits. .It Ar file Optionally specifies a file from which to read input; by default, xrootconsole reads from the standard input. .El .Sh DIAGNOSTICS Exit status is 0 on success, and 1 if the command fails for any reason. .Sh AUTHORS Eric Youngblut is the original author of xrootconsole. Bob Galloway .Aq bob@de-fac.to is the current maintainer. Alexandre Duret\-Lutz eliminated flicker by storing the background pixmap and drawing off-screen. This manual page was written by Zak Johnson .Aq zakj@i.am .