how do I remove an Xresource? - Xwindows

This is a discussion on how do I remove an Xresource? - Xwindows ; I can add an X resource by XrmPutStringResource(&rdb,"Foo.Bar.Baz","Zot") but how do I _remove_ this resource? XrmPutStringResource(&rdb,"Foo.Bar.Baz",NULL) segfaults. thanks...

+ Reply to Thread
Results 1 to 10 of 10

Thread: how do I remove an Xresource?

  1. how do I remove an Xresource?

    I can add an X resource by
    XrmPutStringResource(&rdb,"Foo.Bar.Baz","Zot")
    but how do I _remove_ this resource?
    XrmPutStringResource(&rdb,"Foo.Bar.Baz",NULL) segfaults.
    thanks

  2. Re: how do I remove an Xresource?

    Did you try
    XrmPutStringResource(&rdb, "Foo.Bar.Baz", "");
    ?

    Duan Peterc
    http://www.arahne.si

  3. Re: how do I remove an Xresource?

    On Nov 26, 12:52 pm, arahne wrote:
    > Did you try
    > XrmPutStringResource(&rdb, "Foo.Bar.Baz", "");
    > ?


    yes, if I do that, the new value is "".
    i.e., XrmGetResource returns true.

  4. Re: how do I remove an Xresource?

    sds@gnu.org wrote:
    > On Nov 26, 12:52 pm, arahne wrote:
    >> Did you try
    >> XrmPutStringResource(&rdb, "Foo.Bar.Baz", "");
    >> ?

    >
    > yes, if I do that, the new value is "".
    > i.e., XrmGetResource returns true.


    If you need it to return false, you could set it to "False" or "0".
    If you need to remove it from the database, then try
    xrdb -remove ...
    or check the xrdb source to see which functions is it calling.

    Best regards,

    Duan Peterc
    http://www.arahne.si

  5. Re: how do I remove an Xresource?

    On Nov 26, 2:57 pm, arahne wrote:
    > s...@gnu.org wrote:
    > > On Nov 26, 12:52 pm, arahne wrote:
    > >> Did you try
    > >> XrmPutStringResource(&rdb, "Foo.Bar.Baz", "");
    > >> ?

    >
    > > yes, if I do that, the new value is "".
    > > i.e., XrmGetResource returns true.

    >
    > If you need it to return false, you could set it to "False" or "0".


    XrmGetResource will still return true, right?
    the users of the resource will think that the XrmValue contains a
    valid value.

    > If you need to remove it from the database, then try
    > xrdb -remove ...
    > or check the xrdb source to see which functions is it calling.


    "xrdb -remove" removes the whole database, not the individual
    property.
    it calls XDeleteProperty on the root screen.

    thanks for your kind reply.

  6. Re: how do I remove an Xresource?

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    ,--- sds@gnu org writes:

    [...]

    | "xrdb -remove" removes the whole database, not the individual
    | property.
    | it calls XDeleteProperty on the root screen.

    Hmm..., so this means resources are stored in root windows's
    properties. Just figured out that 'xprop -root |grep
    ^RESOURCE_MANAGER' dumps the resources, so looks like you need to
    parse the value of 'RESOURCE_MANAGER' property, remove the desired
    property from the string, and reset the 'RESOURCE_MANAGER'
    property with new string.

    But this'll be an overkill.

    | thanks for your kind reply.

    Thanks for hinting that resources are stored in root window .

    HTH
    - --
    Ashish Shukla आशीष शुक्ल http://wahjava.wordpress.com/
    ·-- ·- ···· ·--- ·- ···- ·- ·--·-· --· -- ·- ·· ·-·· ·-·-·- -·-· --- --
    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.6 (GNU/Linux)

    iD8DBQFHS97WHy+EEHYuXnQRAs+9AKDI2hEkXk78U7B1Hx9SwK ZeBKDCSgCfWlwk
    Drv7ea0WUPJO1GDgE1XtUac=
    =6NA+
    -----END PGP SIGNATURE-----

  7. Re: how do I remove an Xresource?

    On Nov 27, 4:09 am, wahj...@gmail.com (Ashish Shukla आशीष शुक्ल)
    wrote:
    > ,--- sds@gnu org writes:
    > | "xrdb -remove" removes the whole database, not the individual
    > | property.
    > | it calls XDeleteProperty on the root screen.
    >
    > Hmm..., so this means resources are stored in root windows's
    > properties. Just figured out that 'xprop -root |grep
    > ^RESOURCE_MANAGER' dumps the resources, so looks like you need to
    > parse the value of 'RESOURCE_MANAGER' property, remove the desired
    > property from the string, and reset the 'RESOURCE_MANAGER'
    > property with new string.


    actually, there is a more direct way to the string:
    XResourceManagerString().
    note however, that this gives me access to the resource database
    associated with the X server.
    what if I am manipulating an rdb which is not associated with the
    server?

  8. Re: how do I remove an Xresource?

    ,-- sds@gnu.org types:

    [snipped]

    |> Hmm..., so this means resources are stored in root windows's
    |> properties. Just figured out that 'xprop -root |grep
    |> ^RESOURCE_MANAGER' dumps the resources, so looks like you need to
    |> parse the value of 'RESOURCE_MANAGER' property, remove the desired
    |> property from the string, and reset the 'RESOURCE_MANAGER'
    |> property with new string.
    |
    | actually, there is a more direct way to the string:
    | XResourceManagerString().
    | note however, that this gives me access to the resource database
    | associated with the X server.
    | what if I am manipulating an rdb which is not associated with the
    | server?

    You mean manipulating .Xresources file, right ? For that, refer to the
    source code of xrdb.c, which ships with Xorg.

    HTH
    --
    Ashish Shukla आशीष शुक्ल http://wahjava.wordpress.com/
    ·-- ·- ···· ·--- ·- ···- ·- ·--·-· --· -- ·- ·· ·-·· ·-·-·- -·-· --- --

  9. Re: how do I remove an Xresource?

    On Nov 28, 6:54 am, Ashish Shukla wrote:
    > | actually, there is a more direct way to the string:
    > | XResourceManagerString().
    > | note however, that this gives me access to the resource database
    > | associated with the X server.
    > | what if I am manipulating an rdb which is not associated with the
    > | server?
    >
    > You mean manipulating .Xresources file, right ? For that, refer to the
    > source code of xrdb.c, which ships with Xorg.


    no.
    I want to remove a given specific binding from a given database object
    using C code.
    i.e., I do not want to write the rdb to a file, edit it with vi/emacs/
    grep -v, and then load it back.
    I want a function that would revert the effects of
    XrmPutStringResource(&rdb,"Foo.Bar.Baz","Zot")
    i.e., such that after I call it,
    XrmGetResource(rdb,"Foo.Bar.Baz","*.*.*",...)
    would return "false", as it did before the XrmPutStringResource call.

    xrdb.c, IIUC, removes the whole database from the display, not an
    individual entry from a given database.

    Sam.

  10. Re: how do I remove an Xresource?

    "sds@gnu.org" writes:

    > I want to remove a given specific binding from a given database object
    > using C code.


    I don't see any such function in libx11-1.0.0/src/Xrm.c.
    It would have to Xfree the entry, but the Xfree calls in
    the source do not seem suitable.

    What you can do:
    - Change your requirements.
    - Copy the Xrm functions to your own program and augment them as
    needed. Alas, then your resources wouldn't be seen by any
    toolkit libraries that use libX11. You should not rely on the
    internal structures remaining the same across libX11 versions.
    - XrmEnumerateDatabase and copy the other values to a new
    database, then swap it in with XrmSetDatabase.
    - Convince the maintainers of libX11 to add the functions you
    need, then wait perhaps 10 years so most people have installed
    the new versions.

+ Reply to Thread