lsw-0.2/0000755000175000017500000000000011572513375010315 5ustar clsclslsw-0.2/config.mk0000644000175000017500000000055211572513375012115 0ustar clscls# lsw version VERSION = 0.2 # paths PREFIX = /usr/local MANPREFIX = ${PREFIX}/share/man X11INC = /usr/X11R6/include X11LIB = /usr/X11R6/lib # includes and libs INCS = -I${X11INC} LIBS = -L${X11LIB} -lX11 # flags CPPFLAGS = -DVERSION=\"${VERSION}\" CFLAGS = -ansi -pedantic -Wall -Os ${INCS} ${CPPFLAGS} LDFLAGS = -s ${LIBS} # compiler and linker CC = cc lsw-0.2/LICENSE0000644000175000017500000000217511572513375011327 0ustar clsclsMIT/X Consortium License © 2011 Connor Lane Smith © 2006-2011 Anselm R Garbe Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. lsw-0.2/lsw.c0000644000175000017500000000343011572513375011266 0ustar clscls/* See LICENSE file for copyright and license details. */ #include #include #include #include #include #include static void getname(Window win, char *buf, size_t size); static void lsw(Window win); static Atom netwmname; static Bool lflag = False; static Display *dpy; int main(int argc, char *argv[]) { int i; if(!(dpy = XOpenDisplay(NULL))) { fputs("lsw: cannot open display\n", stderr); exit(EXIT_FAILURE); } netwmname = XInternAtom(dpy, "_NET_WM_NAME", False); for(i = 1; i < argc; i++) if(!strcmp(argv[i], "-v")) { puts("lsw-"VERSION", © 2006-2011 lsw engineers, see LICENSE for details"); exit(EXIT_SUCCESS); } else if(!strcmp(argv[i], "-l")) lflag = True; else break; if(i == argc) lsw(DefaultRootWindow(dpy)); else while(i < argc) lsw(strtol(argv[i++], NULL, 0)); XCloseDisplay(dpy); return EXIT_SUCCESS; } void lsw(Window win) { char buf[BUFSIZ]; unsigned int i, n; Window *wins, dw; XWindowAttributes wa; if(!XQueryTree(dpy, win, &dw, &dw, &wins, &n)) return; for(i = 0; i < n; i++) if(XGetWindowAttributes(dpy, win, &wa) && !wa.override_redirect) { getname(wins[i], buf, sizeof buf); if(lflag) printf("0x%lx %s\n", wins[i], buf); else if(*buf) puts(buf); } XFree(wins); } void getname(Window win, char *buf, size_t size) { char **list = NULL; int n; XTextProperty prop; buf[0] = '\0'; if(!XGetTextProperty(dpy, win, &prop, netwmname) || prop.nitems == 0) if(!XGetWMName(dpy, win, &prop) || prop.nitems == 0) return; if(prop.encoding == XA_STRING) strncpy(buf, (char *)prop.value, size); else if(!XmbTextPropertyToTextList(dpy, &prop, &list, &n) && n > 0) { strncpy(buf, list[0], size); XFreeStringList(list); } XFree(prop.value); } lsw-0.2/README0000644000175000017500000000074711572513375011205 0ustar clsclslsw - list window titles ======================== Prints all window titles of DISPLAY to standard output. Requirements ------------ In order to build lsw you need the Xlib header files. Installation ------------ Edit config.mk to match your local setup (lsw is installed into the /usr/local namespace by default). Afterwards enter the following command to build and install lsw (if necessary as root): make clean install Running lsw ----------- See the man page for details. lsw-0.2/lsw.10000644000175000017500000000060611572513375011206 0ustar clscls.TH LSW 1 lsw\-VERSION .SH NAME lsw \- list window titles .SH SYNOPSIS .B lsw .RB [ \-l ] .RB [ \-v ] .RI [ windows ...] .SH DESCRIPTION .B lsw prints the titles of the given X windows' children to stdout. If no windows are given the root window is used. .SH OPTIONS .TP .B \-l lsw lists each window's XID as well as its title. .TP .B \-v prints version information to stdout, then exits. lsw-0.2/Makefile0000644000175000017500000000244111572513375011756 0ustar clscls# lsw - list window names # See LICENSE file for copyright and license details. include config.mk SRC = lsw.c OBJ = ${SRC:.c=.o} all: options lsw options: @echo lsw build options: @echo "CFLAGS = ${CFLAGS}" @echo "LDFLAGS = ${LDFLAGS}" @echo "CC = ${CC}" .c.o: @echo CC -c $< @${CC} -c ${CFLAGS} $< lsw: ${OBJ} @echo CC -o $@ @${CC} -o $@ ${OBJ} ${LDFLAGS} clean: @echo cleaning @rm -f lsw ${OBJ} lsw-${VERSION}.tar.gz dist: clean @echo creating dist tarball @mkdir -p lsw-${VERSION} @cp -R LICENSE Makefile README config.mk lsw.1 ${SRC} lsw-${VERSION} @tar -cf lsw-${VERSION}.tar lsw-${VERSION} @gzip lsw-${VERSION}.tar @rm -rf lsw-${VERSION} install: all @echo installing executable file to ${DESTDIR}${PREFIX}/bin @mkdir -p ${DESTDIR}${PREFIX}/bin @cp -f lsw ${DESTDIR}${PREFIX}/bin @chmod 755 ${DESTDIR}${PREFIX}/bin/lsw @echo installing manual page to ${DESTDIR}${MANPREFIX}/man1/lsw.1 @sed "s/VERSION/${VERSION}/g" < lsw.1 > ${DESTDIR}${MANPREFIX}/man1/lsw.1 @chmod 644 ${DESTDIR}${MANPREFIX}/man1/lsw.1 uninstall: @echo removing executable file from ${DESTDIR}${PREFIX}/bin @rm -f ${DESTDIR}${PREFIX}/bin/lsw @echo removing manual page from ${DESTDIR}${MANPREFIX}/man1 @rm -f ${DESTDIR}${MANPREFIX}/man1/lsw.1 .PHONY: all options clean dist install uninstall