How do I run a command at startup?

Hi everyone, brand new Zynthian user here - just got it set up on a RPI4 and 1920x440 touchscreen. Initially the touchscreen wasn’t responding but I’ve discovered (with some help from Claude) that this command kicks it into life:

DISPLAY=:0.0 xinput set-prop “ILITEK ILITEK-TOUCH” “Device Enabled” 1

Only problem is that I need to run it in Terminal every time Zynthian restarts.

So hopefully an easy question:
How do I run this command automatically?

Thanks!

P.S. I found another topic that suggested adding it to /zynthian/config/zynthian_envars.sh but this doesn’t seem to work - probably something I’m doing wrong as this coding stuff is all a bit new to me!

Hi @grum , welcome to Zynthian!

I think the easiest way to do that is via webconf, search the wiki if you don’t know how to access it. On the main screen, AKA the dashboard, under Hardware, click on the Display you have selected, then set Advanced View at upper right on, then add your statement to Config.

If that doesn’t do what you want, another option is:

May the Force be with you.

3 Likes

Thanks for your help, unfortunately adding the command to the config section of the custom display settings didn’t work as it truncated the text and stripped out the quote marks!!!

The 2nd option also didn’t work. I created the user_config.sh file, made it executable and it works if I execute the script from Terminal but not after a reboot.

Well, you might want to read the rest of the topic where @jofemodo added the hook for the bash script at startup - there was some discussion re different places to execute a startup script and how they relate to starting Zynthian and Jack. I wonder if the user_config.sh file needs to be placed somewhere else.

There is probably a way to ‘escape’ the quotes in the config settings so they won’t be stripped out but I don’t know what has to be done.

Hi @grum! A very warm welcome to the community.

Zynthian purposefully disables some xinput from touch devices when it initialises as part of its multitouch support. It uses the first found touch / pointer device for input. It is plausible that another pointer device connected to your RPi4 is blocking auto detection of the touchscreen. Will you please provide the listing:

DISPLAY=:0 xinput --list

I suspect we have some suboptimal code around this. (I got it working then stepped away, but always felt guilty that it was not very robust.)

We really should not need (and don’t want) to run extra commands. It should just work. :smile:

[Edit] How is your touchscreen attached? Is it using I2C or USB for configuration? If using I2C you may need to add dtoverlay=ilitek,ili251x (or similar) to the “Config” section of webconf HARDWARE->Display. (Enable Advanced view)

1 Like

In that case, when you have time, perhaps you can take a look at the following.
I use an USB keypad (as a remote control) and the bold/long press does not work out of the box. Before the bold timeout is over, autorepeat kicks in.

Looking at zynthian.service there is already a line that suggests that autorepeat is switched off, but that does not work:

# Start X11 with keyboard autorepeat disable (-r) and disabling screen blanking (-s 0)
ExecStart=startx ./zynthian.sh -- -r -s 0 #X11_SERVER_OPTIONS#

To fix this I had to add a command to disable autorepeat, in /etc/rc.local I add

export XAUTHORITY=/root/.Xauthority

and start a shell script:

export DISPLAY=":0"
xset r off

That works fine, but it would be better if it worked out of the box.

Kind regards,
Hans.

1 Like

This should work if using the service command to start zynthian because it has the execute line:

ExecStart=startx ./zynthian.sh -- -r -s 0 -nocursor

which passes -r (disable keyboard autorepeat) to the X session. Why do you start zynthian manually from the command line? When I am debugging, I start the display server first with the command:

X -r -s 0 &
1 Like

I do not start it manually. I switch on the box and it starts by itself. With autorepeat on usb enabled.

I get the impression it disables autorepeat on the wrong session.

But it doesn’t…

Shall I open an issue?

Yeah - probably best to open a ticket. I have been looking at this today and it looks to be working here so add details such as the output of lsusb and dmesg -w whilst you plug the device in.

[Edit] Include output from:

export DISPLAY=:0
xset q
xinput list
xinput list-props <id>
setxkbmap -query

E.G. xinput list shows the keypad with device 9, command would be xinput list-props 9.

Ok, will do.

As usual, when I remove my work-around it suddenly works :unamused_face:

I’ll wait with the ticket until it starts to misbehave again,

Thanks so far, you gave me a nice list of things to check.

Hi, @HansR

Can you explain what you did to make It work. I had not success so far setting Up my USB touch interface; zynthian recognizes the device but in floating slave state. I know the commands to make It work but didn’t manage to execute them at boot time. Perhaps your procedure Will help me.

Thanks in advance.

Hi @smespresati

There are several moments during startup when you can execute commands. What exactly are the problems you are experiencing? Are the commands not being executed, or are errors occurring (which ones?), or are they being executed at the wrong time during startup?

I need more details to give you an advice.

Off topic post moved to GitHub ticket

1 Like

Please move all this info into a GitHub ticket. I need more info like your hardware/software config which will be captured by a webconf Report Issue report. I have some suspisions but need to track it on GitHub, not in this (kinda off topic) thread. BTW xfce4 is the desktop environment we used for the VNC desktop.

done