XCB(1)

πŸ“¦ version 2.5, in opensuse-leap 16.0

πŸ’… XCB(1) β€” the vibe check

okay so real talk, this is a page from the General Commands Manual (that's the manual name bestie, we're in section 1) and it's about xcb. stick with me, it's actually iconic.


✨ NAME ✨

xcb β€” X Cut Buffers β€” literally pigeon holes for your cut and paste selections. πŸ•ŠοΈ


πŸŽ€ SYNOPSIS πŸŽ€

xcb [Xt option] [-l layout] [-n count] [-p|-s|-S list] [-r count]

🌸 DESCRIPTION 🌸

okay so xcb gives you easy access to the cut buffers that are built into every X server. no cap. it lets you mess with those buffers either from the command line, or with the mouse in a whole point-and-click situation. the buffers are like holding pens where you stash and grab arbitrary data fragments. you can make any number of cut buffers, so you can save any number of different pieces of data and recall them later. by default, 8 cut buffers get created. the program is designed primarily for textual data. πŸ’–

xcb has two modes of operation, and honestly both ate.

Normal mode: xcb gives you an array of windows on your display, one per cut buffer, tiled horizontally, vertically, or in some layout you specify yourself. each window displays the contents of its respective cut buffer. you can cut from and paste to the windows kinda like you do in xterm. the buffers can also be rotated. πŸ”„

Task mode: here xcb lets you access the cut buffers straight from the command line. you can load cut buffers from stdin, copy or concatenate them to stdout, load them using the current PRIMARY selection, or rotate them an arbitrary number of positions. in this mode xcb does the requested task and then exits. it creates no windows and has zero interaction with the mouse or keyboard. ghost mode fr. πŸ‘»


πŸ’… OPTIONS πŸ’…

xcb supports the full set of X Toolkit Intrinsics options, plus the ones listed below. xcb options can appear in any order. and heads up: the presence of the -p, -r, -s or -S options causes xcb to execute in task mode, described above. ⭐

  • -l layout β€” this option controls the geometry arrangement of xcb's subwindows. it's the command line equivalent of the .layout resource, described below.
  • -n count β€” create count cut buffers. count can be any integer greater than zero. this option is the command line equivalent of the .bufferCount resource, described below.
  • -u β€” use utf-8 instead of the current locale settings when executing in task mode and doing I/O.
  • -V β€” print the xcb release version number and exit immediately.
  • -p list β€” print the contents of the listed buffer(s) on stdout. the buffered data is printed exactly as it is stored in the server. selecting two or more buffers has the effect of concatenating the data on stdout. the cut buffers are numbered from 0... onwards. the list can be either a single digit, a comma separated list of digits, a range of the form m-n, or some combination of lists and ranges. the buffers are printed in listed order, so repeated numbers in the list can be used to duplicate buffer contents. 🫢
  • -r count β€” rotate the buffers by count positions. count can be any integer, positive or negative. this option may be used in conjunction with the -n count option to rotate a specific number of buffers. if the -n option is not used, xcb will rotate the number of buffers given by the .bufferCount resource.
  • -s list β€” store the data from stdin in the listed buffer(s). if the list refers to two or more buffers, the input data is duplicated in each buffer. refer to the -p option for the definition of a list.
  • -S list β€” store the current PRIMARY selection data in the listed buffer(s). the data is converted to a string representation. if the list refers to two or more buffers, the PRIMARY selection is duplicated in each buffer. refer to the -p option for the definition of a list. under the -S option xcb waits for the nominated cut buffer's contents to change before exiting. if no change is detected within 3 seconds, xcb exits with a non-zero return code. 😭

πŸ¦‹ WIDGETS and RESOURCES πŸ¦‹

the xcb widget hierarchy is a collection of custom buffer widgets, one per cut buffer. in the Athena version of the program, these buffer widgets are all contained within a single Athena form widget. in the Motif version of the program, they're each enclosed by Motif frame widgets, and the frame widgets are all contained within a single Motif RowColumn widget. the way that nesting goes. πŸͺ†

the names of the buffer widgets are "buffer0", "buffer1", "buffer2", .... etc., and their class name is "Buffer". each buffer widget supports all the standard core widget resources, plus the .foreground and .fontSet resources.

application wide resources are as follows:

.bufferCount (default value 8)

this is the number of buffer widgets to create. any number of widgets (greater than zero) can be created. πŸ‘‘

.layout (default value "h")

only the first character of the resource value is significant. this is the geometry arrangement to apply in the container widget. the layout can be "h" (horizontal), "v" (vertical), or some other value to disable the inbuilt geometry code and specify the layout via your X resources. an example is provided in the application default resources file.


🌈 EVENTS and TRANSLATIONS 🌈

