You are not logged in.

#1 2023-10-29 09:55:57

tesla135
Member
Registered: 2013-06-27
Posts: 76

[SOLVED]Disable touchpad with xinput

Hi, I have the next shell script that disables my touchpad

#!/bin/bash

sleep 10

id=$(xinput list | grep TouchPad | grep -Eo "id=[0-9]+" | grep -Eo "[0-9]+")

device_id=$(xinput list-props "SynPS/2 Synaptics TouchPad" | grep "Device Enabled" | grep -Eo "\([0-9]+\)" | tr -d "()")

xinput set-prop $id $device_id 0

If I execute it manually it works, If put it /home/admin1/.config/autostart/ it gets executed but xinput does not do anything, if I put it in a cronjob to run every minute, same effect.

In .xinitrc it does not execute.

Last edited by tesla135 (2023-10-29 16:23:00)

Offline

#2 2023-10-29 12:29:18

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,074

Re: [SOLVED]Disable touchpad with xinput

The cronjob will suffer from the missing environment variables (notably DISPLAY; perhaps XAUTHORITY)
"xinput disable $id", and you can btw. just use the device name - how exactly do you assess that
1. the script gets exsecuted
2. "xinput does not do anything"

Is your xinitrc in use at all? How and into what kind of session do you login?

Also https://wiki.archlinux.org/title/Libinp … ation_file & https://man.archlinux.org/man/extra/xor … #Option~40

Offline

#3 2023-10-29 14:10:51

tesla135
Member
Registered: 2013-06-27
Posts: 76

Re: [SOLVED]Disable touchpad with xinput

exported variables Display and XAUTHORITY fixed the problem

sleep 10

export DISPLAY=:0
export XAUTHORITY=/home/user/.Xauthority

xinput disable "SynPS/2 Synaptics TouchPad"

For my xinitrc  used  a basic /etc/X11/xinit/xinitrc, and at the bottom I used exec mate-session for my mate DE.

And I lanch it with startx.

Last edited by tesla135 (2023-10-29 15:31:19)

Offline

#4 2023-10-29 14:20:14

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,074

Re: [SOLVED]Disable touchpad with xinput

Is that from your /home/admin1/.config/autostart/ or the cronjob?

In .xinitrc it does not execute … I lanch it with startx.

Post the xinitrc you attempted.

Offline

#5 2023-10-29 15:17:12

tesla135
Member
Registered: 2013-06-27
Posts: 76

Re: [SOLVED]Disable touchpad with xinput

#!/bin/sh

userresources=$HOME/.Xresources
usermodmap=$HOME/.Xmodmap
sysresources=/etc/X11/xinit/.Xresources
sysmodmap=/etc/X11/xinit/.Xmodmap

# merge in defaults and keymaps

if [ -f $sysresources ]; then

    xrdb -merge $sysresources

fi

if [ -f $sysmodmap ]; then
    xmodmap $sysmodmap
fi

if [ -f "$userresources" ]; then

    xrdb -merge "$userresources"

fi

if [ -f "$usermodmap" ]; then
    xmodmap "$usermodmap"
fi

# start some nice programs

if [ -d /etc/X11/xinit/xinitrc.d ] ; then
 for f in /etc/X11/xinit/xinitrc.d/?*.sh ; do
  [ -x "$f" ] && . "$f"
 done
 unset f
fi

exec mate-session 

echo test >> /home/admin1/log

#/home/scripts/disable_touchpad.sh

QT_SCALE_FACTOR=0.8 VirtualBox

After exec mate-session.. that echo line or the commented script is not executed

Is that from your /home/admin1/.config/autostart/ or the cronjob?

cronjob

Last edited by tesla135 (2023-10-29 15:30:48)

Offline

#6 2023-10-29 15:22:25

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,074

Re: [SOLVED]Disable touchpad with xinput

Please use [code][/code] tags, not "quote" tags. Edit your post in this regard.

https://man.archlinux.org/man/core/man-pages/exec.1p.en
"exec mate-session" replaces the script process w/mate-session, even if it didn't you wouldn't reach the echo line until mate-session terminated.

…
/home/scripts/disable_touchpad.sh & # there's a delay in that script anyway, otherwise you could (sleep 10; /home/scripts/disable_touchpad.sh) &
exec mate-session

Offline

#7 2023-10-29 15:55:06

tesla135
Member
Registered: 2013-06-27
Posts: 76

Re: [SOLVED]Disable touchpad with xinput

/home/scripts/disable_touchpad.sh & exec mate-session

Well.. disable_touchpad.sh it's executed without any effect (so those exported variables are wrong in xinit?)

P.S. I added a longer delay, and mate took longer to execute;

Offline

#8 2023-10-29 15:59:15

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,074

Re: [SOLVED]Disable touchpad with xinput

You don't have to export any of those but typically they'd be correct - it's more likely that mate re-activates the device.
"mate took longer to execute" makes no sense as long as the script is forked (the ampersand) b/c xinitrc triggers the script and immediately moves on to exec mate-session.
Does it take 10+ seconds longer to execute??

Offline

#9 2023-10-29 16:05:06

tesla135
Member
Registered: 2013-06-27
Posts: 76

Re: [SOLVED]Disable touchpad with xinput

seth wrote:

You don't have to export any of those but typically they'd be correct - it's more likely that mate re-activates the device.
"mate took longer to execute" makes no sense as long as the script is forked (the ampersand) b/c xinitrc triggers the script and immediately moves on to exec mate-session.
Does it take 10+ seconds longer to execute??

I tested 30 seconds, and it tooked 30+ seconds after startx

P.S. I commented those exports, still no effect

Last edited by tesla135 (2023-10-29 16:10:53)

Offline

#10 2023-10-29 16:08:38

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,074

Re: [SOLVED]Disable touchpad with xinput

Post the actual xinitrc

Offline

#11 2023-10-29 16:12:21

tesla135
Member
Registered: 2013-06-27
Posts: 76

Re: [SOLVED]Disable touchpad with xinput

#!/bin/sh

userresources=$HOME/.Xresources
usermodmap=$HOME/.Xmodmap
sysresources=/etc/X11/xinit/.Xresources
sysmodmap=/etc/X11/xinit/.Xmodmap

# merge in defaults and keymaps

if [ -f $sysresources ]; then

    xrdb -merge $sysresources

fi

if [ -f $sysmodmap ]; then
    xmodmap $sysmodmap
fi

if [ -f "$userresources" ]; then

    xrdb -merge "$userresources"

fi

if [ -f "$usermodmap" ]; then
    xmodmap "$usermodmap"
fi

# start some nice programs

if [ -d /etc/X11/xinit/xinitrc.d ] ; then
 for f in /etc/X11/xinit/xinitrc.d/?*.sh ; do
  [ -x "$f" ] && . "$f"
 done
 unset f
fi

/home/scripts/disable_touchpad.sh && exec mate-session

#QT_SCALE_FACTOR=0.8 VirtualBox

Offline

#12 2023-10-29 16:14:52

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,074

Re: [SOLVED]Disable touchpad with xinput

ONE ampersand.
Two ampersands are a logical connector - the line says "run disable_touchpad.sh and only if that succeeds run exec mate-session afterwards"

Offline

#13 2023-10-29 16:22:00

tesla135
Member
Registered: 2013-06-27
Posts: 76

Re: [SOLVED]Disable touchpad with xinput

seth wrote:

ONE ampersand.
Two ampersands are a logical connector - the line says "run disable_touchpad.sh and only if that succeeds run exec mate-session afterwards"

Yeah, It worked, thx

Offline

Board footer

Powered by FluxBB