commit 7f5575bfcfe713d52431073184bd1f04bfec7ff3
parent 5bb400bf8e8f0704d760ab09c972415f4b61742b
Author: Friedel Schon <[email protected]>
Date: Tue, 25 Apr 2023 11:30:22 +0200
adding zzz.d to zzz
Diffstat:
3 files changed, 45 insertions(+), 0 deletions(-)
diff --git a/src/exec/zzz.c b/src/exec/zzz.c
@@ -1,3 +1,4 @@
+#include "config.h"
#include "util.h"
#include <errno.h>
@@ -6,6 +7,8 @@
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
+#include <sys/stat.h>
+#include <sys/wait.h>
#include <unistd.h>
@@ -48,6 +51,22 @@ int main(int argc, char** argv) {
printf("Zzzz...\n");
+ struct stat st;
+
+ if (stat(SV_SUSPEND_EXEC, &st) == 0 && st.st_mode & S_IXUSR) {
+ pid_t pid;
+ if ((pid = fork()) == -1) {
+ fprintf(stderr, "failed to fork for " SV_SUSPEND_EXEC ": %s\n", strerror(errno));
+ return 1;
+ } else if (pid == 0) { // child
+ execl(SV_SUSPEND_EXEC, SV_SUSPEND_EXEC, NULL);
+ fprintf(stderr, "failed to execute " SV_SUSPEND_EXEC ": %s\n", strerror(errno));
+ _exit(1);
+ }
+
+ wait(NULL);
+ }
+
if (new_disk) {
if ((sys_disk = open("/sys/power/disk", O_WRONLY | O_TRUNC)) == -1) {
fprintf(stderr, "cannot open /sys/power/disk: %s\n", strerror(errno));
@@ -72,5 +91,19 @@ int main(int argc, char** argv) {
sleep(5);
}
+ if (stat(SV_RESUME_EXEC, &st) == 0 && st.st_mode & S_IXUSR) {
+ pid_t pid;
+ if ((pid = fork()) == -1) {
+ fprintf(stderr, "failed to fork for " SV_RESUME_EXEC ": %s\n", strerror(errno));
+ return 1;
+ } else if (pid == 0) { // child
+ execl(SV_RESUME_EXEC, SV_RESUME_EXEC, NULL);
+ fprintf(stderr, "failed to execute " SV_RESUME_EXEC ": %s\n", strerror(errno));
+ _exit(1);
+ }
+
+ wait(NULL);
+ }
+
printf("Yawn!\n");
}
\ No newline at end of file
diff --git a/usr/share/fiss/resume b/usr/share/fiss/resume
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+for f in /etc/zzz.d/resume/*; do
+ [ -x "$f" ] && "$f"
+done
+\ No newline at end of file
diff --git a/usr/share/fiss/suspend b/usr/share/fiss/suspend
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+for f in /etc/zzz.d/suspend/*; do
+ [ -x "$f" ] && "$f"
+done
+\ No newline at end of file