X11 related parameter settings
- X11
- Xlib: connection to ":0.0" refused by server
- On and off the screen display
- Connect the actual screen
- Touch screen redirection
-
- 0, touch screen redirection
- 1. Install the screen calibrator
- 2. Check the screen resolution
- 3. Manually set the size of the calibration window (used when there are multiple displays and only one touch screen, used to set only the specified window)
- 4. Follow the instructions to copy the calibration information to the following file
- 5. Finish.
- 1. Check how to use xinput_calibrator
- 2. View input devices
- 3. View the output device
X11
Environment variables are DISPLAY
used to set where to display graphics.
Log in to the graphical interface directly or use startx to start the graphics after logging in to the command line interface, the DISPLAY environment variable will be automatically set to 0:0
Variable format
The format of the DISPLAY environment variable is as follows host:NumA.NumB
,
host
Refers to where Xserver is locatedHost hostname or ip address, The graphics will be displayed on this machine. It can be a Linux/Unix machine with a graphical interface, or a Windows machine with Xserver running on Windows platforms such as Exceed, X-Deep/32, etc. If Host is empty, then Indicates that Xserver is running on this machine, and the graphics program (Xclient) uses unix socket to connect to Xserver, not TCP. When using TCP connection, NumA is the connected port minus the value of 6000. If NuMA is 0, it means Connect to port 6000; when using unix socket connection, it means the path of the connected unix socket, if it is 0, it means it is connected to /tmp/.X11-unix/X0. NumB is almost always 0
Xlib: connection to “:0.0” refused by server
Xlib: No protocol specifiedr
Error: Can’t open display: :0.0
This is because Xserver does not allow other users' graphics programs to be displayed on the current screen by default. If you need other users' graphics to be displayed on the current screen, you should use the currently logged-in user, that isThe user before switching identity executes the following command
xhost +
Instance
#切换用户前是root用户在使用图形程序
su - root
xhost +
su - oracle
root与oracle用户的DISPLAY都为:0.0
xhost is used to control X server access rights.
Usually when you log in from hostA to hostB and run the application on hostB, as the login and the logged-in, hostA is the client, but for graphics, it isDisplayed on hostA, Need to use hostA's Xserver, sohostA is server。
Therefore, before logging in to hostB, you need to run xhost+ on hostA to enable other users to access the Xserver of hostA.
On and off the screen display
#ubuntu16.04关掉图形界面启动,命令:
systemctl disable lightdm.service
#开启图形界面命令:
ln -s /lib/systemd/system/lightdm.service /etc/systemd/system/display-manager.service
Reset
sudo dpkg-reconfigure lightdm
other
关闭图形界面:
1.不可恢复:
sudo systemctl disable lightdm.service
2.可恢复:
sudo systemctl set-default multi-user.target
打开图形界面,分别针对上述1和2
1
sudo apt-get install --reinstall lightdm
2
sudo systemctl set-default graphical.target
Connect the actual screen
Confirm that the name of display of the actual screen is the value of DISPLAY
Requires running on the actual display screen
xdpyinfo |grep name
Different logins will cause different results, remember! Be sure to log in and run on the actual screen
xhost +
#运行结果:access control disabled, clients can connect from any host
Then the actual screen can be used by other login terminals, such as SSH terminal login. The
operation xdpyinfo |grep name
result is:
Then run the interface program with ui and it will not be displayed on the actual screen. If you need to map to the actual screen, execute the following command:
#实际屏幕端,允许任意连接 或者加号后面带ip地址指定ip可以连接
xhost +
#ssh端设置DISPLAY,指定图形连接到localhost:0.0这里也就是我们在实际屏幕端查到的信息
export DISPLAY=:0.0
#以上没有错误,再ssh端,运行需要的程序即可显示到实际屏幕端
xxx
Set rotation
xrandr -o left 向左旋转90度
xrandr -o right 向右旋转90度
xrandr -o inverted 上下翻转
xrandr -o normal 回到正常角度
#通过xrandr读取显示屏id 为DSI-1,指定他旋转
xrandr --output DSI-1 --rotate left
Touch screen redirection
ubuntu multi-display single touch screen calibration
0, touch screen redirection
sudo xinput map-to-output 13 DP1 #将触摸屏映射到指定的显示器
-
13
It is the ID of the touch screen device, which can bexinput
viewed by commandILITEK ILITEK-TP id=13 [slave pointer (2)] -
DP1
The name of the specified display device, which can bexrandr
viewed through commands
1. Install the screen calibrator
sudo apt-get install xinput-calibrator
2. Check the screen resolution
Check the screen resolution in System settings --> Display
3. Manually set the size of the calibration window (used when there are multiple displays and only one touch screen, used to set only the specified window)
My computer has two monitors, one 1920x1080
and one 1024x768
, I only calibrate the left monitor, such as
Usage:xinput_calibrator --geometry x
–geometry: manually provide the geometry (width and height) for the calibration window
sudo xinput_calibrator --geometry 1920x1080
#注意:1920x1080 此处是字母x
Warning: multiple calibratable devices found, calibrating last one (ILITEK ILITEK-TP)
use --device to select another one.
Setting calibration data: 0, 16384, 0, 9600
Calibrating EVDEV driver for “ILITEK ILITEK-TP” id=14
current calibration values (from XInput): min_x=0, max_x=16384 and min_y=0, max_y=9600
Doing dynamic recalibration:
Setting calibration data: 82, 32942, 155, 9796
–> Making the calibration permanent <–
copy the snippet below into ‘/etc/X11/xorg.conf.d/99-calibration.conf’ (/usr/share/X11/xorg.conf.d/ in some distro’s)
Section “InputClass”
Identifier “calibration”
MatchProduct “ILITEK ILITEK-TP”
Option “Calibration” “82 32942 155 9796”
Option “SwapAxes” “0”
EndSection
My computer is in the /usr/share/X11/xorg.conf.d/ directory
4. Follow the instructions to copy the calibration information to the following file
sudo gedit /usr/share/X11/xorg.conf.d/99-calibration.conf
Copy the content below
Section “InputClass”
Identifier “calibration”
MatchProduct “ILITEK ILITEK-TP”
Option “Calibration” “82 32942 155 9796”
Option “SwapAxes” “0”
EndSection
5. Finish.
1. Check how to use xinput_calibrator
xinput_calibrator -h
xinput_calibrator, v0.7.5
Usage: xinput_calibrator [-h|–help] [-v|–verbose] [–list] [–device ] [–precalib ] [–misclick ] [–output-type <auto|xorg.conf.d|hal|xinput>] [–fake] [–geometry x] [–no-timeout]
-h, --help: print this help message
-v, --verbose: print debug messages during the process
–list: list calibratable input devices and quit
–device <device name or XID or sysfs event name (e.g event5)>: select a specific device to calibrate
–precalib: manually provide the current calibration setting (eg. the values in xorg.conf)
–misclick: set the misclick threshold (0=off, default: 15 pixels)
–output-type <auto|xorg.conf.d|hal|xinput>: type of config to output (auto=automatically detect, default: auto)
–fake: emulate a fake device (for testing purposes)
–geometry: manually provide the geometry (width and height) for the calibration window
–no-timeout: turns off the timeout
–output-filename: write calibration data to file (USB: override default /etc/modprobe.conf.local
2. View input devices
xinput
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ Logitech USB Receiver id=11 [slave pointer (2)]
⎜ ↳ ILITEK ILITEK-TP id=13 [slave pointer (2)]
⎜ ↳ ILITEK ILITEK-TP id=14 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Power Button id=6 [slave keyboard (3)]
↳ Video Bus id=7 [slave keyboard (3)]
↳ Power Button id=8 [slave keyboard (3)]
↳ Sleep Button id=9 [slave keyboard (3)]
↳ Logitech USB Receiver id=10 [slave keyboard (3)]
↳ USB2.0 Camera
id=12 [slave keyboard (3)]
3. View the output device
xrandr
Screen 0: minimum 8 x 8, current 1920 x 1080, maximum 32767 x 32767
DP1 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 521mm x 293mm
1920x1080 60.0*+
1680x1050 60.0
1280x1024 75.0 60.0
1440x900 59.9
1280x960 60.0
1280x720 60.0
1024x768 75.1 70.1 60.0
832x624 74.6
800x600 72.2 75.0 60.3 56.2
640x480 75.0 72.8 66.7 60.0
720x400 70.1
HDMI1 disconnected (normal left inverted right x axis y axis)
HDMI2 disconnected (normal left inverted right x axis y axis)
VIRTUAL1 disconnected (normal left inverted right x axis y axis)
实例参考