perror("open");
return -1;
}
- snprintf(buf, sizeof(buf), "%i", val);
+ snprintf(buf, sizeof(buf), "%d", val);
if (write(fd, buf, strlen(buf)) != (int)strlen(buf))
{
perror("write");
close(fd);
return -1;
}
+ printf("BACKLIGHT: %s -> %i\n", file, val);
close(fd);
return 0;
}
-/* local subsystem globals */
-typedef struct _Bl_Entry
-{
- char type;
- const char *base;
- const char *max;
- const char *set;
-} Bl_Entry;
-
-static const Bl_Entry search[] =
-{
- { 'F', "/sys/devices/virtual/backlight/acpi_video0", "max_brightness", "brightness" },
- { 'D', "/sys/devices/virtual/backlight", "max_brightness", "brightness" },
- { 'F', "/sys/class/leds/lcd-backlight", "max_brightness", "brightness" },
- { 'F', "/sys/class/backlight/acpi_video0", "max_brightness", "brightness" },
- { 'D', "/sys/class/backlight", "max_brightness", "brightness" }
-};
-
/* externally accessible functions */
int
main(int argc, char **argv)
eeze_init();
devs = eeze_udev_find_by_filter("backlight", NULL, NULL);
- if (!devs) return -1;
+ if (!devs)
+ {
+ devs = eeze_udev_find_by_filter("leds", NULL, NULL);
+ if (!devs) return -1;
+ }
+ if (eina_list_count(devs) > 1)
+ {
+ const char *s = NULL;
+ Eina_List *l, *new = NULL;
+ Eina_Bool use = EINA_FALSE;
+
+ /* prefer backlights of type "firmware" where available */
+ EINA_LIST_FOREACH(devs, l, f)
+ {
+ s = eeze_udev_syspath_get_sysattr(f, "type");
+ use = (s && (!strcmp(s, "firmware")));
+ eina_stringshare_del(s);
+ if (!use) continue;
+ eina_list_move_list(&new, &devs, l);
+ EINA_LIST_FREE(devs, f)
+ eina_stringshare_del(f);
+ devs = new;
+ break;
+ }
+ }
EINA_LIST_FREE(devs, f)
{
const char *str;
return _bl_write_file(buf, curlevel);
}
eina_stringshare_del(f);
+ /* Currently this will set brightness levels on ALL detected devices
+ If this is not desired, add a break here
+ */
}
return -1;