summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Makefile4
-rwxr-xr-xpresenterctl.sh24
-rw-r--r--repeat-xi2.c40
4 files changed, 69 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..06cbdff
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+repeat-xi2
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..2dc2717
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,4 @@
+all: repeat-xi2
+
+%: %.c
+ gcc -ggdb -Wall $(shell pkg-config --libs --cflags x11) $< -o $@
diff --git a/presenterctl.sh b/presenterctl.sh
new file mode 100755
index 0000000..3e3e750
--- /dev/null
+++ b/presenterctl.sh
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+[[ "x$1" = "xremove" ]] && exec sh -c 'xinput remove-master "remote pointer"'
+
+xinput remove-master "remote pointer" &> /dev/null
+xinput create-master remote
+$(dirname $0 )/repeat-xi2 `xinput --list --id-only "remote keyboard"` 500 8
+
+for id in `xinput --list --id-only | sed "s/[^0-9]*//g"`
+do
+ name=`xinput --list-props "$id" | sed -n "1s/.*'\([^']*\)'.*/\\1/p"`
+ [[ "x$name" != "xLogitech USB Receiver" ]] && continue;
+
+ xinput reattach "$id" "remote pointer"
+done
+
+echo -n "Attach 'TPPS/2 IBM TrackPoint' to 'remote pointer'? (Y/n): "
+read attach
+[[ "x$attach" = "xn" ]] && exit
+
+xinput reattach "TPPS/2 IBM TrackPoint" "remote pointer"
+echo -n "Type enter to attach back to core pointer."
+read
+xinput reattach "TPPS/2 IBM TrackPoint" "Virtual core pointer"
diff --git a/repeat-xi2.c b/repeat-xi2.c
new file mode 100644
index 0000000..47c69b1
--- /dev/null
+++ b/repeat-xi2.c
@@ -0,0 +1,40 @@
+#include <stdlib.h>
+#include <X11/X.h>
+#include <X11/XKBlib.h>
+
+int
+main(int argc, char *argv[])
+{
+ Display *dpy;
+ XkbDescPtr xkb;
+ unsigned int id, delay, interval;
+
+ if (argc < 4)
+ exit(1);
+
+ id = atoi(argv[1]);
+ delay = atoi(argv[2]);
+ interval = atoi(argv[3]);
+
+ dpy = XOpenDisplay(NULL);
+ if (!dpy)
+ exit(2);
+
+ xkb = XkbGetKeyboard(dpy, XkbControlsMask, id);
+ if (!xkb)
+ exit(3);
+
+ /* With X.Org-Server 1.13.1 on Gentoo ctrls is unexpectedly NULL. */
+ if (!xkb->ctrls)
+ XkbGetControls(dpy, XkbRepeatKeysMask, xkb);
+
+ xkb->ctrls->repeat_delay = delay;
+ xkb->ctrls->repeat_interval = 1000 / interval;
+
+ XkbSetControls(dpy, XkbRepeatKeysMask, xkb);
+ XkbFreeKeyboard(xkb, 0, True);
+
+ XCloseDisplay(dpy);
+
+ return 0;
+}