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.


Comments

  • Does that also store the calibration commands in the right config? The calibrators I know just output the code that you would need to paste into the right file.

    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.
  • Due to my limited knowledge of linux I recognise that my problem is difficult. In terms of your points 2 and 3 I understand what is required but have no clue how to do it.

    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





  • Also that file writes to the calibration file it looks to me as it would do this only if the file does not exists, so on a second run even manually it will not do a new calibration.

    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.
  • edited July 2017
    Thank you very much for the assistance!!
    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
    • sudo apt-get update
    • sudo apt-get install -y libts-bin evtest xinput python-dev python-pip
    • sudo pip install evdev
    • sudo apt-get install -y xinput-calibrator

    from http://ozzmaker.com/enable-x-windows-on-piscreen/
    Download and setup the calibration script
    • cd ~
    • sudo cp ~/xinput_calibrator_pointercal.sh /etc/X11/Xsession.d/xinput_calibrator_pointercal.sh
    • sudo chmod +x /etc/X11/Xsession.d/xinput_calibrator_pointercal.sh
    Make the script run wen you boot
    edit /home/pi/.xinitrc

    • sudo nano /home/pi/.xinitrc
    add
    sudo 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 line
    CALDATA=`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.

    Add  the following to extcommands.xml:
    <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
    • sudo -s
    • echo "repetierserver ALL=NOPASSWD: /bin/sh" > /etc/sudoers.d/repetierserver-sh
    • echo "repetierserver ALL=NOPASSWD: /etc/X11/Xsession.d/xinput_calibrator_pointercal_wipe.sh" > /etc/sudoers.d/repetierserver-cal




Sign In or Register to comment.