Skip to content

archlinux: Custom suspend scripting?

I was reading about suspending to RAM and Disk here: https://wiki.archlinux.org/index.php/Suspending_to_Disk_with_hibernate-script

I was wondering if its possible to automatically "wake up" from suspending to RAM and just shut off after four hours (and save battery life)?

Alternatively, could I just have it suspend to RAM first, and then after 4 hours (if uninterrupted), wake up and suspend to disk? I have it setup like this in Windows, but I'm not sure what the best way to do this in arch.

7 points8 comments
Open on Reddit
About this post
Posted
Archived
Score
7 · 100% up
Kind
Text
ID
kblu3

Author

30
posts
174
comments
3
media
View profile

9 comments

unknown author6 hidden

Deleted before we saved it.

5 points

cron and rtcwake

3 points

Okay, I got a working script:

#!/bin/bash
timetowait=3600
STARTTIME="$(date +%s)"
rtcwake -m mem -s "$[timetowait]"
ENDTIME="$(date +%s)"

DIFF=$[($ENDTIME)-($STARTTIME)]
echo $DIFF
if [ $DIFF -gt $timetowait ]; then
        pm-hibernate
fi

I saved it as /etc/acpi/actions/customsleep.sh

I also set /etc/acpi/events/lid to use that script, but it doesn't seem to actually use it. When I close the lid, it uses some other script. Any thoughts?

EDIT: I edited /etc/acpi/handler.sh to point to this script on lid close. Still getting a problem where if it turns on while suspended, it will try to resuspend and crash. Not sure how to prevent that...

2 points
unknown author

Deleted before we saved it.

2 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.