[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Suspend-sedation Problem



Hi,

I see there's been some recent changes to the https://wiki.debian.org/SystemdSuspendSedation article.

First a change to move from a (my) dumb string check against "/usr/sbin/rtcwake --mode show" output to avoid issues with l10n (while there doesn't appear to be translations for Norwegian, I gather some locales output "alarm: off" as a localized string, not English).

The change moved to first setting WAKEALARM to point to /sys/class/rtc/rtc0/wakealarm with help of systemd "Environment=" and then setting WAKEALARM either an empty string, or teading a number into WAKEALARM, via command substitution -- and finally checking for the WAKEALARM to be zero '[ -z "$(cat $WAKEALARM)"]. Essentially a complicated way to check if /sys/class/rtc/rtc0/wakealarm is an empty (pseudo)file.

(This isn't meant as criticism against the change - the whole thing is more complicated than it should be and the new version shouldn't be prone to l10n bugs).

Then there was a different change, to do numerical comparison against date +%%s. I think the new code contains two errors: a) it should be:

NOW="$(date +%s)";

At least my date complains that % isn't a valid number if "+%%s" is used. Probably a simple typo.

In the case that no wake-alarm is set; WAKEALARM will be the empty string and dash (and bash) will complain that an integer expression is expected. As far as I can tell adding a test for the empty string (-z) and chaining with logical-or (-o) will *not* work:

a=""
if [ -z "${a}" -o 10 -ge "${a}" ]
then
  echo "Never reached."
else
  echo "Then apparently is smaller than null"
fi

So, with the current script there appear to be a couple of issues with both the code and the logic. Now on my end, the original script mostly♤ works; and the comment on the last change of the wiki says the current version works for "KillYourTV". As the wiki isn't a good VCS I'd rather not change the script(again) without a little more feedback.

Is anyone using the current version? Is it working? Did the original version work? That's:

https://wiki.debian.org/SystemdSuspendSedation?action=recall&rev=6

How about rev=11 ? For the record as of now the lates is 13.

I'm not on the list, please add me to cc of any replies.

I'm hoping we can find something that's both clean and correct - and actually works for everyone... :-)

Best regards,

Eirik Schwenke

♤ On occasion my thinkpad T420s refuse to suspend on lid close. I usually just open up the lid and manually go directly to hibernate-disk from the command line. No idea why this sometimes happens.


-- 
Via phone - please excuse quoting and spelling


Reply to: