From f3777c15f1e88bff05a2b6aa0d08d5072ce8d1bd Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Mon, 23 Aug 2021 18:59:49 -0400 Subject: alsvid3: Turn off screen on lid close Inspired by . --- (limited to 'hosts/alsvid3/postinst') diff --git a/hosts/alsvid3/postinst b/hosts/alsvid3/postinst index eb6f377..892bf70 100644 --- a/hosts/alsvid3/postinst +++ b/hosts/alsvid3/postinst @@ -27,12 +27,41 @@ cat >"${target}/boot/grub/libreboot_grub.cfg" <<-EOF boot EOF -# Don't suspend on lid close. -cp -p "${target}/etc/elogind/logind.conf" \ - "${target}/etc/elogind/logind.conf.dist" -sed 's/^.*\(HandleLidSwitch.*\)=.*$/\1=ignore/' \ - "${target}/etc/elogind/logind.conf.dist" \ - >"${target}/etc/elogind/logind.conf" +# Don't suspend on lid close. Turn off screen instead. +# Unfortunately, colord recursively depends on a logind. +in_target apt-get -q -y --autoremove purge elogind || return 1 +# Install acpid without acpi-support-base. +in_target apt-get -q -y --no-install-recommends install acpid +cat >"${target}/etc/acpi/events/button" <<'EOF' +event=button.* +action=/etc/acpi/button.sh %e +EOF +cat >"${target}/etc/acpi/button.sh" <<'EOF' +#!/bin/sh + +set -eu + +export XAUTHORITY=~pj/.Xauthority +export DISPLAY=:0 + +case "${1}" in + 'button/lid') + case "${3}" in + 'open') + logger 'acpid: lid opened' + xset dpms force on + ;; + 'close') + logger 'acpid: lid closed' + xset dpms force off + ;; + esac +esac +# button/sleep could be handled too, but there are two events per press with +# different $2, $3, and $4. +# More events may be exposed if thinkpad_acpi is patched to support Taurinus: +# http://git.proteanos.com/pkg/linux-libre-4.19.git/tree/patches/03_thinkpad_acpi_support-libiquity-taurinus-laptops.patch +EOF # Turn on numlock on the VTs. cat >"${target}/etc/rc.local" <<'EOF' -- cgit v0.9.1