~kennylevinsen/poweralertd-devel

poweralertd: feat: add usage -h v2 SUPERSEDED

~cyrinux: 2
 feat: add usage -h
 fix: make silent global instead of local

 3 files changed, 18 insertions(+), 13 deletions(-)
#637696 .build.yml failed
poweralertd/patches/.build.yml: FAILED in 16s

[feat: add usage -h][0] v2 from [~cyrinux][1]

[0]: https://lists.sr.ht/~kennylevinsen/poweralertd-devel/patches/26915
[1]: mailto:cyril@levis.name

✗ #637696 FAILED poweralertd/patches/.build.yml https://builds.sr.ht/~kennylevinsen/job/637696
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/~kennylevinsen/poweralertd-devel/patches/26915/mbox | git am -3
Learn more about email & git

[PATCH poweralertd v2 1/2] feat: add usage -h Export this patch

From: Cyril Levis <cyril@levis.name>

---
 main.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/main.c b/main.c
index 3e11d83..2148b6d 100644
--- a/main.c
+++ b/main.c
@@ -127,13 +127,19 @@ static int send_warning_update(sd_bus *bus, struct upower_device *device) {
	return notify(bus, title, msg, &device->notifications[SLOT_WARNING], urgency);
}

static const char usage[] = "usage: %s [options]\n"
"  -h				show this help message\n"
"  -s				ignore the events at startup\n"
"  -i <device_type>		ignore this device type, can be use several times\n";


int main(int argc, char *argv[]) {
	int opt = 0;
	int device_type = 0;
	int ignore_types_mask = 0;
	bool ignore_initial = false;

	while ((opt = getopt(argc, argv, "si:")) != -1) {
	while ((opt = getopt(argc, argv, "hsi:")) != -1) {
		switch (opt) {
		case 'i':
	   		device_type = upower_device_type_int(optarg);
@@ -147,9 +153,10 @@ int main(int argc, char *argv[]) {
		case 's':
			ignore_initial = true;
			break;
		case '?':
			fprintf(stderr, "Usage: %s [-i type] [-s]\n", argv[0]);
			exit(EXIT_FAILURE);
		case 'h':
		default:
			fprintf(stderr, usage, argv[0]);
			return opt == 'h' ? EXIT_SUCCESS : EXIT_FAILURE;
		}
	}

-- 
2.32.0

[PATCH poweralertd v2 2/2] fix: make silent global instead of local Export this patch

From: Cyril Levis <cyril@levis.name>

I want at startup no notification but everything after.
---
 main.c   | 15 +++++++--------
 upower.h |  1 -
 2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/main.c b/main.c
index 2148b6d..1be4449 100644
--- a/main.c
+++ b/main.c
@@ -138,6 +138,7 @@ int main(int argc, char *argv[]) {
	int device_type = 0;
	int ignore_types_mask = 0;
	bool ignore_initial = false;
	bool initialized = false;

	while ((opt = getopt(argc, argv, "hsi:")) != -1) {
		switch (opt) {
@@ -190,13 +191,14 @@ int main(int argc, char *argv[]) {
			struct upower_device *device = state.devices->items[idx];

			if ((ignore_types_mask & (1 << device->type))) {
				continue;
				goto next_device;
			}

			if (device->current.serial == 0 && ignore_initial) {
				continue;
			if (!initialized && ignore_initial) {
				goto next_device;
			}


			if (upower_device_has_battery(device)) {
				ret = send_state_update(user_bus, device);
				if (ret < 0) {
@@ -215,7 +217,7 @@ int main(int argc, char *argv[]) {
					goto finish;
				}
			}

next_device:
			device->last = device->current;
		}

@@ -246,10 +248,7 @@ int main(int argc, char *argv[]) {
			goto finish;
		}

		for (int idx = 0; idx < state.devices->length; idx++) {
		 	struct upower_device *device = state.devices->items[idx];
			device->current.serial = device->last.serial + 1;
		}
		initialized = true;

	}

diff --git a/upower.h b/upower.h
index a397c40..f914a10 100644
--- a/upower.h
+++ b/upower.h
@@ -62,7 +62,6 @@ enum change_slot {
struct upower_device_props {
	int generation;
	int online;
	int serial;
	double percentage;
	enum upower_device_state state;
	enum upower_device_level warning_level;
-- 
2.32.0
poweralertd/patches/.build.yml: FAILED in 16s

[feat: add usage -h][0] v2 from [~cyrinux][1]

[0]: https://lists.sr.ht/~kennylevinsen/poweralertd-devel/patches/26915
[1]: mailto:cyril@levis.name

✗ #637696 FAILED poweralertd/patches/.build.yml https://builds.sr.ht/~kennylevinsen/job/637696