Re: [hackers] [slstatus][PATCH] backlight: implemented openbsd support

From: lucas <lucas_AT_nanashi.co>
Date: Wed, 23 May 2018 16:30:41 -0300

Tobias,

> See my notes below the commit message of the patch.

I saw the note just after sending the email. My bad. Still, I think that
slstatus shouldn't be run as root. It would be nice to find a workaround
when launching X from xenodm.

> Updated diff below.
>
> diff --git a/components/backlight.c b/components/backlight.c
> index 21e06a1..4234164 100644
> --- a/components/backlight.c
> +++ b/components/backlight.c
> _AT_@ -39,7 +39,7 @@
> const char *
> backlight_perc(const char *unused)
> {
> - int fd, err;
> + int fd;
> struct wsdisplay_param wsd_param = {
> .param = WSDISPLAYIO_PARAM_BRIGHTNESS
> };
> _AT_@ -48,11 +48,12 @@
> warn("could not open /dev/ttyC0");
> return NULL;
> }
> - if ((err = ioctl(fd, WSDISPLAYIO_GETPARAM, &wsd_param)) < 0) {
> + if ((ioctl(fd, WSDISPLAYIO_GETPARAM, &wsd_param)) < 0) {

Haven't taken a look at the rest of the code, but are the extra () used
everywhere?

> warn("ioctl 'WSDISPLAYIO_GETPARAM' failed");
> return NULL;
> }
> - return bprintf("%d", wsd_param.curval * 100 / wsd_param.max);
> + return bprintf("%d", wsd_param.curval * 100 /
> + (wsd_param.max - wsd_param.min));

Better, but .curval is still between .min and .max, so you should substract
.min from it to get the right percentage.

> }
>
> #endif
>
Received on Wed May 23 2018 - 21:30:41 CEST

This archive was generated by hypermail 2.3.0 : Wed May 23 2018 - 21:36:24 CEST