Need help with extcommands.xml
I have a command I want to add for screen calibration on a raspberry pi running the 0.85.2 image.
I added
"<command>
<name>Calibrate Touch Panel</name>
<execute>sudo bash /etc/X11/Xsession.d/xinput_calibrator_pointercal_wipe.sh</execute>
<confirm>Really calibrate touch screen?</confirm>
<remote>true</remote>
<print-permission>true</print-permission>
<add-permission>true</add-permission>
<del-permission>true</del-permission>
<config-permission>true</config-permission>
</command>"
to extcommands.xml
I have no idea what to do to make it work. From the terminal I can launch the script but from the touch screen it does nothing.
I have a very basic understanding of linux. Any help will be appreciated.
I added
"<command>
<name>Calibrate Touch Panel</name>
<execute>sudo bash /etc/X11/Xsession.d/xinput_calibrator_pointercal_wipe.sh</execute>
<confirm>Really calibrate touch screen?</confirm>
<remote>true</remote>
<print-permission>true</print-permission>
<add-permission>true</add-permission>
<del-permission>true</del-permission>
<config-permission>true</config-permission>
</command>"
to extcommands.xml
I have no idea what to do to make it work. From the terminal I can launch the script but from the touch screen it does nothing.
I have a very basic understanding of linux. Any help will be appreciated.
Comments
Your problem is a bit difficult.
1. Always use absolute path names. sudo and bash might be somehwere but server will start it only with correct full path.
2. sudo normally requires entering a password which is not possible here. See the docs how we added shutdown to sodoes list with no password.
3. You should better make a script doing everything and call that script. So you put that scriptname into sudoer list instead of /bin/bash. You might also need to set DISPLAY to :0 in the script to tell the command what display to calibrate.
The script /etc/X11/Xsession.d/xinput_calibrator_pointercal_wipe.sh contains the following:
#!/bin/sh
# script to make the changes permanent (xinput is called with every Xorg start)
#
# can be used from Xsession.d
# script needs tee and sed (busybox variants are enough)
#
# original script: Martin Jansa <Martin.Jansa@gmail.com>, 2010-01-31
# updated by Tias Guns <tias@ulyssis.org>, 2010-02-15
# updated by Koen Kooi <koen@dominion.thruhere.net>, 2012-02-28
rm /etc/pointercal.xinput
PATH="/usr/bin:$PATH"
BINARY="xinput_calibrator"
CALFILE="/etc/pointercal.xinput"
LOGFILE="/var/log/xinput_calibrator.pointercal.log"
if [ -e $CALFILE ] ; then
if grep replace $CALFILE ; then
echo "Empty calibration file found, removing it"
rm $CALFILE
else
echo "Using calibration data stored in $CALFILE"
. $CALFILE && exit 0
fi
fi
CALDATA=`DISPLAY=:0.0 xinput_calibrator --output-type xinput -v | grep ' xinput set' | sed 's/^ //g; s/$/;/g'`
if [ ! -z "$CALDATA" ] ; then
echo $CALDATA > $CALFILE
echo "Calibration data stored in $CALFILE (log in $LOGFILE)"
fi
If you delete
if [ -e $CALFILE ] ; then
if grep replace $CALFILE ; then
echo "Empty calibration file found, removing it"
rm $CALFILE
else
echo "Using calibration data stored in $CALFILE"
. $CALFILE && exit 0
fi
fi
It would always make a new calibration file. Good news is that it is the script I wanted you to write as it does everything and even sets display. So change you command to
/usr/bin/sudo /etc/X11/Xsession.d/xinput_calibrator_pointercal_wipe.sh
and add /etc/X11/Xsession.d/xinput_calibrator_pointercal_wipe.sh to the no password question list for repetierserver user as shown for the shutdown command in the server docs.
If the lcd was not calibrated at all, it will do the lcd calibration automatically.
From the server commands menu I can manually start the screen calibration.
For those with resistive touch screen lcd pannels on a Pi that want touch screen calibration easily, I did this:
Tested on:
5" HDMI touch scren with XPT2046 touch
5" HDMI touch scren with ADS7846 touch
3.5" RPi SPI display with XPT2046 touch (horrible display)
Install xinput-calibrator
from http://ozzmaker.com/enable-x-windows-on-piscreen/
Download and setup the calibration script
-
sudo chmod +x /etc/X11/Xsession.d/xinput_calibrator_pointercal.sh
Make the script run wen you bootedit /home/pi/.xinitrc
- sudo nano /home/pi/.xinitrc
addsudo bash /etc/X11/Xsession.d/xinput_calibrator_pointercal.sh &
before exec openbox-session
and save.
Modify the script to select the correct display:
- sudo nano /etc/X11/Xsession.d/xinput_calibrator_pointercal.sh
modify the lineCALDATA=`xinput_calibrator --output-type xinput -v | grep ' xinput set' | sed 's/^ //g; s/$/;/g'`
to
CALDATA=`DISPLAY=:0.0 xinput_calibrator --output-type xinput -v | grep ' xinput set' | sed 's/^ //g; s/$/;/g'`
and save.
Copy the script and modify it for manual use
sudo cp /etc/X11/Xsession.d/xinput_calibrator_pointercal.sh /etc/X11/Xsession.d/xinput_calibrator_pointercal_wipe.sh
Edit the script and remove the check
- sudo nano /etc/X11/Xsession.d/xinput_calibrator_pointercal_wipe.sh
remove this section form the file:if [ -e $CALFILE ] ; then
if grep replace $CALFILE ; then
echo "Empty calibration file found, removing it"
rm $CALFILE
else
echo "Using calibration data stored in $CALFILE"
. $CALFILE && exit 0
fi
fi
and save.
<command>
<name>Calibrate Touch Panel</name>
<execute>/usr/bin/sudo /bin/sh /etc/X11/Xsession.d/xinput_calibrator_pointercal_wipe.sh</execute>
<confirm>Really calibrate touch screen?</confirm>
<local>true</local>
<remote>true</remote>
<print-permission>true</print-permission>
<add-permission>true</add-permission>
<del-permission>true</del-permission>
<config-permission>true</config-permission>
</command>
Add RepetierServer to the list of allowed users