网站制作 连云港,建设营销型网站公司,15年做啥网站致富,沧州营销型网站建设Ubuntu扩展触摸屏触控错位修复
当我们ubuntu外接一个触摸显示器的时候#xff0c;会发现触摸扩展屏幕#xff0c;发现操控的是主屏幕#xff0c;我写了一个脚本去修复。
#! /bin/bash
#------------------------------------------------------------------------------
#…Ubuntu扩展触摸屏触控错位修复
当我们ubuntu外接一个触摸显示器的时候会发现触摸扩展屏幕发现操控的是主屏幕我写了一个脚本去修复。
#! /bin/bash
#------------------------------------------------------------------------------
# Filename: repairTouchscreen.sh
# Usage: ./repairTouchscreen.sh
# Version: 1.0
# Date: 2018-03-29
# Author: vincent
# Email: N/A
# Description: 此脚本用于修复Ubuntu下扩展触摸显示器触摸扩展屏操作主屏的错误
# Notes: N/A
#-------------------------------------------------------------------------------outputErrorMsg()
{if [ $1 -ne 0 ]thenecho $2exitfi
}declare SCREEN_COUNTS # 当前显示器的总数
declare ACTIVE_SCREEN_COUNTS # 当前活跃的显示器数量
declare SCREEN_NAME # 显示器的输出名称
declare TOUCH_DEVICE_ID # 触摸设备ID号SCREEN_COUNTS$(xrandr --listmonitors | wc -l)
outputErrorMsg $? Get screen counts failed!
SCREEN_COUNTSexpr $SCREEN_COUNTS - 1ACTIVE_SCREEN_COUNTS$(xrandr --listactivemonitors | wc -l)
outputErrorMsg $? Get active screen counts failed!
ACTIVE_SCREEN_COUNTSexpr $ACTIVE_SCREEN_COUNTS - 1if [ $ACTIVE_SCREEN_COUNTS -ge 3 ] # 如果当前活跃的显示器数量多于2个退出
thenoutputErrorMsg 1 There are currently three monitors, please reduce to two monitors
fiif [ $ACTIVE_SCREEN_COUNTS -eq 1 ] # 如果只有一个活跃的显示器退出
thenoutputErrorMsg 1 There are only one monitor!
fi
# 如果是两个屏幕那么第一个是主屏幕第二个是辅助屏幕
SCREEN_NAME($(xrandr --listactivemonitors | awk {if(NR 1) {print $4}}))
outputErrorMsg $? Get screen name failed!TOUCH_DEVICE_ID$(xinput | grep -iw touch) # 获取可触摸设备if [ -z $TOUCH_DEVICE_ID ]
thenoutputErrorMsg 1 There is no touch device!
fiTOUCH_DEVICE_ID$(echo ${TOUCH_DEVICE_ID#*id})
TOUCH_DEVICE_ID$(echo ${TOUCH_DEVICE_ID%% *}) # 最终获取id号if [ -z $TOUCH_DEVICE_ID ]
thenoutputErrorMsg 1 Device id is empty!
fixinput map-to-output $TOUCH_DEVICE_ID ${SCREEN_NAME[1]}
xrandr --listactivemonitors
echo Setting successful!