From 1a3bfe39a521e863b242752390208a798c7d2229 Mon Sep 17 00:00:00 2001 From: Shogo Yamazaki Date: Sun, 25 Aug 2024 21:17:36 +0900 Subject: [PATCH] Check write permission on `/sys/power/disk` when hibernate --- zzz | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/zzz b/zzz index 38f65d4..679fd82 100755 --- a/zzz +++ b/zzz @@ -36,7 +36,10 @@ case "$ZZZ_MODE" in hibernate) grep -q disk /sys/power/state || fail "hibernate not supported";; esac -test -w /sys/power/state || fail "sleep permission denied" +if ! [ -w /sys/power/state ] || { + ! [ -w /sys/power/disk ] && [ "$ZZZ_MODE" = hibernate ];}; then + fail "sleep permission denied" +fi ( flock -n 9 || fail "another instance of zzz is running"