~emersion/public-inbox

chayang: add an option to provide a lock command v1 SUPERSEDED

Ben Collerson: 1
 add an option to provide a lock command

 1 files changed, 13 insertions(+), 1 deletions(-)
I did a second version that waits for the lock command to finish. This gets rid of the sleep. I can add more error handling also.
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~emersion/public-inbox/patches/39523/mbox | git am -3
Learn more about email & git

[PATCH chayang] add an option to provide a lock command Export this patch

This is an attempt to make the transition from chayang to swaylock (or
other screenlocker) more transparent. It attempts to stop the flash of
the unlocked screen between the two processes.
---
 main.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/main.c b/main.c
index 4180f69..f0966ff 100644
--- a/main.c
+++ b/main.c
@@ -265,8 +265,9 @@ int main(int argc, char *argv[]) {
	wl_list_init(&state.seats);

	double delay_sec = 3;
	char *command = NULL;
	while (1) {
		int opt = getopt(argc, argv, "hd:");
		int opt = getopt(argc, argv, "hc:d:");
		if (opt < 0) {
			break;
		}
@@ -281,6 +282,9 @@ int main(int argc, char *argv[]) {
				return 1;
			}
			break;
		case 'c':;
			command = optarg;
			break;
		default:
			fprintf(stderr, "usage: chayang [-d seconds]\n");
			return opt == 'h' ? 0 : 1;
@@ -352,6 +356,13 @@ int main(int argc, char *argv[]) {
		ret = 2;
	}

	if (command && ret == 0) {
		if (fork() == 0) {
			execl("/bin/sh", "/bin/sh", "-c", command, NULL);
		}
		sleep(1);
	}

	struct chayang_output *output_tmp;
	wl_list_for_each_safe(output, output_tmp, &state.outputs, link) {
		destroy_output(output);
@@ -371,3 +382,4 @@ int main(int argc, char *argv[]) {

	return ret;
}

-- 
2.39.2
I really don't like the sleep(1) in there. Maybe we could wait for the
subprocess to exit instead.

(Also this patch is missing error handling.)

I wonder if there's a better solution to this problem though.