fork download
  1. #!/bin/bash
  2. # Explanar.de bash script for calibrating Touchscreens in combination of several monitors
  3. # Aug 2013 testet with ubuntu 12.04LTS64
  4.  
  5. OS=$(uname)
  6. hostname=$(hostname)
  7. whoami=$(whoami)
  8. ip=$(ifconfig | grep 'inet ' | grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}')
  9. echo "|--------------------------------|"
  10. echo "|----Touchscreen Calibration----|"
  11. echo "|-----with external Monitors-----|"
  12. echo "|--------------------------------|"
  13. echo "| www.explanar.de | August 2013 |"
  14. echo "|--------------------------------|"
  15. echo ""
  16.  
  17.  
  18. # Must be root
  19. if [ "$UID" -eq 0 ];
  20. then
  21. echo "Ip-Adress:${ip}."
  22. echo "${OS}-Host:${hostname}."
  23. echo "User:${whoami}."
  24. echo ""
  25. echo ""
  26. echo ""
  27. else
  28. echo "Need to be root. Try to start script prefixed with \"sudo \"."
  29. exit 1
  30. fi
  31.  
  32.  
  33. # Identification of devices to be used
  34. inputdevall=$(xinput list --name-only | egrep -i "touch|Touch")
  35. outputdevall=$(xrandr | grep "connected" | cut -f1 -d"(")
  36.  
  37. # Input device Selection
  38. if [ -z "$inputdevall" ];
  39. then
  40. echo "Sorry, no Inputdevices found."
  41. exit 0
  42. else
  43. if [ $(echo "$inputdevall" | wc -l) -gt 1 ];
  44. then
  45. echo "Please choose the Device to calibrate:"
  46. echo "---------------------------------------"
  47. echo "$inputdevall" | nl
  48. echo "---------------------------------------"
  49. read -p "Number of Device to use: " inputdevnr
  50. echo ""
  51. echo ""
  52. inputdev=$(echo "$inputdevall" | awk "NR==$inputdevnr")
  53. inputdevothers=$(echo -n "sed -i /$inputdev/d $inputdevall")
  54. else
  55. inputdev=$(echo "$inputdevall")
  56. echo "Inputdevice: $inputdev"
  57. echo ""
  58. echo ""
  59. fi
  60. fi
  61.  
  62.  
  63.  
  64. # Output device Selection
  65. if [ -z "$outputdevall" ];
  66. then
  67. echo "Sorry, no Outputdevices found."
  68. exit 0
  69. else
  70. if [ $(echo "$outputdevall" | wc -l) -gt 1 ];
  71. then
  72. echo "Please choose the output-device to use:"
  73. echo "---------------------------------------"
  74. echo "$outputdevall" | nl
  75. echo "---------------------------------------"
  76. read -p "Number of Screen to use: " outputdevnr
  77. echo ""
  78. echo ""
  79. outputdev=$(echo -e "$outputdevall" | cut -f1 -d" " | awk "NR==$outputdevnr")
  80. outputdevothers=$(echo -e "$outputdevall" | cut -f1 -d" " | grep -v "$outputdev")
  81. else
  82. outputdev=$(echo "$outputdevall" | cut -f1 -d" ")
  83. echo "Outputdevice: $outputdev"
  84. echo ""
  85. echo ""
  86. fi
  87. fi
  88.  
  89.  
  90. # Switching off all unused Output-devices
  91. echo "$outputdevothers" | while read a; do $(xrandr --output "$a" --off); done # > /dev/null 2>&1
  92.  
  93. # string-to-command workaround: xinput doesn't understand Devices from variables
  94. cmd="xinput map-to-crtc '$inputdev' $outputdev"
  95. eval "$cmd"
  96.  
  97. if [ -f /usr/share/X11/xorg.conf.d/99-calibration.conf ]
  98. then
  99. rm /usr/share/X11/xorg.conf.d/99-calibration.conf
  100. fi
  101.  
  102.  
  103. calibration=$(xinput_calibrator)
  104. echo ""
  105. sudo echo -e "$calibration" | awk 'NR > 9 { print }' >> /usr/share/X11/xorg.conf.d/99-calibration.conf
  106.  
  107. # neue Variable mit Auflösung und koordinaten
  108. outputdevothersfull=$(echo -e "$outputdevall" | grep -v "$outputdev")
  109. echo "$outputdevothers" | while read a;
  110. do $(xrandr --output "$a" --off)
  111. done # > /dev/null 2>&1
  112.  
  113.  
  114. # Alte (einfache) Wiedereinschaltung der anderen monitore mit auto statt
  115. # echo -e "$outputdevothers" | while read a; do $(xrandr --output "$a" --auto); done # > /dev/null 2>&1
  116.  
  117.  
  118. eval "$cmd"
  119.  
  120. echo "Please readjust your \"(non-touch-)Monitors\" in the Systemsettings."
  121. echo ""
  122. echo ""
  123. echo ""
  124. echo ""
  125.  
  126. exit
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty