summaryrefslogtreecommitdiff
path: root/extra/acpid/lid-closed
blob: 57ffb713bd589fadc003534bdd07173778274e14 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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