X
X Server software
XMing
See XMing page.
VcXsrv Windows X Server
A fork of XMing, without the annoyance of the broken donation link.
Actively maintained, but:
- Launching terminator: black window for one or two minutes (apparently DBUS error - this is apparent when starting terminator from an existing terminator window).
- Not smooth screen scrolling
- Native OpenGL gives error about missing driver
Pro:
- Right click menu in terminator works.
- Nice colors, but a bit blurry.
Configuration
- xset is a user preference utility for X. It can be used to set different settings in X.
To get the current configuration settings:
xset q
Hints and Tips
See Linux Commands for a list of X-related commands, and programs to manage key bindings in X. See Linux Software for list of X-related software.
Screenshot
- In Gnome,
- Press PrtScn to take a screenshot of the complete desktop.
- Press Alt + PrtScn to take a snapshot of window under mouse pointer.
- See all Linux Software#Shutter
- There exists also plenty of command-line & GUI solutions ([1]).
Enabling xhost on Ubuntu
For security, xhost is disabled by default on Ubuntu. To enable it back ([2]):
- Edit /etc/X11/xinit/xserverrc:
Remove the-nolisten tcp
- Edit /etc/gdm/gdm.conf:
Comment out theDisallowTCP=true
so that it doesn't add the-nolisten
back. - Really restart X — kill gdm and restart it:
sudo /etc/init.d/gdm stop
sudo /etc/init.d/gdm start
Set or Get information on Screen Size and Resolution
To get information on the screen size and resolution, use utility xdpyinfo:
xdpyinfo | grep dimensions # Return dimension of the desktop (size in pixels and millimeters)
xdpyinfo | grep resolution # Return current screen resolution in DPI (dots per inch)
Some basic information on screen size, DPI, etc:
point (pt) | The point or pt is a typographic unit defined as 1/72 of an inch |
DPI | Dots per inch, i.e. the number of pixels by screen inch. Most monitors nowadays have a resolution of 96 DPI. |
As explained here, the DPI of the X-server is determined as follows:
-dpi
command line option has highest priority.- If not set, look up
DisplaySize
setting in the X config file. - If not set, use the monitor size values from DDC to derive the DPI.
- If unknown, 75 DPI is used by default.
Keyboard shortcut to paste x-clipboard
From [3]:
- Install packages xsel, xbindkeys, xvkbd
- Edit file ~/.xbindkeysrc
"xvkbd -no-jump-pointer -xsendevent -text "\D1`xsel`" 2>/dev/null" F12
Enable X access selectively (xhost,xauth)
To grant access to all users (not adviced):
xhost +
To grant access to a local user user1:
xhost +SI:localuser:user1
The above fail recently on Ubuntu. To grant access, user must have DISPLAY and XAUTHORITY correctly set. Some solutions below.
- Copy .Xauthority to user1 (assuming $USER has group write access to /home/user1 and user1 is in $USER group):
cp $XAUTHORITY ~user1/.Xauthority chmod g+rw ~user1/.Xauthority XAUTHORITY=~user1/.Xauthority sudo -H -u user1 xterm
- Grant access to user1 (assuming user1 is in same group as $USER):
chmod g+x $HOME chmod g+r $XAUTHORITY
- Grant access manually with
xauth
[4]:
xauth list|perl -lne 'print for /$HOSTNAME\/unix:0.* ([0-9a-f]+)/g') > /tmp/cookie
sudo -H -u user1 bash
export XAUTHORITY=$HOME/.Xauthority # Must set XAUTHORITY explicitly because set by sudo
xauth add $DISPLAY . $(cat /tmp/cookie)
rm /tmp/cookie
xterm
More solutions:
- Use pam/dbus [5] (does not work for me).
- Use package sux (no longer available on Ubuntu 14.04):
sudo apt-get install sux sux user -c 'command'
Set Window Title
Using echo
[6]:
echo -ne "\033]0;SOME TITLE HERE\007"
Set Window Icon
Use xseticon.
Capture all mouse / keyboard events
Use xinput
:
xinput test-xi2 --root>log.txt
Windows Manager
References
The function of the window manager is to draw the windows in a certain place, with a certain size, and let them be movable and resizable.
Most common Window Managers on Ubuntu:
- Metacity — The default GNOME Window Manager
- Kwin — KDE Window Manager
- Compiz
Windows Decorator
The window decorator draws the window borders. It is not necessary to move the window, since alt+click & drag will still work even when the window decorator has crashed.
- Metacity has its own window decorator built-in
- KWin also has its own window decorator built-in
- Compiz supports 3 different window decorators:
- gtk-window-decorator
- kde-window-decorator
- emerald — The window decorator inherited from Beryl, the ancestor of Compiz.
Themes
Gnome:
- GTK theme — controls how buttons look, the colors of text, the window background, the scrollbars, and the menubar styles.
- Metacity theme — just controls the window border's style.
KDE:
- Qt theme — does the buttons, scrollbars, etc.,
- Kwin has its own themes for window borders.
When Compiz is used, the theme used depends on the selected window decorator. gtk-window-decorator uses Metacity themes, kde-window-decorator used kwin themes, Emerald has its own themes.
wmctrl / xdotool
Use wmctrl
or xdotool
to send X events or control windows from the command line:
wmctrl -l -x # Get list of windows
wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz # Un-maximize current active window
# Move windows to different viewports
xdotool search --onlyvisible --classname Opera set_desktop_viewport 0 0 windowmove %@ 1600 0
xdotool search --onlyvisible --classname Gvim set_desktop_viewport 0 0 windowmove %@ 0 0
xdotool search --onlyvisible --class VirtualBox set_desktop_viewport 3200 0 windowmove %@ 0 0
xprop
Use xprop to display X properties on a window, fonts, etc. Without any parameters, xprop will display properties on window clicked by the user.
xprop # Show properties on window clicked by the user
xev
Use xev (package x11-utils) to detect keyboard or mouse presses, as well as any X events (show keycode - i.e. scancode, keypress, button press...).
Mouse
To adjust mouse properties, use xset m. Default settings (restored with xset m):
Pointer Control: acceleration: 2/1 threshold: 4
Set custom settings:
xset m 1/1 2 # xset m [acc_mult[/acc_div] [thr]]
In Gnome, mouse settings can also be configured in System → Hardware → Mouse.
Keyboard
Qwerty / Azerty Issues
Some tips and tricks to (touch-)type on a QWERTY keyboard when the keymap is set to AZERTY.
The main issue is that AZERTY keyboard has an additional key next to the left SHIFT key. This key gives access to <, to > (Shift) and to \ (AltGr). To obtain these keys on a QWERTY keyboard, the basic trick is to temporarily switch the keyboard layout. Alternatively, one can use under X:
- <:
- >:
- \: Use AltGr-- (on QWERTY, i.e. AltGr-) on AZERTY)
Layout
To change keyboard layout (xfree86):
#Set to BE layout
xprop -root -f _XKB_RULES_NAMES 8s -set _XKB_RULES_NAMES xfree86
setxkbmap -model pc105 -layout be
#Set to US layout
xprop -root -f _XKB_RULES_NAMES 8s -set _XKB_RULES_NAMES xfree86
setxkbmap -model pc104 -layout us
Multiple keyboards - Change keyboard layout on each device separately ([7])
setxkbmap -device 3 af #Set device 3 to Farsi (to find device id, try 1 and then up)
setxkbmap -device 3 us #Set it back to US
Configuring Layout Options
X supports a wide range of layout options. See xkeyboard-config manpage for a list:
man 7 xkeyboard-config
The most interesting options:
caps:escape
— Make Caps Lock another Escape keycaps:swapescape
— Swap Caps Lock and Escape key
Use setxkbmap
to set temporarily layout options:
/usr/bin/setxkbmap -option "caps:escape"
There are various options to make these settings permanent for the user:
- In Ubuntu (before u14.04 trusty), use Keyboard layout applet in system configuration, and click Options
- In Ubuntu 14.04 Trusty, Use
dconf-editor
and go org >> gnome >> desktop >> input-sources, then set xkb-options (e.g.,['caps:escape']
) to make the options permanent.
sudo apt-get install dconf-tools # To install dconf-editor
- Or using the command-line, via
gsettings
gsettings get org.gnome.desktop.input-sources xkb-options
gsettings set org.gnome.desktop.input-sources xkb-options "@as ['caps:escape']"
- Alternatively, use
gnome-tweak-tool
[8]
To make the settings permanent system-wide:
- Create file /usr/share/X11/xorg.conf.d/10-keyboard.conf (on Debian / Ubuntu; this is /etc/X11/xorg.conf.d/10-keyboard.conf on other systems). Example of content [9]:
Section "InputClass" Identifier "system-keyboard" MatchIsKeyboard "on" Option "XkbLayout" "us" Option "XkbModel" "pc104" Option "XkbOptions" "shift:both_capslock,caps:none" EndSection
Screensaver
X11 screensaver is configured via xset s
(see man xset
).
To disable screen saver:
xset s off
This line can be added to ~/.xsession to disable this feature permanently.
Synergy
Install Windows Client
- Execute setup program.
- Set the client to start automatically at PC startup
- Set the service Synergy Client to start manually.
- Check that the keymap for all users are identical.
- To launch the client:
net start "Synergy Client"
Install Linux Client
- Manual launch:
sudo synergyc --daemon --restart -n clientname servername
Install Linux Server
- Configuration file /etc/synergy.conf (see [http://synergy2.sourceforge.net/configuration.html reference manual) . Example
- Firewall — open up port 24800/TCP
- Server on gdm — Requires editing 3 gdm startup scripts. /etc/gdm/Init/Default:
- At the beginning of /etc/gdm/PostLogin/Default:
- At the beginning of /etc/gdm/PreSession/Default:
section: screens
gryphon:
BEQLEUNXP1NB103:
minimoy:
end
section: links
gryphon:
left = BEQLEUNXP1NB103
right = minimoy
BEQLEUNXP1NB103:
right = gryphon
minimoy:
left = gryphon
end
section: options
screenSaverSync = true
keystroke(shift+alt+right) = switchInDirection(right)
keystroke(shift+alt+left) = switchInDirection(left)
end
#
# Start the synergy server
#
/usr/bin/killall synergys
sleep 1
/usr/bin/synergys --config /etc/synergy.conf --daemon
exit 0
#
# Kill all running synergy server
#
/usr/bin/killall synergys
sleep 1
#
# Start synergy server
#
/usr/bin/killall synergys
sleep 1
/usr/bin/synergys --config /etc/synergy.conf --daemon
Starting manually with aliases
The aliases make it easy to restart synergy on the client / server in case of crashes (quite frequent),
Add to /etc/sudoers:
ALL ALL=NOPASSWD: /usr/bin/synergyc
ALL ALL=NOPASSWD: /usr/bin/synergys
ALL ALL=NOPASSWD: /usr/bin/killall -9 synergyc
ALL ALL=NOPASSWD: /usr/bin/killall -9 synergys
Define the following aliases:
alias synclient="sudo killall -9 synergyc; read -p 'Press ENTER...'; sudo synergyc --daemon --restart -n $HOSTNAME"
alias synserver='sudo killall -9 synergys 2>/dev/null; read -p "Press ENTER..."; sudo synergys --daemon --restart --config /etc/synergy.conf'
To start synergy:
synserver # On the server
synclient <servername> # On the client
Building from sources
Instructions to build synergy 1.3.8 on Lucid.
Build instructions say that we have to use cmake and the given hm.sh script. However that does not work! The script always complains about a missing generator argument, even though we try to give it in all possible ways.
Instead, do the usual configure; make
:
- Install the dependencies:
sudo apt-get install cmake make g++ xorg-dev libqt4-dev
- Unpack the archive, then
./configure
make
sudo cp bin/synergyc /usr/bin
sudo cp bin/synergys /usr/bin
Troubleshoot
- Sticky modifier keys (ctrl/alt/shift), desync capslock — This problem occurs at least one during my Linux - Linux session (Ubuntu Lucid client, Maverick client), belgium keyboard. Also Capslock event not seen on client. Some related bugs: [10], [11].
- Firefox Chinese bug — When copy/pasting text (incl. address bar) from Firefox to a remote Windows screen, chinese characters are printed instead. Workaround:
- Security — Data are not encrypted between the server and the client(s). To enable this, use SSH port forwarding. Run on the remote client:
- Login / Unlocking screen saver on Windows client — On Windows client, Synergy must be configured to autostart at boot in order to be able to unlock a session (eg. when client screensaver is protected by a password).
- Keymaps — Server and all client must be configured to all use exactly the same keymap. On Windows client, this is valid for logged user but also for at least Administrator account. Otherwise typing in the login window will give incorrect characters.
- Can't get tilde character (~) on a Belgian-french keyboard on windows client / Linux server with AltGr= Workaround: Use CA= followed by space.
- Can't connect to server. Possibly because synergy client not started with root privileges
- VirtualBox — When the Synergy Server is also a VirtualBox host, with the guest in fullscreen mode, the mouse will not leave the guest screen. It seems that VirtualBox doesn't release the mouse. See bugs [12], [13], [14]. Workarounds:
- Press VB Host Key (typically ctrl), either before or after going to Synergy Client. — tried and works on Synergy 1.3.7 - VB 4.0.10
- Disable VB mouse integration
sudo apt-get install xsel # Install xsel (Ubuntu) / xselection (opensuse)
xsel -p # (Ubuntu) Before pasting in the remote Windows screen
xselection PRIMARY # (opensuse)
ssh -f -N -L 24800:<server-name>:24800 <user-server-name>@<server-name> && synergyc localhost
However, this creates some lag, and mouse movement are a bit jerky. Another solution is to not use wireless connection, and connect computers through a network switch so that local communication are not visible to other computers on the network.