diff --git a/disable_laptop_lid.sh b/disable_laptop_lid.sh new file mode 100644 index 0000000..f942e92 --- /dev/null +++ b/disable_laptop_lid.sh @@ -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