changeset: 1:4c01c9bb7aab
tag: tip
user: Connor Lane Smith <cls_AT_lubutu.com>
date: Wed Apr 07 12:33:13 2010 +0000
files: LICENSE Makefile README config.mk sprop.1 sprop.c
description:
Added docs, makefile, and bugfix.
diff -r 6ab2029e3f8b -r 4c01c9bb7aab LICENSE
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/LICENSE Wed Apr 07 12:33:13 2010 +0000
@@ -0,0 +1,21 @@
+MIT/X Consortium License
+
+© 2010 Connor Lane Smith <cls_AT_lubutu.com>
+
+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.
diff -r 6ab2029e3f8b -r 4c01c9bb7aab Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Makefile Wed Apr 07 12:33:13 2010 +0000
@@ -0,0 +1,54 @@
+# sprop - simple X property utility
+
+include config.mk
+
+SRC = sprop.c
+OBJ = ${SRC:.c=.o}
+
+all: options sprop
+
+options:
+ @echo sprop build options:
+ @echo "CFLAGS = ${CFLAGS}"
+ @echo "LDFLAGS = ${LDFLAGS}"
+ @echo "CC = ${CC}"
+
+.c.o:
+ @echo CC $<
+ @${CC} -c ${CFLAGS} $<
+
+${OBJ}: config.mk
+
+sprop: ${OBJ}
+ @echo CC -o $@
+ @${CC} -o $@ ${OBJ} ${LDFLAGS}
+
+clean:
+ @echo cleaning
+ @rm -f sprop ${OBJ} sprop-${VERSION}.tar.gz
+
+dist: clean
+ @echo creating dist tarball
+ @mkdir -p sprop-${VERSION}
+ @cp -R LICENSE Makefile README config.mk sprop.1 ${SRC} sprop-${VERSION}
+ @tar -cf sprop-${VERSION}.tar sprop-${VERSION}
+ @gzip sprop-${VERSION}.tar
+ @rm -rf sprop-${VERSION}
+
+install: all
+ @echo installing executable file to ${DESTDIR}${PREFIX}/bin
+ @mkdir -p ${DESTDIR}${PREFIX}/bin
+ @cp -f sprop ${DESTDIR}${PREFIX}/bin
+ @chmod 755 ${DESTDIR}${PREFIX}/bin/sprop
+ @echo installing manual page to ${DESTDIR}${MANPREFIX}/man1
+ @mkdir -p ${DESTDIR}${MANPREFIX}/man1
+ @sed "s/VERSION/${VERSION}/g" < sprop.1 > ${DESTDIR}${MANPREFIX}/man1/sprop.1
+ @chmod 644 ${DESTDIR}${MANPREFIX}/man1/sprop.1
+
+uninstall:
+ @echo removing executable file from ${DESTDIR}${PREFIX}/bin
+ @rm -f ${DESTDIR}${PREFIX}/bin/sprop
+ @echo removing manual page from ${DESTDIR}${MANPREFIX}/man1
+ @rm -f ${DESTDIR}${MANPREFIX}/man1/sprop.1
+
+.PHONY: all options clean dist install uninstall
diff -r 6ab2029e3f8b -r 4c01c9bb7aab README
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/README Wed Apr 07 12:33:13 2010 +0000
@@ -0,0 +1,24 @@
+sprop - simple X property utility
+=================================
+Prints/sets window properties in an X server.
+
+
+Requirements
+------------
+In order to build sprop you need the Xlib header files.
+
+
+Installation
+------------
+Edit config.mk to match your local setup (sprop is installed into
+the /usr/local namespace by default).
+
+Afterwards enter the following command to build and install sprop
+(if necessary as root):
+
+ make clean install
+
+
+Running sprop
+--------------
+See the man page for details.
diff -r 6ab2029e3f8b -r 4c01c9bb7aab config.mk
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/config.mk Wed Apr 07 12:33:13 2010 +0000
@@ -0,0 +1,23 @@
+# sprop version
+VERSION = 0.1
+
+# Customize below to fit your system
+
+# paths
+PREFIX = /usr/local
+MANPREFIX = ${PREFIX}/share/man
+
+X11INC = /usr/X11R6/include
+X11LIB = /usr/X11R6/lib
+
+# includes and libs
+INCS = -I. -I/usr/include -I${X11INC}
+LIBS = -L/usr/lib -lc -L${X11LIB} -lX11
+
+# flags
+CPPFLAGS = -DVERSION=\"${VERSION}\"
+CFLAGS = -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS}
+LDFLAGS = -s ${LIBS}
+
+# compiler and linker
+CC = cc
diff -r 6ab2029e3f8b -r 4c01c9bb7aab sprop.1
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sprop.1 Wed Apr 07 12:33:13 2010 +0000
@@ -0,0 +1,23 @@
+.TH SPROP 1 sprop\-VERSION
+.SH NAME
+sprop \- simple X property utility
+.SH SYNOPSIS
+.B sprop
+.I xid atom
+.RI [ value ]
+[-v]
+.SH DESCRIPTION
+.SS Overview
+The
+.I sprop
+utility prints the value of the property
+.I atom
+of the window with the given
+.IR xid ,
+or alternatively sets it to
+.I value
+if given. sprop can only interact with atoms which are strings.
+.SS Options
+.TP
+.B \-v
+prints version information to standard output, then exits.
diff -r 6ab2029e3f8b -r 4c01c9bb7aab sprop.c
--- a/sprop.c Wed Apr 07 10:02:16 2010 +0000
+++ b/sprop.c Wed Apr 07 12:33:13 2010 +0000
@@ -1,4 +1,5 @@
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <X11/Xlib.h>
#include <X11/Xatom.h>
@@ -21,20 +22,25 @@
case 4:
value = argv[3];
case 3:
- if((atom = XInternAtom(dpy, argv[2], True)) == None) {
- fprintf(stderr, "sprop: no such atom\n");
- return 1;
- }
+ atom = XInternAtom(dpy, argv[2], True);
win = atoi(argv[1]);
break;
+ case 2:
+ if(!strcmp(argv[1], "-v")) {
+ printf("sprop-"VERSION", © 2010 Connor Lane Smith\n");
+ return 0;
+ }
default:
- fprintf(stderr, "usage: sprop <xid> <atom> [<value>]\n");
+ fprintf(stderr, "usage: sprop <xid> <atom> [<value>] [-v]\n");
return 1;
}
if(value)
setatom(atom, value);
else {
- value = getatom(atom);
+ if(!(value = getatom(atom))) {
+ fprintf(stderr, "sprop: cannot get atom\n");
+ return 1;
+ }
printf("%s\n", value);
XFree(value);
}
@@ -52,7 +58,7 @@
XGetWindowProperty(dpy, win, atom, 0, BUFSIZ, False, XA_STRING,
&adummy, &idummy, &ldummy, &ldummy, &p);
- return p;
+ return (char *)p;
}
void
Received on Wed Apr 07 2010 - 11:35:54 UTC
This archive was generated by hypermail 2.2.0 : Wed Apr 07 2010 - 11:48:07 UTC