x.rst
author Oleksandr Gavenko <gavenkoa@gmail.com>
Mon, 22 Feb 2016 12:41:52 +0200
changeset 1903 901e7394849f
parent 1706 387028a4bc33
child 1905 fba288d59662
permissions -rw-r--r--
Decrease intent to increase space usage on mobile.

.. -*- coding: utf-8; -*-
.. include:: HEADER.rst

====
 X.
====
.. contents::

Standard.
=========

See

  http://www.tronche.com/gui/x/icccm/

Widget toolkit.
===============

  http://en.wikipedia.org/wiki/Widget_toolkit
                Widget toolkit
  http://en.wikipedia.org/wiki/List_of_widget_toolkits
                List of widget toolkits

GTK+.
-----

  http://en.wikipedia.org/wiki/GTK%2B

QT.
---

  http://en.wikipedia.org/wiki/Qt_%28toolkit%29

WxWidgets.
----------

  http://en.wikipedia.org/wiki/WxWidgets

Tk.
---

  http://en.wikipedia.org/wiki/Tk_%28computing%29

FLTK.
-----

  http://en.wikipedia.org/wiki/FLTK

Xaw.
----

  http://en.wikipedia.org/wiki/Xaw

GNUstep.
--------

  http://en.wikipedia.org/wiki/GNUstep

XView.
------

  http://en.wikipedia.org/wiki/XView

Getting info about X window and X-related applications data.
============================================================

Look for system registered resources::

  $ listres
  $ listres -all

  $ appres XTerm
  $ appres -name htop   # for xterm with running bash inside

Look for X resources of running applications::

  $ xprop -root
  $ xprop -name bash    # for xterm with running bash inside

Keyboard's keys under X window.
===============================

  scancodes
                hardware-dependent codes generated by keystrokes and received by
                the X server.
  keycodes
                Codes sent by the X server to the client indicating which key
                was pressed. Keycodes by themselves do not indicate what the
                keystroke means; the client must request that information from
                the X server.
  modifiers
                Flags, such as ``shift`` and ``control``, that the server sends
                with each keycode to the client. The client's interpretation of
                the keycode may depend on the state of the modifiers. For
                example, the state of the shift modifier determines whether an
                alphabetic character should be lowercase or uppercase. Because
                the X server encodes the states of the eight modifiers (shift,
                lock, control, mod1, mod2, mod3, mod4, and mod5) in a single
                byte of data, modifiers are often referred to as ``modifier
                bits``.
  keysyms
                codes that specify the glyphs appearing on the keys. The X
                server also maintains a list of strings that describe the
                keysyms, such as ``a``, ``B``, and ``Control``.

Find the keycode.
=================

::

  $ xev
  $ cat /usr/include/X11/keysymdef.h

Don't run under X::

  $ showkey

To do same under X::

  $ xev | sed -n 's=.*keycode \([0-9]*\).*=\1=p'

List key modifier::

  $ xmodmap -pm

Add keycode to modifier::

  $ xmodmap -e "add shift = Shift_R"

Remove keycode from modifier::

  $ xmodmap -e "remove shift = Shift_L"

Examining the current keymap table::

  $ xmodmap -pk

Changing the keymap table::

  $ xmodmap -e "keycode 34 = bracketleft braceleft"
  $ xmodmap -e "keysym CapsLock = Control_L"

  https://wiki.ubuntu.com/LaptopTesting/Keycodes
                Ubuntu Keycodes howto.
  http://en.gentoo-wiki.com/wiki/Multimedia_Keys
                Gentoo Multimedia Keys howto.

List input devices.
===================
::

  $ xinput -list

You can use obtained ID in such command::

  $ setxkbmap -device $ID -layout dvorak

Making screenshort.
===================
::

  $ sudo apt-get install scrot
  $ scrot -d <sec> <file>

or::

  $ sudo apt-get install imagemagic
  $ import -quality 100 -pause <sec> -silent <file>

Input method.
=============

Input method by setxkbmap.
--------------------------
::

  $ setxkbmap ru

  $ setxkbmap -rules xorg -model pc104 -layout "us,ru" -option "grp:rwin_toggle,grp_led:scroll" -variant ",winkeys"

Input method from xorg.conf.
----------------------------
::

  Section "InputDevice"
      Identifier     "Keyboard0"
      Driver         "kbd"
      Option         "XkbModel" "pc105"
      Option         "XkbLayout" "us,ru"
      Option         "XkbVariant" ",winkeys"
      Option         "XkbOptions" "grp:rwin_switch,grp_led:scroll"
  EndSection

.Xdefaults
==========

The syntax of an Xdefaults file is as follows::

  [client. | *][{restriction.} | *]resource: value

where:

  client
                The name of the application, some program allow change it by
                '-name' option. This element is optional (can be substituated
                with wildcard).
  restriction
                Class names or name of specific class instance. The classes
                names conventionally start with an upper-case letter.
  resource
                The name of the resource whose value is to be changed.
                Resources are typically lowercase with uppercase
                concatenation.
  value
                The actual value of the resource.
  delimiters
                A period (.) is used to signify each step down into the
                hierarchy. A colon (:) is used to separate the resource
                declaration from the actual value.

Comment start with '!' char and goes up to end of line or C-like ``/* */``.

Use xprop utility to find classes and resources used by application.

To reread your .Xresources file, and throw away your old resources::

  $ xrdb ~/.Xdefaults

