Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xprop setting multiple fields of atom property

Tags:

linux

x11

xorg

I searched internet and found examples with setting only one field of property:

xprop -id "$windowid" -f _NET_WM_STATE 32a -set _NET_WM_STATE _NET_WM_STATE_ABOVE 

but how can I set multiple fields? I tried:

xprop -id "$windowid" -f _NET_WM_STATE 32a -set _NET_WM_STATE '_NET_WM_STATE_ABOVE, _NET_WM_STATE_SKIP_TASKBAR'

and

xprop -id "$windowid" -f _NET_WM_STATE 32aa -set _NET_WM_STATE _NET_WM_STATE_ABOVE,_NET_WM_STATE_SKIP_TASKBAR

and many other variants with no luck. Is it possible ? :)


Ok....

I wrote a patch for xprop to fix this, and It works, but don't know is it correct.
Thanks to @MichałGórny.
(xprop.c,v 1.6)

--- xprop.c 2012-07-31 11:24:01.178117974 +0400
+++ xprop.mod   2012-07-31 11:23:19.434784430 +0400
@@ -1487,11 +1487,20 @@
    break;
       }
       case 'a': {
-   static Atom avalue;
-   avalue = Parse_Atom(value, False);
-   type = XA_ATOM;
-   data = (unsigned char *) &avalue;
-   nelements = 1;
+   static unsigned long data32[MAXELEMENTS];
+    char * value2 = strdup(value);
+    char * tmp = strtok(value2,",");
+    nelements = 0;
+    while( NULL != tmp ){
+      data32[nelements] = Parse_Atom(tmp, False);
+      nelements +=1;
+      if(nelements >= MAXELEMENTS)
+        break;
+      tmp = strtok(NULL,",");
+    }
+    type = XA_ATOM;
+    data = (unsigned char *) data32;
+    free(value2);
    break;
       }
       case 'm':
like image 306
Bad_ptr Avatar asked Jul 28 '12 11:07

Bad_ptr


1 Answers

Looking at the xprop's code, it's not possible.

case 'a': {
    static Atom avalue;
    avalue = Parse_Atom(value, False);
    type = XA_ATOM;
    data = (unsigned char *) &avalue;
    nelements = 1;
    break;
}

This is the code parsing the value to -set.

static Atom
Parse_Atom (const char *name, int only_if_exists)
{
    /* may return None = 0 */
    return XInternAtom(dpy, name, only_if_exists);
}

So it parses only a single atom.


I've also opened a bug for it; maybe they'll add this.

like image 181
Michał Górny Avatar answered Oct 21 '22 17:10

Michał Górny