~emersion/public-inbox

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
2 2

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

Ben Collerson <benc@benc.cc>
Details
Message ID
<20230306115720.3203521-1-benc@benc.cc>
DKIM signature
missing
Download raw message
Patch: +13 -1
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
Details
Message ID
<xQGhdBALfWCtgpB9enRR6vrK_OJxF-A3bZUfbgpqJoGCd9OyZ3uWKsBfjbofA55yGxVQ1Cfd3w_2Iq-4Vixcx0vEhRzIZy3YEaM7CT_o1nk=@emersion.fr>
In-Reply-To
<20230306115720.3203521-1-benc@benc.cc> (view parent)
DKIM signature
missing
Download raw message
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.
Ben Collerson <benc@benc.cc>
Details
Message ID
<3256a0c2-de56-41d2-ac7e-b764b60f7da2@app.fastmail.com>
In-Reply-To
<xQGhdBALfWCtgpB9enRR6vrK_OJxF-A3bZUfbgpqJoGCd9OyZ3uWKsBfjbofA55yGxVQ1Cfd3w_2Iq-4Vixcx0vEhRzIZy3YEaM7CT_o1nk=@emersion.fr> (view parent)
DKIM signature
missing
Download raw message
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.

On Mon, 6 Mar 2023, at 23:23, Simon Ser wrote:
> 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.
Reply to thread Export thread (mbox)