21 lines
388 B
C
21 lines
388 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
int main(int argc, char **argv) {
|
|
FILE *f = fopen("/sys/power/state", "w");
|
|
|
|
if(argc != 2) {
|
|
fprintf(stderr, "%s [mem|standby|freeze|disk]\n", argv[0]);
|
|
exit(1);
|
|
}
|
|
|
|
|
|
if(f == NULL) {
|
|
fprintf(stderr, "%s is unable to write to /sys/power/state.\nAdd the setuid bit?\n", argv[0]);
|
|
exit(1);
|
|
}
|
|
|
|
fprintf(f, "%s", argv[1]);
|
|
|
|
fclose(f);
|
|
}
|