#!/bin/sh # Specifically handling LID events # Can take the form: # button/lid LID close # button/lid LID open # We are only interested in value $3. # Do not turn off machine if external screens are connected. case "$3" in close) should_sleep=true screens=$(find /sys/devices -type f -wholename '*drm/*card*-DP-*/status') while IFS= read -r screen; do if [ "$(cat "$screen")" = connected ]; then should_sleep=false fi done <