diff options
| author | Nathan Reiner <nathan@nathanreiner.xyz> | 2023-02-08 13:19:56 +0100 |
|---|---|---|
| committer | Nathan Reiner <nathan@nathanreiner.xyz> | 2023-02-08 13:19:56 +0100 |
| commit | d7229970f8910aa756d299f8bdceee7f4d1fbfbc (patch) | |
| tree | a95ff2e6bd50578d34d6449c9fde173acc0ef59c /core/powerctl.c | |
| parent | e947b1459f93f11ad91f3e920676fe1b828281e7 (diff) | |
add env and make smash be able to parse files with comments
Diffstat (limited to 'core/powerctl.c')
| -rw-r--r-- | core/powerctl.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/core/powerctl.c b/core/powerctl.c new file mode 100644 index 0000000..cf887bf --- /dev/null +++ b/core/powerctl.c @@ -0,0 +1,29 @@ +#include "../lib/sys/reboot.h" +#include "../lib/cstr/cstr.h" +#include "../lib/io/io.h" +#include "../lib/sys/sync.h" + +int main(int argc, char **argv) { + if (argc != 2) { + wf(STDERR_FD, "powerctl [poweroff|reboot|halt|hard-reset|suspend]\n"); + return -1; + } + + char *command = argv[1]; + + sync(); + + if (cstr_compare(command, "poweroff")) { + reboot(REBOOT_POWEROFF); + } else if (cstr_compare(command, "reboot")) { + reboot(REBOOT_RESTART); + } else if (cstr_compare(command, "halt")) { + reboot(REBOOT_HALT_SYSTEM); + } else if (cstr_compare(command, "hard-reset")) { + reboot(REBOOT_HARD_RESET); + } else if (cstr_compare(command, "suspend")) { + reboot(REBOOT_SUSPEND); + } + + return -1; +} |