diff options
| author | stkhan <personal@slickd.xyz> | 2022-03-18 08:09:07 -0800 |
|---|---|---|
| committer | stkhan <personal@slickd.xyz> | 2022-03-18 08:09:07 -0800 |
| commit | e20a439f0de08052fad50669fd005dee14d40cae (patch) | |
| tree | 8ffed60a1dce40ae64fd8f336a4d1b5d103683f1 /wmname | |
| parent | a33351c3345f7b8657e6415878a73b5fedb09d72 (diff) | |
Update dwm, added farbfeld, sent, and wmname plus more
Diffstat (limited to 'wmname')
| -rw-r--r-- | wmname/LICENSE | 21 | ||||
| -rw-r--r-- | wmname/Makefile | 51 | ||||
| -rw-r--r-- | wmname/README | 25 | ||||
| -rw-r--r-- | wmname/config.mk | 22 | ||||
| -rw-r--r-- | wmname/wmname.c | 53 |
5 files changed, 172 insertions, 0 deletions
diff --git a/wmname/LICENSE b/wmname/LICENSE new file mode 100644 index 0000000..bf73bff --- /dev/null +++ b/wmname/LICENSE @@ -0,0 +1,21 @@ +MIT/X Consortium License + +© 2008 Anselm R Garbe <garbeam at gmail dot 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 --git a/wmname/Makefile b/wmname/Makefile new file mode 100644 index 0000000..61e7027 --- /dev/null +++ b/wmname/Makefile @@ -0,0 +1,51 @@ +# wmname - prints/sets the WM name + +include config.mk +include ../config.mk + +SRC = wmname.c +OBJ = ${SRC:.c=.o} + +all: options wmname + +options: + @echo wmname build options: + @echo "CFLAGS = ${CFLAGS}" + @echo "LDFLAGS = ${LDFLAGS}" + @echo "CC = ${CC}" + @echo "LD = ${LD}" + +.c.o: + @echo CC $< + @${CC} -c ${CFLAGS} $< + +${OBJ}: config.mk + +wmname: ${OBJ} + @echo LD $@ + @${LD} -o $@ ${OBJ} ${LDFLAGS} + @strip $@ + +clean: + @echo cleaning + @rm -f wmname ${OBJ} wmname-${VERSION}.tar.gz + +dist: clean + @echo creating dist tarball + @mkdir -p wmname-${VERSION} + @cp -R LICENSE Makefile README config.mk ${SRC} wmname-${VERSION} + @tar -cf wmname-${VERSION}.tar wmname-${VERSION} + @gzip wmname-${VERSION}.tar + @rm -rf wmname-${VERSION} + +install: all + @echo installing executable file to ${DESTDIR}${PREFIX}/bin + @mkdir -p ${DESTDIR}${PREFIX}/bin + @cp -f wmname ${DESTDIR}${PREFIX}/bin + @chmod 755 ${DESTDIR}${PREFIX}/bin/wmname + +uninstall: + @echo removing executable file from ${DESTDIR}${PREFIX}/bin + @rm -f ${DESTDIR}${PREFIX}/bin/wmname + +.PHONY: all options clean dist install uninstall diff --git a/wmname/README b/wmname/README new file mode 100644 index 0000000..a7d4b2c --- /dev/null +++ b/wmname/README @@ -0,0 +1,25 @@ +wmname - prints/sets the WM name +================================ +Prints/sets the EWMH WM name property. + + +Requirements +------------ +In order to build wmname you need the Xlib header files. + + +Installation +------------ +Edit config.mk to match your local setup (wmname is installed into +the /usr/local namespace by default). + +Afterwards enter the following command to build and install wmname +(if necessary as root): + + make clean install + + +Running wmname +-------------- +Run 'wmname' to print the current WM name. Run 'wmname <name>' to set it. This +is pretty much similiar to hostname(1). diff --git a/wmname/config.mk b/wmname/config.mk new file mode 100644 index 0000000..3291924 --- /dev/null +++ b/wmname/config.mk @@ -0,0 +1,22 @@ +# wmname version +VERSION = 0.1 + +# Customize below to fit your system + +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 +LD = ${CC} diff --git a/wmname/wmname.c b/wmname/wmname.c new file mode 100644 index 0000000..7d846f3 --- /dev/null +++ b/wmname/wmname.c @@ -0,0 +1,53 @@ +/* See LICENSE file for details. */ +#include <stdarg.h> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <X11/Xlib.h> +#include <X11/Xatom.h> +#include <X11/Xutil.h> + +void +eprint(const char *errstr, ...) { + va_list ap; + + va_start(ap, errstr); + vfprintf(stderr, errstr, ap); + va_end(ap); + exit(EXIT_FAILURE); +} + +int +main(int argc, char **argv) { + int status, format; + unsigned char *data = NULL; + unsigned long n, extra; + Display *dpy; + Window root; + Atom netwmcheck, netwmname, utf8_string, real; + + if(argc > 2) + eprint("usage: wmname [name] [-v]\n"); + else if(argc == 2 && !strncmp(argv[1], "-v", 3)) + eprint("wmname-"VERSION", © 2008 Anselm R Garbe\n", stdout); + + if(!(dpy = XOpenDisplay(0))) + eprint("wmname: cannot open display\n"); + root = DefaultRootWindow(dpy); + netwmcheck = XInternAtom(dpy, "_NET_SUPPORTING_WM_CHECK", False); + netwmname = XInternAtom(dpy, "_NET_WM_NAME", False); + utf8_string = XInternAtom(dpy, "UTF8_STRING", False); + if(argc == 1) { + status = XGetWindowProperty(dpy, root, netwmname, 0L, 32L, False, utf8_string, &real, &format, &n, &extra, (unsigned char **) &data); + if(status == Success && data != NULL) + fprintf(stdout, "%s\n", data); + XFree(data); + } + else { + XChangeProperty(dpy, root, netwmcheck, XA_WINDOW, 32, PropModeReplace, (unsigned char *)&root, 1); + XChangeProperty(dpy, root, netwmname, utf8_string, 8, PropModeReplace, (unsigned char *)argv[1], strlen(argv[1])); + } + XSync(dpy, False); + XCloseDisplay(dpy); + return 0; +} |