summaryrefslogtreecommitdiff
path: root/transSet.c
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2003-11-24 17:12:27 +0000
committerKeith Packard <keithp@keithp.com>2003-11-24 17:12:27 +0000
commit59e751294611cb043252e6b8180601ac71b17bcf (patch)
treeb0f3c9831d78fc5d7e55ec3425b2397e63524d1d /transSet.c
Initial revision
Diffstat (limited to 'transSet.c')
-rw-r--r--transSet.c74
1 files changed, 74 insertions, 0 deletions
diff --git a/transSet.c b/transSet.c
new file mode 100644
index 0000000..3418c69
--- /dev/null
+++ b/transSet.c
@@ -0,0 +1,74 @@
+/* Simple program to toggle Translucency property on next window clicked
+ Uses dsimple.h and dsimple.c from xlsfonts.
+ Based on xprops and xwininfo
+
+ By Matthew Hawn
+ Use however you want. I can't stop you.
+*/
+
+
+
+#include <stdio.h>
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+#include "dsimple.h"
+
+
+Window target_win;
+
+/* needed by dsimple.c */
+
+void usage()
+{
+ fprintf(stderr, "Bad arguments\n");
+}
+
+
+/* nothing fancy */
+int main(int argc, char **argv)
+{
+
+ /* wonderful utility */
+ Setup_Display_And_Screen(&argc, argv);
+
+ /* grab mouse and return window that is next clicked */
+ target_win = Select_Window(dpy);
+
+ int val = 15;
+
+ unsigned char *data;
+
+ Atom actual;
+ int format;
+ unsigned long n, left;
+
+ /* get property */
+ XGetWindowProperty(dpy, target_win, XInternAtom(dpy, "CM_TRANSLUCENCY", False),
+ 0L, 1L, False, XA_INTEGER, &actual, &format, &n, &left,
+ (unsigned char **) &data);
+
+ if (data != None)
+ {
+
+ printf("Found property: %d\n", (int) *data );
+
+ /* toggle */
+ if ((int) *data > 0)
+ val = 0;
+
+ XFree(( void *) data );
+
+ }
+
+
+ /* set it */
+ XChangeProperty(dpy, target_win, XInternAtom(dpy, "CM_TRANSLUCENCY", False),
+ XA_INTEGER, 32, PropModeReplace,
+ (unsigned char *) &val, 1L);
+ XSync(dpy, False);
+ printf("Set Property to %d\n", val);
+
+
+ /* all done, wasn't that simple */
+ return 0;
+}