i was going through the list of non-pledged process in my list and
found xcape. It's a simple program that allows to turn some keys
(e.g. ctrl) to act as another key (e.g. esc) when pressed and released
by themselves. It's around 500 lines of code and I haven't spotted
anything that won't run under pledge `stdio', except for the first
half of main.
I'm running it as
$ xcape -e 'Control_L=Escape'
(which I just discovered it's the default so I can drop -e entirely)
and is working fine.
% ps aux | grep xcape
op 28882 0.0 0.0 1664 2392 ?? Sp 12:46PM 0:00.51 xcape -e Con
ok?
Index: Makefile
===================================================================
RCS file: /home/cvs/ports/x11/xcape/Makefile,v
retrieving revision 1.3
diff -u -p -r1.3 Makefile
--- Makefile 11 Mar 2022 20:17:43 -0000 1.3
+++ Makefile 13 Aug 2022 10:43:13 -0000
@@ -3,6 +3,7 @@ COMMENT = configure a modifier key when
GH_ACCOUNT = alols
GH_PROJECT = xcape
GH_TAGNAME = v1.2
+REVISION = 0
CATEGORIES = x11
Index: patches/patch-xcape_c
===================================================================
RCS file: patches/patch-xcape_c
diff -N patches/patch-xcape_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-xcape_c 13 Aug 2022 10:42:51 -0000
@@ -0,0 +1,18 @@
+pledge it
+
+Index: xcape.c
+--- xcape.c.orig
++++ xcape.c
+@@ -191,6 +191,12 @@ int main (int argc, char **argv)
+ if (self->debug != True)
+ daemon (0, 0);
+
++ if (pledge ("stdio", NULL) == -1)
++ {
++ fprintf (stderr, "pledge: %s\n", strerror(errno));
++ exit (EXIT_FAILURE);
++ }
++
+ sigemptyset (&self->sigset);
+ sigaddset (&self->sigset, SIGINT);
+ sigaddset (&self->sigset, SIGTERM);