summaryrefslogtreecommitdiff
path: root/repo/acpid/lid-closed
diff options
context:
space:
mode:
authordavidovski <david@davidovski.xyz>2022-05-31 11:05:19 +0100
committerdavidovski <david@davidovski.xyz>2022-05-31 11:05:19 +0100
commit48ca75555522716f0f686dcae3dd6cf3d8ad714d (patch)
tree00c0f58550ba4661e87376f2f02c8001c69bae44 /repo/acpid/lid-closed
parent871b2b573f01c1b3176a0f65458b3d281b41c437 (diff)
removed idea of repos
Diffstat (limited to 'repo/acpid/lid-closed')
-rw-r--r--repo/acpid/lid-closed21
1 files changed, 21 insertions, 0 deletions
diff --git a/repo/acpid/lid-closed b/repo/acpid/lid-closed
new file mode 100644
index 0000000..57ffb71
--- /dev/null
+++ b/repo/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