I'm making a script to disable my mouse when the screen closes because that was causing the laptop to wake up while closed and waste power. It is successfully putting the laptop back to sleep when it awakes while closed, but it isn't disabling the mouse. The script:
#!/bin/bash
#βββββββββββββββββββββββββββββββββββββββββ
#βSolves the problem of laptop waking β
#βup while suspended due to getting inputβ
#βfrom the mouse β
#β β
#βNeeds to be set up with ACPI to start β
#βwhen the lid closes β
#β β
#βShould not run while the laptop is in β
#βuse, only when the lid is closed β
#β β
#βv1 β
#βββββββββββββββββββββββββββββββββββββββββ
# xinput list
# then, find your mouse id and put it here
# possibly when you plug in more devices this changes
device=9
# use whereis to make sure these paths are right
cat=/usr/bin/cat
grep=/usr/bin/grep
xinput=/usr/bin/xinput
systemctl=/usr/bin/systemctl
sleep=/usr/bin/sleep
# might be LID instead of LID0 or some other place entirely
# script depends on this file containing "open" when open
lidstate=/proc/acpi/button/lid/LID0/state
while :; do
$cat $lidstate | $grep open
if [ $? -ne 0 ]; then
# lid closed
/usr/bin/echo helloworld >>/tmp/lid-close-log
$xinput list >>/tmp/lid-close-log
$xinput disable $device
$systemctl suspend
else
# lid open
$xinput enable $device
exit
fi
$sleep 1
done
I'm printing the result of xinput list into a text file to try to figure out the issue, but nothing is printed into that text file other than the helloworld. I think there is something stopping xinput commands from working properly. can someone help me out with this? i cant figure out the issue