XrmUniqueQuark(3)
π XrmUniqueQuark β quarks, but make it a group chat
okay bestie so this is a page from the XLIB FUNCTIONS manual, and it's literally all about resource quarks β those tiny little integer-ish handles X uses to describe names, classes and representations. It's from the libX11 1.8.14 days of X Version 11, and ngl it's extremely useful, you just have to read it in the right voice. Here, I'll read it for you π«Ά
β¨ NAME β¨
XrmUniqueQuark, XrmStringToQuark, XrmPermStringToQuark, XrmQuarkToString, XrmStringToQuarkList, XrmStringToBindingQuarkList β these are the functions that manipulate resource quarks. That's the whole vibe of this page π
πΈ SYNOPSIS πΈ
First things first, you gotta pull in the header:
#include <X11/Xresource.h>
Then here's the one that makes a brand new one:
XrmQuark XrmUniqueQuark(void);
Then the stringβquark glow-ups, and yes these macros are allll just aliases of the same function, iconique:
#define XrmStringToName(string) XrmStringToQuark(string)
#define XrmStringToClass(string) XrmStringToQuark(string)
#define XrmStringToRepresentation(string) XrmStringToQuark(string)
XrmQuark XrmStringToQuark(char *string);
XrmQuark XrmPermStringToQuark(_Xconst char *string);
π okay don't panic β the manpage literally repeats that exact block one more time, right here. I'm not messing with you, that's genuinely what's in the source. Copy-paste era, no cap. Here it is again because β¨fidelityβ¨:
#define XrmStringToName(string) XrmStringToQuark(string)
#define XrmStringToClass(string) XrmStringToQuark(string)
#define XrmStringToRepresentation(string) XrmStringToQuark(string)
XrmQuark XrmStringToQuark(char *string);
XrmQuark XrmPermStringToQuark(_Xconst char *string);
Then quarkβstring, the reverse slay:
#define XrmNameToString(name) XrmQuarkToString(name)
#define XrmClassToString(class) XrmQuarkToString(class)
#define XrmRepresentationToString(type) XrmQuarkToString(type)
char *XrmQuarkToString(XrmQuark quark);
Then the list-y ones, note how these macros wrap across lines in the original, I'm keeping it exactly as printed (yes, including that XrmStringToClassList(str,class) with no space β character for character, bestie π):
#define XrmStringToNameList(str, name) XrmStringToQuarkList((str),
(name))
#define XrmStringToClassList(str,class) XrmStringToQuarkList((str),
(class))
void XrmStringToQuarkList(char *string, XrmQuarkList quarks_return);
void XrmStringToBindingQuarkList(_Xconst char *string, XrmBindingList
bindings_return, XrmQuarkList quarks_return);
π ARGUMENTS π
bindings_returnβ you hand this over and it comes back holding the binding list π«Άquarkβ the quark you're like "hey what's the string for this one" aboutquarks_returnβ comes back holding the list of quarksstringβ the string you want a quark (or a whole quark list) allocated for β¨
π DESCRIPTION π
π¦ the unique one π¦
XrmUniqueQuark allocates a quark that is guaranteed not to represent any string that is known to the resource manager. That's it, that's the whole function. It's giving "I'm special and nobody knows me" main character energy π
π¦ string β quark π¦
These functions can be used to convert from string to quark representation. Now, important caveat time: if the string is not in the Host Portable Character Encoding, the conversion is implementation-dependent β so like, don't come for it if that happens, it's not defined behaviour, it's vibes π«
The string argument to XrmStringToQuark need not be permanently allocated storage. XrmPermStringToQuark is just like XrmStringToQuark, except that Xlib is permitted to assume the string argument is permanently allocated, and, hence, that it can be used as the value to be returned by XrmQuarkToString. So like, that's the trade: you promise it lives forever, it can hand that same pointer back to you π₯
For any given quark, if XrmStringToQuark returns a non-NULL value, all future calls will return the same value (identical address). Consistency queen π
π and yeah β that whole stringβquark paragraph is repeated verbatim in the original, twice total. So here it is again, faithfully, because I refuse to skip things:
These functions can be used to convert from string to quark representation. If the string is not in the Host Portable Character Encoding, the conversion is implementation-dependent. The string argument to XrmStringToQuark need not be permanently allocated storage. XrmPermStringToQuark is just like XrmStringToQuark, except that Xlib is permitted to assume the string argument is permanently allocated, and, hence, that it can be used as the value to be returned by XrmQuarkToString.
For any given quark, if XrmStringToQuark returns a non-NULL value, all future calls will return the same value (identical address).
π¦ quark β string π¦
These functions can be used to convert from quark representation to string. The string pointed to by the return value must not be modified or freed. Read that again bestie. Do not touch it. Do not free it. Hands off π«
The returned string is byte-for-byte equal to the original string passed to one of the string-to-quark routines. If no string exists for that quark, XrmQuarkToString returns NULL. And for any given quark, if XrmQuarkToString returns a non-NULL value, all future calls will return the same value (identical address) β same energy as before, it's consistent like that π
π¦ the quark list one π¦
XrmStringToQuarkList converts the null-terminated string (generally a fully qualified name) to a list of quarks. The caller must allocate sufficient space for the quarks list before calling XrmStringToQuarkList. Not me forgetting to allocate, couldn't be me π
Note that the string must be in the valid ResourceName format (see section 15.1). And if the string is not in the Host Portable Character Encoding, the conversion is implementation-dependent. Again. Same caveat. It's everywhere.
π¦ bindings, explained π¦
A binding list is a list of type XrmBindingList and indicates if components of name or class lists are bound tightly or loosely (that is, if wildcarding of intermediate components is specified).
typedef enum {XrmBindTightly, XrmBindLoosely} XrmBinding, *XrmBindingList;
XrmBindTightly indicates that a period separates the components, and XrmBindLoosely indicates that an asterisk separates the components. Period = tight. Asterisk = loose. Got it? Got it π
π¦ the binding quark list one π¦
XrmStringToBindingQuarkList converts the specified string to a binding list and a quark list. The caller must allocate sufficient space for the quarks list and the binding list before calling XrmStringToBindingQuarkList β both of them, don't be out here allocating one and calling it a day π
If the string is not in the Host Portable Character Encoding the conversion is implementation-dependent. (sir this is the fifth timeβ)
Component names in the list are separated by a period or an asterisk character. If the string does not start with period or asterisk, a period is assumed. For example, *a.b*c becomes:
quarks a b c
bindings loose tight loose
see, * loose, . tight, * loose β it literally ate and left no crumbs β¨
π¦ SEE ALSO π¦
Go read these next, bestie, they're all connected:
And of course, the big one: Xlib - C Language X Interface π
k bye ily, go forth and quark responsibly π§π
this has been XrmUniqueQuark(3) from X Version 11, shipped with libX11 1.8.14 β mwah, take care of her π
π¦ where this page comes from
- alpine 3.24: libx11-doc 1.8.14-r0 Β· X11
- arch rolling: libx11 1.8.14-1 Β· MIT AND X11
- nixos 26.05: libx11 1.8.14
- nixpkgs unstable: libx11 1.8.14
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms