[dev] [dwm] X11/XF86keysym.h is not available
Hello.
..and isn't that mysterious, do you all live without any
accessibility to these media keys in dwm? I have written
XF86 media key spawn hook..
This will invoke xf86cmd with the name of the key, for example
XF86AudioMute, as an argument, for any key that adheres to
* XFree86 vendor specific keysyms.
*
* The XFree86 keysym range is 0x10080001 - 0x1008ffff.
*
* The XF86 set of keysyms is a catch-all set of defines for keysyms found
* on various multimedia keyboards.
To work this needs
static const char *xf86cmd = "adjust-xf86-mediahooks.sh";
^(or any other command, say)
and within the
static const Key keys[] = {
an entry like the following with a -1 KeySym:
{0,(KeySym)-1,NULL,{0}},
The patch is as below. It is a bit of a pity as i would break and
return and thus optimize all these loops, but i guess that would
not just make any friends at all.
Btw i am totally surprised how often the keys are completely
reinitialized, i have almost done zero, and never a WM, but that
seems insane. Puh.
Btw execwm now only is
fun: execwm()
---
dwm.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/dwm.c b/dwm.c
index 67c6b2bc6d..5ce3f3c0fa 100644
--- a/dwm.c
+++ b/dwm.c
_AT_@ -206,6 +206,7 @@ static void setup(void);
static void seturgent(Client *c, int urg);
static void showhide(Client *c);
static void spawn(const Arg *arg);
+static void execwm(const Arg *arg);
static void tag(const Arg *arg);
static void tagmon(const Arg *arg);
static void tile(Monitor *m);
_AT_@ -1666,6 +1667,14 @@ spawn(const Arg *arg)
}
}
+void
+execwm(const Arg *arg)
+{
+ setsid();
+ execvp(((char **)arg->v)[0], (char **)arg->v);
+ die("dwm: execvp WM '%s' failed:", ((char **)arg->v)[0]);
+}
+
void
tag(const Arg *arg)
{
Here is the key diff, maybe someone has an idea or likes it:
XF86 media key spawn hook..
This will invoke xf86cmd with the name of the key, for example
XF86AudioMute, as an argument, for any key that adheres to
* XFree86 vendor specific keysyms.
*
* The XFree86 keysym range is 0x10080001 - 0x1008ffff.
*
* The XF86 set of keysyms is a catch-all set of defines for keysyms found
* on various multimedia keyboards.
To work this needs
static const char *xf86cmd = "adjust-xf86-mediahooks.sh";
and within the
static const Key keys[] = {
an entry like the following with a -1 KeySym:
{0,(KeySym)-1,NULL,{0}},
---
dwm.c | 34 ++++++++++++++++++++++++++++++----
1 file changed, 30 insertions(+), 4 deletions(-)
diff --git a/dwm.c b/dwm.c
index 5ce3f3c0fa..e5572db09a 100644
--- a/dwm.c
+++ b/dwm.c
_AT_@ -269,6 +269,10 @@ static Drw *drw;
static Monitor *mons, *selmon;
static Window root, wmcheckwin;
+/* X11/XF86keysym.h: The XFree86 keysym range is 0x10080001 - 0x1008ffff */
+static Key const *xf86_key;
+#define a_XF86_IS_SYM(X) ((X) >= 0x10080001ul && (X) <= 0x1008fffful)
+
/* configuration, allows nested code to access above variables */
#include "config.h"
_AT_@ -954,26 +958,35 @@ void
grabkeys(void)
{
updatenumlockmask();
+ xf86_key = NULL;
{
unsigned int i, j, k;
unsigned int modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask };
int start, end, skip;
- KeySym *syms;
+ KeySym *syms, ks;
XUngrabKey(dpy, AnyKey, AnyModifier, root);
XDisplayKeycodes(dpy, &start, &end);
syms = XGetKeyboardMapping(dpy, start, end - start + 1, &skip);
if (!syms)
return;
- for (k = start; k <= end; k++)
- for (i = 0; i < LENGTH(keys); i++)
+ for (k = start; k <= end; k++) {
+ ks = syms[(k - start) * skip];
+
+ for (i = 0; i < LENGTH(keys); i++) {
/* skip modifier codes, we do that ourselves */
- if (keys[i].keysym == syms[(k - start) * skip])
+ if (keys[i].keysym == ks)
for (j = 0; j < LENGTH(modifiers); j++)
XGrabKey(dpy, k,
keys[i].mod | modifiers[j],
root, True,
GrabModeAsync, GrabModeAsync);
+ if (keys[i].keysym == (KeySym)-1 && a_XF86_IS_SYM(ks)) {
+ xf86_key = &keys[i];
+ XGrabKey(dpy, k, 0, root, True, GrabModeAsync, GrabModeAsync);
+ }
+ }
+ }
XFree(syms);
}
}
_AT_@ -1011,6 +1024,19 @@ keypress(XEvent *e)
&& CLEANMASK(keys[i].mod) == CLEANMASK(ev->state)
&& keys[i].func)
keys[i].func(&(keys[i].arg));
+
+ if (xf86_key && a_XF86_IS_SYM(keysym) && xf86cmd){
+ char const *kss, *argv[3];
+ Arg a;
+
+ if ((kss = XKeysymToString(keysym))) {
+ argv[0] = xf86cmd;
+ argv[1] = kss;
+ argv[2] = NULL;
+ a.v = argv;
+ spawn(&a);
+ }
+ }
}
void
Ciao!
--steffen
|
|Der Kragenbaer, The moon bear,
|der holt sich munter he cheerfully and one by one
|einen nach dem anderen runter wa.ks himself off
|(By Robert Gernhardt)
Received on Thu Sep 12 2024 - 02:10:39 CEST
This archive was generated by hypermail 2.3.0
: Thu Sep 12 2024 - 02:12:09 CEST