Real name: X Window System.
X11 is a window system:
- http://superuser.com/questions/291298/window-manager-vs-desktop-environment-vs-window-system-whats-the-difference
- http://unix.stackexchange.com/questions/20385/windows-managers-vs-login-managers-vs-display-managers-vs-desktop-environment
It is by far the most commonly used on Linux.
Alternatives: http://unix.stackexchange.com/questions/9608/lightweight-x11-alternative-available
-
Wayland. https://en.wikipedia.org/wiki/Wayland_(display_server_protocol)
It is not yet widely used, but plans made for use in Ubuntu 16.04.
Based on the https://en.wikipedia.org/wiki/EGL_(API) Khronos API.
Reference implementation: https://en.wikipedia.org/wiki/Wayland_(display_server_protocol)#Weston
-
Mir. https://en.wikipedia.org/wiki/Mir_(software)
Part of it comes from the Android API.
X11 is only an interface.
There can be different implementations:
- X.org implementation currently dominates
- XFree86 was the dominant prior to 2004, when it adopted BSD license leaving GPL, and fell into oblivion.
X is an abstraction layer for things like:
- windows
- key presses
- mouse position / presses
- screen backlight
X does not:
-
relegates certain jobs to x display managers and X window managers.
-
panel
-
a desktop that shows files contained in some predefined folder. TODO who does that?
-
sound management
This has been taken up by other projects:
- PulseAudio
- Advanced Linux Sound Architecture (ALSA)
Usually graphic accelerated. This is why messing with GPU settings may break your desktop.
X11 uses a server/client mode
Client and server can be on different machines
Client:
- typically programs with a window
- clients give commands to the X server and tell it to draw on screen
- clients respond to input events via callback functions
Server:
-
creates the image
-
sends inputs events to clients who responds to it via callbacks
-
a server has many displays
-
a display has many screens, one mouse and one keyboard
-
to set the display to use use the DISPLAY var:
env DISPLAY=localhost:0.1 firefox & #single commena
Display notation:
0.1
means: display 0, screen 1
A good way to see some basic and useful application implemented in pure X as demos
is to do ls /etc/X11/app-defaults
Dominant implementation of the X server.
Configuration file:
man xorg.conf
First of:
/etc/X11/<cmdline>
/tmp/Xorg-KEM/etc/X11/<cmdline>
/etc/X11/$XORGCONFIG
/tmp/Xorg-KEM/etc/X11/$XORGCONFIG
/etc/X11/xorg.conf-4
/etc/X11/xorg.conf
/etc/xorg.conf
where <cmdline>
is specified on the command line at startup
Log file:
less /var/log/Xorg.0.log
where 0
is the display number.
Get X server version
sudo X -version
View and edit on which users may connect to an X server.
When you start with most desktop environments, they start the host as you.
If you su another-user
, by default he cannot connect.
View current status:
xhost
Let any user connect:
xhost +
Let a single user connect:
xhost + another-user
List x clients.
This allows you to see all open windows.
xlsclients
More detailed info:
xlsclients -l
Modify key maps.
For example, to exchange ESC and Caps Lock:
f=~/.Xmodmap
echo "! Swap caps lock and escape
remove Lock = Caps_Lock
keysym Escape = Caps_Lock
keysym Caps_Lock = Escape
add Lock = Caps_Lock
" >> "$f"
xmodmap "$f"
To make this happen every time at startup TODO broken?:
echo "xmodmap \"$f\"
" >> ~/.xinitrc
chmod +x ~/.xinitrc
The ~/.xsession
file could also be used depending on system
TODO vs xinitrc
?
Send clicks and manage window properties from sh.
Before you try to do things to a window, you must say which window you want to act on.
If you don't give any indication, actions occur on the current window.
Every window has a window id.
Act on windows with given id:
id=
xdotool search --window "$id" key ctrl+c
Act on windows with given name:
n=
xdotool search --name "$n" key ctrl+c
Name is exactly what is shown on window title bar.
Keystroke types:
key
: up and downkeydown
: only downkeyup
: only up
Send an a
keystroke to the current window:
xdotool key a
Send an a
keystroke and then a b
keystroke to the current window:
xdotool key a b
F2
:
xdotool key F2
á
:
xdotool key Aacute
ctrl+l
:
xdotool key ctrl+l
Sends a
, b
, space
, c
and d
:
xdotool type 'ab cd'
a
, waits 1 ms, b
:
xdotool type --delay 1 'ab'
Wait for application to start before sending a command to it:
google-chrome &
xdotool search --sync --onlyvisible --class "google-chrome"x-terminal-emulator
In this way, you can launch an app and send commands, making sure they will be received!
High level, GUI interface X11 automation.
Control screen brightness
Get current lightning level on a scale of 0 to 100:
xbacklight -get
Set lightning to 80%:
xbacklight -set 80
Acronym for X Resize, rotate AND Reflect
Gets and sets screen properties such as screen resolution.
xrandr
Sample output:
Screen 0: minimum 320 x 200, current 1600 x 900, maximum 32767 x 32767
LVDS1 connected primary 1600x900+0+0 (normal left inverted right x axis y axis) 309mm x 174mm
1600x900 60.0*+ 40.0
1440x900 59.9
1360x768 59.8 60.0
1152x864 60.0
1024x768 60.0
800x600 60.3 56.2
640x480 59.9
VGA1 disconnected (normal left inverted right x axis y axis)
VIRTUAL1 disconnected (normal left inverted right x axis y axis)
LVDS-2 disconnected (normal left inverted right x axis y axis)
VGA-2 disconnected (normal left inverted right x axis y axis)
DP-1 disconnected (normal left inverted right x axis y axis)
DP-2 disconnected (normal left inverted right x axis y axis)
DP-3 disconnected (normal left inverted right x axis y axis)
TODO understand everything on this output.
This output lists the possible resolutions. Mine are: 1600x900
(current because of the *
, default because of the +
).
Change resolution:
xrandr -s 1360x769
the new resolution must be on the list.
Now:
xrandr
Outputs:
1600x900 60.0 + 40.0
1440x900 59.9
1360x768 59.8* 60.0
1152x864 60.0
1024x768 60.0
800x600 60.3 56.2
640x480 59.9
So the asterisk *
gives the new resolution.
Change to default resolution (the one with the plus sign +
):
xrandr -s 0
X support an arbitrary number of selections.
The most important ones are widely implemented by default by most GUI systems:
-
PRIMARY
: automatically updated to the last selected text.It can be pasted with a middle click.
-
CLIPBOARD
: Ctrl + C, Ctrl + V mechanism.
Each selection contains data completely separate from the others.
Those concepts touched by freedesktop.org: http://freedesktop.org/wiki/Specifications/ClipboardsWiki/
Alternative tool to xsel
.
View and modify key mappings.
Get a list of current keymapping state:
xmodmap -pke > ~/.Xmodmap
Sample output line:
keycode 24 = q Q q Q adiaeresis Adiaeresis
^ ^ ^ ^ ^^^^^^^^^^ ^^^^^^^^^^
1 2 3 4 5 6
- no modifiers
- shift
- mode_switch no shift
- mode_switch + shift
- ?
- ?
- ?
- ?
- ?
AltGru is the mode_switch key.
Up to 8 keysyms bay be attached to each keycode.
However, only the first 4 are commonly used.
TODO
Swap ESC and CapsLock:
setxkbmap -option caps:escape
Put this in your ~/.xinitrc
.
Either for testing or useful utilities.
xcalc
: simple scientific calculatorxedit
: text editorxeyes
: fun X11 test programxfontsel
: point and click and view how a font looks likexgc
: X Graphics Demo. A GUI.xlogo
: a window with an X11 logoxmag
: magnifying lensxmessage
:zenity
's grandfatherxmore
:more
for Xxtime
: pointer clockxterm
: terminal
Open a test window and prints X events description to stdout:
xterm
xev
Try clicking on the windows, or using your keyboard to see the outputs.
- http://raspberrypi.stackexchange.com/questions/12606/run-a-gui-without-the-desktop
- http://stackoverflow.com/questions/24147026/display-gui-on-raspeberry-without-startx
- http://superuser.com/questions/904142/launching-programs-with-gui-without-display-manager
https://en.wikipedia.org/wiki/Xinit backend of startx
Sourced in Ubuntu 12.04, but not 14.04.
http://askubuntu.com/questions/518454/what-does-startx-command-do/817747#817747
Script to start an graphical session.
Don't ever run sudo startx
on an Ubuntu TTY!!! It will break your UI. Fix:
sudo apt-get install --reinstall ubuntu-desktop gdm unity
sudo mv /etc/X11/xorg.conf "/etc/X11/xorg.conf.$(date '+%Y-%m-%d-%H-%M-%S').bak"