@gfld/xtsb
TypeScript icon, indicating that this package has built-in type declarations

1.0.0-rc1 • Public • Published

XTSB Build Status Coverage Status

X11 TypeScript Bindings.

Wip, although probably already quite usable.

Works in Node and browser.

Originally created for use in Greenfield.

Build

yarn install

Usage

example:

import { connect, EventMask, WindowClass } from 'xtsb'

async function main() {
  // create a new connection to the x server using the default environment variable DISPLAY
  const connection = await connect()
  
  // allocate a new windowId
  const windowId = connection.allocateID()

  // create a new window in a non-blocking way, we can optionally call 'check()' on the returned result so we receive a 'Promsise<void>' that can be 'await'ed.
  connection.createWindow(
    0,
    windowId,
    connection.setup.roots[0].root,
    0,
    0,
    150,
    150,
    0,
    WindowClass.InputOutput,
    0,
    { eventMask: EventMask.StructureNotify }
  )
  
  // query the window child tree and wait for the reply
  const queryTreeReply = await connection.queryTree(windowId)
  console.log(queryTreeReply.parent)
  
  // set the on destroy notify event listener
  connection.onDestroyNotifyEvent = event => {
    console.log(event.window)
  }
  
  // destroy the window and explicitly block & check if the request succeeded
  await connection.destroyWindow(windowId).check()
}

main()

Documentation

http://udev.be/xtsb/

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i @gfld/xtsb

Weekly Downloads

1

Version

1.0.0-rc1

License

MIT

Unpacked Size

681 kB

Total Files

46

Last publish

Collaborators

  • zubzub