lsw-0.3/0000755000175000017500000000000012436370760011511 5ustar anselmanselmlsw-0.3/LICENSE0000644000175000017500000000217512436370760012523 0ustar anselmanselmMIT/X Consortium License © 2006-2014 Anselm R Garbe © 2011 Connor Lane Smith 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.3/README0000644000175000017500000000072612436370760012376 0ustar anselmanselmlsw - list windows ================== lsw prints the title and XID of windows to stdout. 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.3/Makefile0000644000175000017500000000251012436370760013147 0ustar anselmanselm# 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 @mkdir -p ${DESTDIR}${MANPREFIX}/man1 @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 lsw-0.3/config.mk0000644000175000017500000000055212436370760013311 0ustar anselmanselm# lsw version VERSION = 0.3 # 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.3/lsw.c0000644000175000017500000000265512436370760012472 0ustar anselmanselm/* See LICENSE file for copyright and license details. */ #include #include #include #include #include static const char *getname(Window); static void lsw(Window); static Atom netwmname; static Display *dpy; int main(int argc, char *argv[]) { int i; if(!(dpy = XOpenDisplay(NULL))) { fprintf(stderr, "%s: cannot open display\n", argv[0]); exit(EXIT_FAILURE); } netwmname = XInternAtom(dpy, "_NET_WM_NAME", False); if(argc < 2) lsw(DefaultRootWindow(dpy)); else for(i = 1; i < argc; i++) lsw(strtol(argv[i], NULL, 0)); XCloseDisplay(dpy); return EXIT_SUCCESS; } void lsw(Window win) { unsigned int n; Window *wins, *w, dw; XWindowAttributes wa; if(!XQueryTree(dpy, win, &dw, &dw, &wins, &n)) return; for(w = &wins[n-1]; w >= &wins[0]; w--) if(XGetWindowAttributes(dpy, *w, &wa) && !wa.override_redirect && wa.map_state == IsViewable) printf("0x%07lx %s\n", *w, getname(*w)); XFree(wins); } const char * getname(Window win) { static char buf[BUFSIZ]; char **list; int n; XTextProperty prop; if(!XGetTextProperty(dpy, win, &prop, netwmname) || prop.nitems == 0) if(!XGetWMName(dpy, win, &prop) || prop.nitems == 0) return ""; if(!XmbTextPropertyToTextList(dpy, &prop, &list, &n) && n > 0) { strncpy(buf, list[0], sizeof buf); XFreeStringList(list); } else strncpy(buf, (char *)prop.value, sizeof buf); XFree(prop.value); return buf; } lsw-0.3/lsw.10000644000175000017500000000033012436370760012374 0ustar anselmanselm.TH LSW 1 lsw\-VERSION .SH NAME lsw \- list windows .SH SYNOPSIS .B lsw .RI [ window ...] .SH DESCRIPTION .B lsw prints the title and XID of each child of each .IR window . If none are given the root window is used.