lsw

lists window titles of X clients to stdout
git clone git://git.suckless.org/lsw
Log | Files | Refs | README | LICENSE

commit 4efebb8fc4bac764538151abdc6b56a3068e477a
parent 0bcbd0cd548b2ab4246c4b7652cc6b72ce998272
Author: Connor Lane Smith <cls@lubutu.com>
Date:   Sat, 18 Jun 2011 04:30:21 +0100

flagless
Diffstat:
config.mk | 2+-
lsw.1 | 14+++-----------
lsw.c | 24+++++-------------------
3 files changed, 9 insertions(+), 31 deletions(-)

diff --git a/config.mk b/config.mk @@ -1,5 +1,5 @@ # lsw version -VERSION = 0.2 +VERSION = 0.3 # paths PREFIX = /usr/local diff --git a/lsw.1 b/lsw.1 @@ -3,17 +3,9 @@ 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. +prints the title and XID of each child of each +.IR window . +If none are given the root window is used. diff --git a/lsw.c b/lsw.c @@ -10,7 +10,6 @@ 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 @@ -23,20 +22,10 @@ main(int argc, char *argv[]) { } 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) + if(argc < 2) lsw(DefaultRootWindow(dpy)); - else while(i < argc) - lsw(strtol(argv[i++], NULL, 0)); + else for(i = 1; i < argc; i++) + lsw(strtol(argv[i], NULL, 0)); XCloseDisplay(dpy); return EXIT_SUCCESS; @@ -55,17 +44,14 @@ lsw(Window win) { if(XGetWindowAttributes(dpy, wins[i], &wa) && !wa.override_redirect && wa.map_state == IsViewable) { getname(wins[i], buf, sizeof buf); - if(lflag) - printf("0x%07lx %s\n", wins[i], buf); - else if(*buf) - puts(buf); + printf("0x%07lx %s\n", wins[i], buf); } XFree(wins); } void getname(Window win, char *buf, size_t size) { - char **list = NULL; + char **list; int n; XTextProperty prop;