123456789101112131415161718192021222324252627282930313233343536373839 |
- /*
-
- zzz - a program to imitate FreeBSD's `zzz` sleep utility for laptops, only
- that this one uses `loginctl` for the backend.
- USAGE: zzz
- Sleeps the system (sudo may be required depending on the user's rights)
- Note that in order for this program to work, you must have loginctl available
- in your system. If your distribution uses systemd (i.e. Debian/Ubuntu based,
- Fedora, Arch Linux, etc), it will include it by default. Other non-systemd
- distros can install the standalone elogind daemon instead.
- Copyright 2022- kzimmermann. All Rights reserved.
- This program is Free Software released under the terms and conditions of the
- GNU GPL v3. See https://gnu.org/licenses for more information
- */
- #include <stdlib.h>
- #include <stdio.h>
- int
- main(int argc, char* argv[])
- {
- char* stmt = "loginctl suspend";
- FILE* p;
- p = popen(stmt, "r");
- if (p == NULL) {
- printf("Error: `loginctl` not found.\n");
- printf("You must have loginctl installed (see elogind) in order to suspend your machine in a modern way\n");
- return 1;
- }
- pclose(p);
- return 0;
- }
|