From 856392749c23823d6c745f599e27c8de3b1d2e90 Mon Sep 17 00:00:00 2001 From: Jan Danielzick Date: Wed, 28 Apr 2021 08:05:28 +0200 Subject: [PATCH] copied this from my laptop's /etc/rc.local --- disable_laptop_lid.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 disable_laptop_lid.sh 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