---
name: "xcb_intern_atom"
section: "3"
platform: "linux"
package: "libxcb"
version: "1.17.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/xcb_intern_atom"
---

# xcb\_intern\_atom(3)

Get atom identifier by name

## NAME

xcb\_intern\_atom - Get atom identifier by name

## SYNOPSIS

**#include \<xcb/xproto.h\>**

### Request function

xcb\_intern\_atom\_cookie\_t **xcb\_intern\_atom**(xcb\_connection\_t \**conn*, uint8\_t *only\_if\_exists*, uint16\_t *name\_len*, const char \**name*);

### Reply datastructure

```

typedef struct xcb_intern_atom_reply_t {
    uint8_t    response_type;
    uint8_t    pad0;
    uint16_t   sequence;
    uint32_t   length;
    xcb_atom_t atom;
} xcb_intern_atom_reply_t;
```

### Reply function

xcb\_intern\_atom\_reply\_t \***xcb\_intern\_atom\_reply**(xcb\_connection\_t \**conn*, xcb\_intern\_atom\_cookie\_t *cookie*, xcb\_generic\_error\_t \*\**e*);\

## REQUEST ARGUMENTS

- *conn*

  The XCB connection to X11.

- *only\_if\_exists*

  Return a valid atom id only if the atom already exists.

- *name\_len*

  The length of the following *name*.

- *name*

  The name of the atom.

## REPLY FIELDS

- *response\_type*

  The type of this reply, in this case *XCB\_INTERN\_ATOM*. This field is also present in the *xcb\_generic\_reply\_t* and can be used to tell replies apart from each other.

- *sequence*

  The sequence number of the last request processed by the X11 server.

- *length*

  The length of the reply, in words (a word is 4 bytes).

- *atom*

  TODO: NOT YET DOCUMENTED.

## DESCRIPTION

Retrieves the identifier (xcb\_atom\_t TODO) for the atom with the specified name. Atoms are used in protocols like EWMH, for example to store window titles (*\_NET\_WM\_NAME* atom) as property of a window.

If *only\_if\_exists* is 0, the atom will be created if it does not already exist. If *only\_if\_exists* is 1, *XCB\_ATOM\_NONE* will be returned if the atom does not yet exist.

## RETURN VALUE

Returns an *xcb\_intern\_atom\_cookie\_t*. Errors have to be handled when calling the reply function *xcb\_intern\_atom\_reply*.

If you want to handle errors in the event loop instead, use *xcb\_intern\_atom\_unchecked*. See **[xcb-requests(3)](/xcb-requests/3.md)** for details.

## ERRORS

- *xcb\_alloc\_error\_t*

  TODO: reasons?

- *xcb\_value\_error\_t*

  A value other than 0 or 1 was specified for *only\_if\_exists*.

## EXAMPLE

```

/*
 * Resolves the _NET_WM_NAME atom.
 *
 */
void my_example(xcb_connection_t *c) {
    xcb_intern_atom_cookie_t cookie;
    xcb_intern_atom_reply_t *reply;
    cookie = xcb_intern_atom(c, 0, strlen("_NET_WM_NAME"), "_NET_WM_NAME");
    /* ... do other work here if possible ... */
    if ((reply = xcb_intern_atom_reply(c, cookie, NULL))) {
        printf("The _NET_WM_NAME atom has ID %u0, reply->atom);
        free(reply);
    }
}
```

## SEE ALSO

[**xcb-requests**(3)](/xcb-requests/3.md), [**xcb-examples**(3)](/xcb-examples/3.md), [**xcb\_get\_atom\_name**(3)](/xcb_get_atom_name/3.md), [**xlsatoms**(1)](/xlsatoms/1.md)

## AUTHOR

Generated from xproto.xml. Contact xcb@lists.freedesktop.org for corrections and improvements.