xcb's input semantics are coded into a Toolkit translation table. the default bindings have been chosen to conform with the default configuration of other cut and paste clients, such as xterm. the bindings may be altered or overridden according to your needs. the action functions provided by xcb are:β€”

  • cut() β€” causes the contents of the chosen cut buffer to become the PRIMARY selection. the window contents, if any, are highlighted, and can then be pasted into other cut buffers or applications. βœ‚οΈ
  • paste() β€” causes the value of the PRIMARY selection to be converted into text and pasted into the chosen cut buffer, overwriting any previous buffer contents. if no PRIMARY selection is present, xcb pastes the contents of cut buffer zero into the chosen buffer.
  • clear() β€” clears the chosen cut buffer.
  • rotate(NN) β€” rotates the cut buffers by NN positions. NN may be any positive or negative number.
  • refresh() β€” causes the cut buffer window to be cleared and redrawn.
  • selreq() β€” this action function handles paste requests from other clients, or other xcb windows. it should always be bound to SelectionRequest events.
  • selclear() β€” this action function responds to the loss of ownership of the PRIMARY selection property. it should always be bound to SelectionClear events.
  • quit() β€” causes xcb to terminate. bye bestie πŸ‘‹

the default bindings are as follows:β€”

<Btn1Down>:         cut() \n\
Shift <Btn2Down>:   clear() \n\
<Btn2Down>:         paste() \n\
Shift <Btn3Down>:   rotate(-1) \n\
<Btn3Down>:         rotate(1) \n\
<Key>Left:          rotate(-1) \n\
<Key>Right:         rotate(1) \n\
<Key>Up:            rotate(-1) \n\
<Key>Down:          rotate(1) \n\
<Key>q:             quit() \n\
<SelReq>:           selreq() \n\
<SelClr>:           selclear()

πŸ”₯ EXAMPLES πŸ”₯

the following are some examples of xcb task mode usage:β€”

xcb -s 0-7 < /dev/null

this clears the first 8 cut buffers in your server.

echo "G'day." | xcb -display bigears:0.0 -s 1,3,5,7

this loads the string "G'day." into four of the cut buffers on the display "bigears".

xsendevent -win buffer5 '<Btn1Down>'

this uses the program xsendevent to send a synthetic mouse click event to an xcb subwindow, thereby making that window the owner of the PRIMARY selection.

ls xcb -p 2,3``

this produces a listing of all the files named in cut buffers 2 and 3.

xcb -p 0-7 | xcb -s 0

this concatenates the values in the first 8 cut buffers, and places the result back in cut buffer zero.

xcb -S 0 && xcb -p 0

the first command copies the current PRIMARY selection into the first cut buffer. if the copy succeeds, then the second command prints that data on stdout.

for i in 0 1 2 3 4 5 6 7
do
        xcb -p $i > $HOME/.xcb/$i
done
for i in 0 1 2 3 4 5 6 7
do
        xcb -s $i < $HOME/.xcb/$i
done

this first loop saves the contents of each of the cut buffers in a separate file under your home directory. the second loop restores the cut buffer contents from those files. when placed in your .logout and .login scripts respectively, the commands are a simple method of preserving your cut buffers across login sessions. ok that's actually so smart 🧚

function g {
        echo "$1\\c" | xcb -s 7
        grep "$@"
}
function vg {
        vi +/`xcb -p 7` "$@"
}

these two shell functions exemplify a simple mechanism for saving and reusing regular expressions. the first function saves the regex used for grep-ing into cut buffer 7. the second function reuses the most recent grep regex as a search command in vi. there is considerable scope for expanding and improving these ideas. honestly, go off. πŸ’œ


πŸ“ SEE ALSO πŸ“

xterm(1), xcutsel(1), xclipboard(1), xprop(1) Athena Widget Set - C Language Interface Motif Programmers Reference Guide


πŸ‘‘ AUTHORS πŸ‘‘

Current Maintainer (I18n version) Marc Lehmann E-mail: pcg@goof.com

Original Author Farrell McKay E-mail: Farrell.McKay@mpx.com.au

XView modifications provided by Danny Vanderryn E-mail: dvanderr@us.oracle.com


Copyright (C) 1992,1993,1994 by Farrell McKay.

Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appears in all copies and that both that copyright notice and this permission notice appear in supporting documentation. This software is provided "as is" without express or implied warranty.


πŸ’€ BUGS :-) πŸ’€

Xlib's underlying protocol for moving selection data between client and server can sometimes be slow, depending on the amount of data involved. do not expect fast performance if your selections are big or you want to store big files in your cut buffers! ("big" means, say, over 10k bytes β€” but your mileage may vary). 😭


fr fr though β€” big selections = slow, and that's just how Xlib is. not my fault, not xcb's fault. πŸ’…

and that's the whole page bestie β€” this one's from X Version 11, dated Oct 6 1994. vintage but still slaying. πŸŽ€βœ¨πŸ¦‹

πŸ“¦ where this page comes from