From 779c743bc91dacd46a21a35e26196ad870dc20da Mon Sep 17 00:00:00 2001 From: eugene2021 Date: Thu, 25 Apr 2024 18:08:23 +0800 Subject: [PATCH] Check the last suspend within the time of HoldoffTimeoutUSec as the review advised. --- providers/base/bin/lid_close_suspend_open.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/providers/base/bin/lid_close_suspend_open.sh b/providers/base/bin/lid_close_suspend_open.sh index 84ad0abef..5e4ba9d3f 100755 --- a/providers/base/bin/lid_close_suspend_open.sh +++ b/providers/base/bin/lid_close_suspend_open.sh @@ -1,4 +1,16 @@ -#! /usr/bin/bash +#!/usr/bin/bash + +holdoff_timeout_usec=$(gdbus introspect --system --dest org.freedesktop.login1 --object-path /org/freedesktop/login1 -p | grep HoldoffTimeoutUSec | awk '{print $5}' | awk -F\; '{print $1}') +holdoff_timeout_sec=$(echo "scale=0; $holdoff_timeout_usec / 1000000" | bc) + +if [ "$holdoff_timeout_sec" -ne 0 ]; then + while (journalctl --since "$holdoff_timeout_sec seconds ago" -b 0 -r | grep "suspend exit" >/dev/null 2>&1) + do + echo "The system just resume from suspend, please wait for $holdoff_timeout_sec seconds and continue the test" + sleep 1 + done +fi + prev_suspend_number=$(cat /sys/power/suspend_stats/success) echo "Number of successful suspends until now: $prev_suspend_number" echo "Please close the lid and wait for 5 sec to make it suspend~"