To reread your .Xresources file, and keep your old resources::

 $ xrdb -merge ~/.Xdefaults

Example::

  *foreground: yellow
  XClock*foreground: pink
  Xman*topBox*foreground: blue

String value type.
------------------

This can be path specification like '/usr/bin/firefox'.

Colors value type.
------------------

For color names see '/usr/lib/X11/rgb.txt'. Also you can use hex
representation #ffffff.

Font value type.
----------------

You can use either a full name, a wildcarded specification, or a font alias::

  XTerm*Font: -adobe-courier-bold-r-normal--14-140-75-75-m-90-iso8859-1
  XTerm*Font: *courier-bold-r*140*
  XTerm*Font: 7x14

Geometry value type.
--------------------

  XCalc*geometry: 120x120-0-0
  XClock*geometry: -50+100

Cursor names value type.
------------------------

Cursor resources require the name of the file in /usr/include/X11/bitmaps that
contains the cursor you want to use.

  ScoTerm*pointerShape: gumby

Pixmaps value type.
-------------------

Pixmaps are patterns, like bitmaps, that are used to texture or color an area
on your display. Pixmap resources are specified like cursors or bitmaps.

Numebers value type.
--------------------

  XLogo*borderWidth: 10

Boolean value type.
-------------------

Some resources require a boolean value, such as 'true' or 'false', 'yes' or
'no', or 'on' or 'off'.

Wildcard matching.
------------------

The asterisk can be used as a wildcard, making it easy to write a single rule
that can be applied to many different applications or elements.

X utilities.
============

  appres
                List "application resources".
  listres
                List resources in widgets.
  bitmap, atobm, bmtoa
                Bitmap editor and converter utilities.
  editres
                Dynamic resource editor for X Toolkit applications.
  iceauth
                ICE authority file utility.
  xauth
                X authority file utility.
  ico
                Animate an icosahedron or other polyhedron.
  luit
                Locale and ISO 2022 support for Unicode terminals.
  setxkbmap
                Set the keyboard using the X Keyboard Extension.
  x11perf
                X11 server performance test program.
  x11perfcomp
                X11 server performance comparison program.
  xcalc
                scientific calculator desktop accessory that can emulate a TI-30
                or an HP-10C.
  xclock
                Displays the time in analog or digital form.
  xconsole
                Monitor system console messages with X.
  xdpyinfo
                displaying information about an X server.
  xev
                "Event Tester" window.
  xeyes
                Showing two googly eyes which follow the cursor movements on the
                screen as if they were watching it.
  xfontsel
                Point and click selection of X11 font names.
  xgamma
                Alter a monitor's gamma correction through the X server.
  xhost
                Server access control program for X.
  xinit
                X Window System initializer.
  startx
                Initialize an X session.
  xkill
                Kill a client by its X resource.
  xload
                System load average display for X.
  xlogo
                X Window System logo.
  xlsclients
                listing information about the client applications running on a display.
  xmag
                Magnify parts of the screen.
  xman
                Manual page display program for the X Window System.
  xmessage
                Display a message or query in a window.
  xmodmap
                Utility for modifying keymaps and pointer button mappings in X.
  xmore
                Plain text display program for the X Window System.
  xprop
                Property displayer for X.
  xrandr
                Primitive command line interface to RandR extension.
  xrdb
                X server resource database utility.
  xrefresh
                Refresh all or part of an X screen.
  xset
                User preference utility for X.
  xsetmode
                Set the mode for an X Input device.
  xsetpointer
                Set an X Input device as the main pointer.
  xsetroot
                Root window parameter setting utility for X.
  xsm
                X Session Manager
  resize
                Set environment and terminal settings to current xterm window size.
  xterm
                Standard terminal emulator for the X Window System.
  xvinfo
                Print out X-Video extension adaptor information.
  xwd, xwud
                Useful and easy way to take screenshots. Saves in the XWD X
                Window Dump image data format.
  xwininfo
                Window information utility for X.

XText extension.
================

``xdotool`` and ``xautomation`` utilities use ``XText`` for emulating user
actions.

GLX info.
=========

To determine whether 3D acceleration is working::

  $ apt-get install mesa-utils
  $ glxinfo | grep render

To see how many frames per second your video card is putting out::

  $ glxgears -info

See:

  https://wiki.debian.org/Mesa
                Mesa is an open source 3D computer graphics library that
                provides a generic OpenGL implementation for rendering
                three-dimensional graphics on multiple platforms.

Running a secondary X server.
=============================

::

  $ startx xterm -- :$N -depth 16

New server will be accessible at ``Alt+Ctrl+F$((N+6))``::

  :0  Alt+Ctrl+F7
  :1  Alt+Ctrl+F8
  ...
  :5  Alt+Ctrl+F12

In order to fix::

  X: user not authorized to run the X server

run::

  $ sudo dpkg-reconfigure x11-common

Running X server without display.
=================================

Run ``Xvfb`` and make screenshort of desktop::

  $ apt-get install xvfb
  $ Xvfb :1 -screen 0 1280x1024x24 &
  $ xclock -display :1 &
  $ import -display :1 -window root image.png
  $ kill %1 %2

In order to run ``Xvfb`` permanently add entry to ``/etc/inittab``::

  xvfb:2:respawn:/usr/bin/Xvfb :1 -ac -screen 0 1280x1024x24

Running X server in nested windows.
===================================
::

  $ sudo apt-get install xnest
  $ startx xterm -- `command -v Xnest` :1 -geometry 800x600