copied this from my laptop's /etc/rc.local

master
Jan Danielzick 2021-04-28 08:05:28 +02:00
parent 3124943ec8
commit 856392749c
1 changed files with 23 additions and 0 deletions

23
disable_laptop_lid.sh Normal file
View File

@ -0,0 +1,23 @@
#!/bin/bash
# prevent detection of lid state by unbinding it from the driver because for
# whatever fucking reason some fucking software keeps detecting it and
# suspending the laptop despite that being turned off
echo -n "Disabling lid switch... "
pushd /sys/bus/acpi/drivers/button/ > /dev/null
# get a list of registered buttons for ACPI actions (the janky way)
TEMP=$(find -maxdepth 1 -type l)
# go through the list and if the button has "LID" in its device path file, unbind it
while [ -n "$TEMP" ];
do
if [ $(grep -c "LID" $(echo "$TEMP" | head -n1)/path 2>/dev/null) -gt 0 ] 2>/dev/null
then
echo "$TEMP" | head -n1 | sed 's/^.\///' > unbind
fi
TEMP=$(echo "$TEMP" | sed "1d")
done
popd > /dev/null
echo "Done."
# lid button hopefully disabled