diff options
author | davidovski <david@davidovski.xyz> | 2022-03-30 17:54:09 +0100 |
---|---|---|
committer | davidovski <david@davidovski.xyz> | 2022-03-30 17:54:09 +0100 |
commit | de16da348671bd797500ab144ae56d23e88c7463 (patch) | |
tree | 728ec7d354049c977b34d9693109cd5683992a30 /extra/acpid/lid-closed | |
parent | 9ae31d6c582fbb636625a87d0921fd914f33c05e (diff) |
fixed initd files
Diffstat (limited to 'extra/acpid/lid-closed')
-rw-r--r-- | extra/acpid/lid-closed | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/extra/acpid/lid-closed b/extra/acpid/lid-closed new file mode 100644 index 0000000..57ffb71 --- /dev/null +++ b/extra/acpid/lid-closed @@ -0,0 +1,21 @@ +#!/bin/sh +# This script exits with status 0 if the latop's lid is closed, 1 if opened, +# 10 if /proc/acpi/button/lid/LID/state does not exist or is not readable. +set -u + +STATE_FILE='/proc/acpi/button/lid/LID/state' + +verbose=false +[ "${1:-}" = '-v' ] && verbose=true + +if ! [ -r "$STATE_FILE" ]; then + $verbose && echo "$STATE_FILE does not exist or is not readable!" >&2 + exit 10 +fi + +read -r _ state < "$STATE_FILE" || exit 10 + +[ "$state" = 'closed' ]; rc=$? + +$verbose && echo $rc +exit $rc |