Initial repo, move from hg to git - seturgent - set urgency hints for X applica… | |
git clone git://git.codemadness.org/seturgent | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 2bba1d32cb4d232cc4aa454ee69fb20b6b0f67e3 | |
Author: Hiltjo Posthuma <[email protected]> | |
Date: Fri, 17 Aug 2012 20:40:01 +0200 | |
Initial repo, move from hg to git | |
Signed-off-by: Hiltjo Posthuma <[email protected]> | |
Diffstat: | |
A LICENSE | 21 +++++++++++++++++++++ | |
A Makefile | 56 +++++++++++++++++++++++++++++… | |
A config.mk | 30 ++++++++++++++++++++++++++++++ | |
A seturgent.1 | 21 +++++++++++++++++++++ | |
A seturgent.c | 48 +++++++++++++++++++++++++++++… | |
5 files changed, 176 insertions(+), 0 deletions(-) | |
--- | |
diff --git a/LICENSE b/LICENSE | |
@@ -0,0 +1,21 @@ | |
+MIT/X Consortium License | |
+ | |
+© 2010-2012 Hiltjo Posthuma <[email protected]> | |
+ | |
+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/Makefile b/Makefile | |
@@ -0,0 +1,56 @@ | |
+# seturgent - set an applications urgency hint (or not) | |
+# See LICENSE file for copyright and license details. | |
+ | |
+include config.mk | |
+ | |
+SRC = seturgent.c | |
+OBJ = ${SRC:.c=.o} | |
+ | |
+all: options seturgent | |
+ | |
+options: | |
+ @echo seturgent build options: | |
+ @echo "CFLAGS = ${CFLAGS}" | |
+ @echo "LDFLAGS = ${LDFLAGS}" | |
+ @echo "CC = ${CC}" | |
+ | |
+.c.o: | |
+ @echo CC $< | |
+ @${CC} -c ${CFLAGS} $< | |
+ | |
+${OBJ}: config.mk | |
+ | |
+seturgent: ${OBJ} | |
+ @echo CC -o $@ | |
+ @${CC} -o $@ ${OBJ} ${LDFLAGS} | |
+ | |
+clean: | |
+ @echo cleaning | |
+ @rm -f seturgent ${OBJ} seturgent-${VERSION}.tar.gz | |
+ | |
+dist: clean | |
+ @echo creating dist tarball | |
+ @mkdir -p seturgent-${VERSION} | |
+ @cp -R LICENSE Makefile config.mk \ | |
+ seturgent.1 ${SRC} seturgent-${VERSION} | |
+ @tar -cf seturgent-${VERSION}.tar seturgent-${VERSION} | |
+ @gzip seturgent-${VERSION}.tar | |
+ @rm -rf seturgent-${VERSION} | |
+ | |
+install: all | |
+ @echo installing executable file to ${DESTDIR}${PREFIX}/bin | |
+ @mkdir -p ${DESTDIR}${PREFIX}/bin | |
+ @cp -f seturgent ${DESTDIR}${PREFIX}/bin | |
+ @chmod 755 ${DESTDIR}${PREFIX}/bin/seturgent | |
+ @echo installing manual page to ${DESTDIR}${MANPREFIX}/man1 | |
+ @mkdir -p ${DESTDIR}${MANPREFIX}/man1 | |
+ @sed "s/VERSION/${VERSION}/g" < seturgent.1 > ${DESTDIR}${MANPREFIX}/m… | |
+ @chmod 644 ${DESTDIR}${MANPREFIX}/man1/seturgent.1 | |
+ | |
+uninstall: | |
+ @echo removing executable file from ${DESTDIR}${PREFIX}/bin | |
+ @rm -f ${DESTDIR}${PREFIX}/bin/seturgent | |
+ @echo removing manual page from ${DESTDIR}${MANPREFIX}/man1 | |
+ @rm -f ${DESTDIR}${MANPREFIX}/man1/seturgent.1 | |
+ | |
+.PHONY: all options clean dist install uninstall | |
diff --git a/config.mk b/config.mk | |
@@ -0,0 +1,30 @@ | |
+# seturgent version | |
+VERSION = 1.4 | |
+ | |
+# Customize below to fit your system | |
+ | |
+# paths | |
+PREFIX = /usr/local | |
+MANPREFIX = ${PREFIX}/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 -Wextra -Os ${INCS} ${CPPFLAGS} | |
+LDFLAGS = -s ${LIBS} | |
+# debug flags | |
+#CFLAGS = -std=c99 -pedantic -g -Wall -Wextra -O0 ${INCS} ${CPPFLAGS} | |
+#LDFLAGS = ${LIBS} | |
+ | |
+# Solaris | |
+#CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\" | |
+#LDFLAGS = ${LIBS} | |
+ | |
+# compiler and linker | |
+CC = cc | |
diff --git a/seturgent.1 b/seturgent.1 | |
@@ -0,0 +1,21 @@ | |
+.TH SETURGENT 1 seturgent\-VERSION | |
+.SH NAME | |
+seturgent \- set an applications urgency hint (or not) | |
+.SH SYNOPSIS | |
+.B seturgent | |
+.RB <winid> | |
+.RB [0|1] | |
+.SH OPTIONS | |
+.TP | |
+.B <winid> | |
+the window id (decimal or hexadecimal). | |
+.TP | |
+.B [0|1] | |
+0 to unset, 1 to set, if not specified 1 is the default. | |
+.SH DESCRIPTION | |
+seturgent can set or unset an applications urgency hint | |
+.SH SEE ALSO | |
+.BR xprop(1) | |
+.BR xwininfo(1) | |
+.SH BUGS | |
+Please report them! | |
diff --git a/seturgent.c b/seturgent.c | |
@@ -0,0 +1,48 @@ | |
+/* See LICENSE file for copyright and license details. */ | |
+ | |
+#include <stdio.h> | |
+#include <string.h> | |
+#include <stdlib.h> | |
+#include <X11/Xlib.h> | |
+#include <X11/Xutil.h> | |
+ | |
+static void | |
+die(const char *s) { | |
+ fputs(s, stderr); | |
+ exit(EXIT_FAILURE); | |
+} | |
+ | |
+static void | |
+seturgency(Display *dpy, Window winid, Bool set) { | |
+ XWMHints *hints = XGetWMHints(dpy, winid); | |
+ if(!hints) { | |
+ fputs("seturgent: unable to get window manager hints.\n", stde… | |
+ return; | |
+ } | |
+ if(set) | |
+ hints->flags |= XUrgencyHint; | |
+ else | |
+ hints->flags &= ~XUrgencyHint; | |
+ if(!XSetWMHints(dpy, winid, hints)) | |
+ fputs("seturgent: unable to set urgency hint.\n", stderr); | |
+ XFree(hints); | |
+} | |
+ | |
+int | |
+main(int argc, char **argv) { | |
+ Display *dpy; | |
+ | |
+ if(argc < 2 || !strcmp(argv[1], "-h")) /* help / usage */ | |
+ die("Usage: seturgent <winid> [0|1]\n"); | |
+ if(argc == 2 && !strcmp(argv[1], "-v")) /* version */ | |
+ die("seturgent-"VERSION" © 2010-2012 seturgent engineer, see … | |
+ "LICENSE file for details.\n"); | |
+ if(!(dpy = XOpenDisplay(NULL))) | |
+ die("seturgent: unable to open display.\n"); | |
+ /* set the urgency hint (or not), if not specified its True. */ | |
+ seturgency(dpy, (Window)strtol(argv[1], NULL, 0), | |
+ !((argc > 2) && !atol(argv[2]))); | |
+ XSync(dpy, False); | |
+ XCloseDisplay(dpy); | |
+ return EXIT_SUCCESS; | |
+} |