Last active
October 15, 2025 13:54
-
-
Save i8degrees/8530e6048091d1c01a0ab2be612071c3 to your computer and use it in GitHub Desktop.
systemd-sleep customizations stub
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- `/usr/lib/systemd/system-sleep` | |
- `chmod +x` | |
```shell | |
#!/bin/bash | |
## REMARK: | |
# - above shebang is required for scripting file | |
# - 1st arg passed to executable file is either "pre" (mean that the entry of a power operation) or "post" (mean that the exit of a power operation) | |
# - 2nd arg passed to executable file is either "suspend", "hibernate", "hybrid-sleep", or "suspend-then-hibernate", depends on what power operation is operating | |
# - SYSTEMD_SLEEP_ACTION environment variable is helpful for "suspend-then-hibernate", it has value of either "suspend", "hibernate", or "suspend-after-failed-hibernate" | |
case $1 in | |
pre) | |
case $2 in | |
hibernate) | |
;; | |
hybrid-sleep) | |
;; | |
suspend) | |
;; | |
suspend-then-hibernate) | |
case $SYSTEMD_SLEEP_ACTION in | |
suspend) | |
;; | |
hibernate) | |
;; | |
suspend-after-failed-hibernate) | |
;; | |
esac | |
;; | |
esac | |
;; | |
post) | |
case $2 in | |
hibernate) | |
;; | |
hybrid-sleep) | |
;; | |
suspend) | |
;; | |
suspend-then-hibernate) | |
case $SYSTEMD_SLEEP_ACTION in | |
suspend) | |
;; | |
hibernate) | |
;; | |
suspend-after-failed-hibernate) | |
;; | |
esac | |
;; | |
esac | |
;; | |
esac | |
``` | |
[SEE ALSO](https://www.freedesktop.org/software/systemd/man/systemd-suspend.service.html) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment