Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bahamas10/zzz-user-hooks
Call scripts on suspend and resume for the currently logged in user using `zzz`
https://github.com/bahamas10/zzz-user-hooks
Last synced: about 2 months ago
JSON representation
Call scripts on suspend and resume for the currently logged in user using `zzz`
- Host: GitHub
- URL: https://github.com/bahamas10/zzz-user-hooks
- Owner: bahamas10
- License: mit
- Created: 2018-09-25T04:58:23.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-06-12T19:15:03.000Z (over 2 years ago)
- Last Synced: 2024-05-08T19:52:46.866Z (8 months ago)
- Language: Shell
- Homepage: https://www.daveeddy.com/2018/10/01/run-user-scripts-on-suspend-and-wakeup-on-void-linux/
- Size: 5.86 KB
- Stars: 24
- Watchers: 3
- Forks: 7
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
`zzz` User Hooks
================Call scripts on suspend and resume for the currently logged in user using `zzz`.
This was written specifically for Void Linux but should work on any OS that has
or uses the `zzz` command to suspend.Installation
------------`make` can be used to install the scripts:
$ sudo make install
cp user-script /etc/zzz.d
cp hooks/resume/99-user-script /etc/zzz.d/resume
cp hooks/suspend/99-user-script /etc/zzz.d/suspendThis will result in the following layout being created:
$ tree /etc/zzz.d/
/etc/zzz.d/
├── resume
│ └── 99-user-script
├── suspend
│ └── 99-user-script
└── user-script2 directories, 3 files
With these scripts in place, the following scripts will be run for the currently
logged in user:- `~/.onsuspend` - called before the machine is suspended
- `~/.onresume` - called when the machine wakes upThe above scripts will be called with the permissions of the user for whom they
are being called (using `sudo -Hu `). The `DISPLAY` environmental
variable will also be set to the currently active display.You can uninstall with:
$ sudo make uninstall
rm -f /etc/zzz.d/user-script
rm -f /etc/zzz.d/resume/99-user-script
rm -f /etc/zzz.d/suspend/99-user-scriptExample
-------$ sudo zzz
Zzzz... [user-script] called Sun Sep 23 11:33:59 EDT 2018
[user-script] running /home/dave/.onsuspend for user dave (DISPLAY=:0)
[user-script] ran /home/dave/.onsuspend for user dave, exited 0
[user-script] called Sun Sep 23 11:34:05 EDT 2018
[user-script] running /home/dave/.onresume for user dave (DISPLAY=:0)
[user-script] ran /home/dave/.onresume for user dave, exited 0
yawn.Contributing
------------This project uses:
- Bash Style Guide: https://www.daveeddy.com/bash/
- `shellcheck`: https://github.com/koalaman/shellcheckEnsure any code contributions pass `make check`:
```
$ make check
awk 'length($0) > 80 { exit(1); }' user-script
shellcheck user-script
shellcheck hooks/*/99-user-script
```License
-------MIT License