From b37138c845c3236a034e4b95b2ca41fe5bcfc0f3 Mon Sep 17 00:00:00 2001 From: Miles Alan Date: Tue, 12 May 2020 21:36:34 -0500 Subject: [PATCH] Fix pine indicator leds paths for latest pmOS setup and add white (flash) --- programs/sxmo_screenlock.c | 2 +- programs/sxmo_setpineled.c | 21 ++++++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/programs/sxmo_screenlock.c b/programs/sxmo_screenlock.c index 938662c..0e3bb29 100644 --- a/programs/sxmo_screenlock.c +++ b/programs/sxmo_screenlock.c @@ -19,7 +19,7 @@ static char * brightnessfile = "/sys/devices/platform/backlight/backlight/backli void updatepineled(int red, int brightness) { sprintf( pineledcommand, - "sh -c 'echo %d > /sys/devices/platform/leds/leds/pinephone:%s:user/brightness'", + "sh -c 'echo %d > /sys/class/leds/%s:indicator/brightness'", brightness, red ? "red" : "blue" ); diff --git a/programs/sxmo_setpineled.c b/programs/sxmo_setpineled.c index dfb0e78..d808e22 100644 --- a/programs/sxmo_setpineled.c +++ b/programs/sxmo_setpineled.c @@ -4,13 +4,14 @@ #include void usage() { - fprintf(stderr, "Usage: setpineled [red|green|blue] [0-255]\n"); + fprintf(stderr, "Usage: setpineled [red|green|blue|white] [0-255]\n"); } int main(int argc, char *argv[]) { int brightness; char * color; char * command; + char * type; if (argc < 2) { usage(); @@ -25,17 +26,27 @@ int main(int argc, char *argv[]) { } color = argv[argc--]; - if (strcmp(color, "red") && strcmp(color, "blue") && strcmp(color, "green")) { + if ( + strcmp(color, "red") && + strcmp(color, "blue") && + strcmp(color, "green") && + strcmp(color, "white") + ) { usage(); return 1; } + if (!strcmp(color, "white")) { + type = "flash"; + } else { + type = "indicator"; + } + command = malloc(80); sprintf( command, - "sh -c 'echo %d > /sys/devices/platform/leds/leds/pinephone:%s:user/brightness'", - brightness, - color + "sh -c 'echo %d > /sys/class/leds/%s:%s/brightness'", + brightness, color, type ); if (setuid(0)) { fprintf(stderr, "setuid(0) failed\n");