From 2674654c393bc51dee027d88516bb4ed93e15c7f Mon Sep 17 00:00:00 2001 From: Clayton Craft Date: Sat, 20 Mar 2021 00:26:24 -0700 Subject: [PATCH] fbd-ledctrl: fix matching of trigger in list of triggers If the trigger is the last thing in sysfs_path/LED_TRIGGER_ATTR, then the new-line at the end of the output causes g_strv_contains to fail to find the trigger in the list. This strips the new-line before splitting the output into a list for searching. You can see the problem this patch fixes with the librem 5, by: $ rmmod ledtrig-timer # or whatever is listed at the end, so 'pattern' is the last thing $ cat /sys/devices/platform/pwmleds/leds/blue:status/trigger [none] kbd-scrolllock ... pattern $ fbd-ledctrl -p /sys/devices/platform/pwmleds/leds/blue:status -t pattern Failed to set perms of /sys/devices/platform/pwmleds/leds/blue:status/pattern to 101: No such file or directory $ modprobe ledtrig-timer $ cat /sys/devices/platform/pwmleds/leds/blue:status/trigger [none] kbd-scrolllock ... pattern timer $ fbd-ledctrl -p /sys/devices/platform/pwmleds/leds/blue:status -t pattern --- src/fbd-ledctrl.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/fbd-ledctrl.c b/src/fbd-ledctrl.c index 9386403..873a58a 100644 --- a/src/fbd-ledctrl.c +++ b/src/fbd-ledctrl.c @@ -102,6 +102,7 @@ set_trigger (const char *sysfs_path, const char *trigger) * same trigger over and over again in a udev rule. */ val = read_sysfs_attr (sysfs_path, LED_TRIGGER_ATTR); + g_strstrip(val); triggers = g_strsplit (val, " ", 0); /*