14 /* local subsystem functions */
16 _bl_write_file(const char *file, int val)
19 int fd = open(file, O_WRONLY);
25 snprintf(buf, sizeof(buf), "%i", val);
26 if (write(fd, buf, strlen(buf)) != (int)strlen(buf))
36 /* local subsystem globals */
37 typedef struct _Bl_Entry
45 static const Bl_Entry search[] =
47 { 'F', "/sys/devices/virtual/backlight/acpi_video0", "max_brightness", "brightness" },
48 { 'D', "/sys/devices/virtual/backlight", "max_brightness", "brightness" },
49 { 'F', "/sys/class/leds/lcd-backlight", "max_brightness", "brightness" },
50 { 'F', "/sys/class/backlight/acpi_video0", "max_brightness", "brightness" },
51 { 'D', "/sys/class/backlight", "max_brightness", "brightness" }
54 /* externally accessible functions */
56 main(int argc, char **argv)
61 int maxlevel = 0, curlevel = -1;
65 for (i = 1; i < argc; i++)
67 if ((!strcmp(argv[i], "-h")) ||
68 (!strcmp(argv[i], "-help")) ||
69 (!strcmp(argv[i], "--help")))
71 printf("This is an internal tool for Enlightenment.\n"
77 level = atoi(argv[1]);
83 printf("ERROR: UNABLE TO ASSUME ROOT PRIVILEGES\n");
88 printf("ERROR: UNABLE TO ASSUME ROOT GROUP PRIVILEGES\n");
93 devs = eeze_udev_find_by_filter("backlight", NULL, NULL);
95 EINA_LIST_FREE(devs, f)
99 str = eeze_udev_syspath_get_sysattr(f, "max_brightness");
102 maxlevel = atoi(str);
103 eina_stringshare_del(str);
104 str = eeze_udev_syspath_get_sysattr(f, "brightness");
107 curlevel = atoi(str);
108 eina_stringshare_del(str);
112 if (maxlevel <= 0) maxlevel = 255;
115 curlevel = ((maxlevel * level) + (500 / maxlevel)) / 1000;
116 // printf("SET: %i, %i/%i\n", level, curlevel, maxlevel);
117 snprintf(buf, sizeof(buf), "%s/brightness", f);
118 return _bl_write_file(buf, curlevel);
120 eina_stringshare_del(f);